zoukankan      html  css  js  c++  java
  • 本想用python来写个 好友发送给我指定的号,然后截屏发给好友,但是消息分割处理小毛病,还在测试

    from wxpy import *
    from PIL import ImageGrab
    import os
    img_path_name='1.jpg'
    def jiepin(img_path=img_path_name):
    
        try:
            # 删除此文件
            os.remove(img_path)
        except:
            print('无此文件:'+img_path)
        
        #无参数,默认全屏截图
        ImageGrab.grab().save(img_path)
    
    bot = Bot()
    # 获取好友
    my_friend = bot.friends().search('小和')[0]
    
    # 搜索信息
    messages = bot.messages.search(keywords='测试', sender=bot.self)
    
    for message in messages:
        print(message)
    
    # 发送文本
    my_friend.send('Hello, WeChat!')
    # 发送图片
    
    # my_friend.send_image(img_path_name)
    # 删除此文件
    # os.remove(img_path_name)
    
    
    # 发送视频
    # my_friend.send_video('my_video.mov')
    # 发送文件
    # my_friend.send_file('my_file.zip')
    # 以动态的方式发送图片
    # my_friend.send('@img@my_picture.png')
    
    # # 发送公众号
    # my_friend.send_raw_msg(
    #     # 名片的原始消息类型
    #     raw_type=42,
    #     # 注意 `username` 在这里应为微信 ID,且被发送的名片必须为自己的好友
    #     raw_content='<msg username="wxpy_bot" nickname="wxpy 机器人"/>'
    # )
    
    
    # 消息接收监听器
    @bot.register()
    def print_others(msg):
        print('消息:',msg)    
        print(msg.chat)
        # print(len(chat_name['Friend']))
        print(msg.text)
        # print(len(msg.text))
        print('__'*10)
        # if chat_name['Friend'].index('qq496631085'):
        #     r_mes = msg.text
        #     print(r_mes)
        #     if str(r_mes)=='1':
        #         jiepin()
        #         msg.reply_image(img_path_name)
        #     if str(r_mes)=='2':
        #         msg.reply('该指令没指定功能')
    
        
        # 输出监听到的消息
        # try:
        #     chat_name = msg.chat
        #     print(chat_name['Friend'])
    
        #     if 'qq496631085'==chat_name['Friend']:
        #         r_mes = msg.text
        #         print(r_mes)
        #         if str(r_mes)=='1':
        #             jiepin()
        #             msg.reply_image(img_path_name)
        #         if str(r_mes)=='2':
        #             msg.reply('该指令没指定功能')
        # except:
        #     print(msg)
        # 回复消息
        # msg.reply()
        # msg.reply("收到")
    
    
    embed()
  • 相关阅读:
    Kubernetes实战模拟三(wordpress健康检查和服务质量QoS)
    Kubernetes实战模拟二(wordpress高可用)
    Kubernetes实战模拟一(wordpress基础版)
    Rook部署测试Ceph和wordpress实战应用
    kettle作业转换的执行
    BUU BURP COURSE 1
    BUU SQL COURSE 1
    BUU CODE REVIEW 1
    查看FGC
    Pod大量为Evicted被驱逐状态
  • 原文地址:https://www.cnblogs.com/xiaohe520/p/10821661.html
Copyright © 2011-2022 走看看