jixiaoleng4

发送消息太频繁会出现禁言消息

1:导入wxpy模块

pip install wxpy
pip3 install wxpy #二者选一

  

调用模块

# 导入模块
from wxpy import *
# 初始化机器人,扫码登陆
bot = Bot()
bot = Bot(console_qr=True) #如果是在服务器不能弹出二维码,可以选择使用这个,可以改True为1,2,3 来改变图案的大小
bot = Bot(
cache_path=True) #开启缓存,不必每次都扫码
# 给机器人自己发送消息
bot.self.send(\'Hello World!\')
# 给文件传输助手发送消息
bot.file_helper.send(\'Hello World!\')

wxpy同时也包括了发送不同类型消息的方法,通过这些方法我们可以发送各种不同类型的消息。以下是文档给出的样例使用方式:  

# 发送文本
my_friend.send(\'Hello, WeChat!\')
# 发送图片
my_friend.send_image(\'my_picture.png\')
# 发送视频
my_friend.send_video(\'my_video.mov\')
# 发送文件
my_friend.send_file(\'my_file.zip\')
# 以动态的方式发送图片
my_friend.send(\'@img@my_picture.png\') 

  

如果要发送给指定好友
my_friend = bot.friends().search(\'cjkk\')[0]  #这个将my_firend定义成cjkk这个用户

  

监听并给指定好友回复消息

# 回复 my_friend 发送的消息
@bot.register(my_friend)
def reply_my_friend(msg):
    return \'received: {} ({})\'.format(msg.text, msg.type)

  

最后要保持程序不自动结束
embed()

  

附上官方文档链接:功能实在太多了
http://wxpy.readthedocs.io/





分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2021-06-30
  • 2021-11-21
  • 2022-12-23
  • 2021-12-22
  • 2021-12-05
猜你喜欢
  • 2018-05-29
  • 2021-06-07
  • 2021-12-12
  • 2021-12-22
相关资源
相似解决方案