當前位置: 首頁>>代碼示例>>Python>>正文


Python itchat.send_msg方法代碼示例

本文整理匯總了Python中itchat.send_msg方法的典型用法代碼示例。如果您正苦於以下問題:Python itchat.send_msg方法的具體用法?Python itchat.send_msg怎麽用?Python itchat.send_msg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在itchat的用法示例。


在下文中一共展示了itchat.send_msg方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: monitorMsg

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send_msg [as 別名]
def monitorMsg(msg):
		if '撤回了一條消息' in msg['Content']:
			recall_msg_id = re.search("\<msgid\>(.*?)\<\/msgid\>", msg['Content']).group(1)
			recall_msg = MSGINFO.get(recall_msg_id)
			print('[Recall]: %s' % recall_msg)
			if len(recall_msg_id) < 11:
				itchat.send_file(FACEPACKAGE, toUserName='filehelper')
			else:
				prompt = '+++' + recall_msg.get('msg_from') + '撤回了一條消息+++\n' \
							'--消息類型:' + recall_msg.get('msg_type') + '\n' \
							'--接收時間:' + recall_msg.get('msg_receive_time') + '\n' \
							'--消息內容:' + recall_msg.get('msg_content')
				if recall_msg['msg_type'] == 'Sharing':
					prompt += '\n鏈接:' + recall_msg.get('msg_link')
				itchat.send_msg(prompt, toUserName='filehelper')
				if recall_msg['msg_type'] == 'Attachment' or recall_msg['msg_type'] == "Video" or recall_msg['msg_type'] == 'Picture' or recall_msg['msg_type'] == 'Recording':
					file = '@fil@%s' % (recall_msg['msg_content'])
					itchat.send(msg=file, toUserName='filehelper')
					os.remove(recall_msg['msg_content'])
				MSGINFO.pop(recall_msg_id) 
開發者ID:CharlesPikachu,項目名稱:WechatHelper,代碼行數:22,代碼來源:antiWithdrawal.py

示例2: group_join_note

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send_msg [as 別名]
def group_join_note(msg):
   global inviter,invitee
   chatroom_name =""
   # 消息來自於哪個群聊
   chatroom_id = msg['FromUserName']
   for c in chatrooms:
       if( c['UserName'] == chatroom_id):
           chatroom_name = c['NickName']        

   if u'邀請' in msg['Content'] or u'invited' in msg['Content']:
       str = msg['Content'];
       pos_start = str.find('"')
       pos_end = str.find('"',pos_start+1)
       inviter = str[pos_start+1:pos_end]
       rpos_start = str.rfind('"')
       rpos_end = str.rfind('"',0, rpos_start)
       invitee = str[(rpos_end+1) : rpos_start]
#       main_logger.info(msg)
   for item in chatrooms:
       if not item['UserName'] == chatroom_id:
           itchat.send_msg(u"%s 群新來一位朋友 %s, 讓我們歡迎他/她吧!" % (chatroom_name,invitee), item['UserName'])
       else:
           itchat.send_msg(u"@%s\u2005歡迎來到本群[微笑],感謝@%s \u2005邀請!方便的話做個簡單自我介紹,再把群名片改為 名字@公司~ 最後看下群公告,謝謝!" % (invitee,inviter), chatroom_id ) 
開發者ID:gnuhpc,項目名稱:All-About-Redis,代碼行數:25,代碼來源:syncgroupchat.py

示例3: SendText2ChatRoom

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send_msg [as 別名]
def SendText2ChatRoom(context, name):
    '''
    @ 發送消息到特定群聊內
    @ 備注:1.確定該群聊存在(可調用PrintChatRoomList查看)
    @      2.切記把群聊加入通訊錄,否則隻能顯示活躍的前幾個群聊
    '''
    itchat.get_chatrooms(update=True)
    iRoom = itchat.search_chatrooms(name)
    for room in iRoom:
        if room['NickName'] == name:
            userName = room['UserName']
            break
    try:
        itchat.send_msg(context, userName)
    except:
        print('warning: no this chatrooms') 
開發者ID:YinChao126,項目名稱:anack,代碼行數:18,代碼來源:wechat.py

示例4: information

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send_msg [as 別名]
def information(msg):
    # 這裏如果這裏的msg['Content']中包含消息撤回和id,就執行下麵的語句
    if '撤回了一條消息' in msg['Content']:
        # 在返回的content查找撤回的消息的id
        old_msg_id = re.search("\<msgid\>(.*?)\<\/msgid\>", msg['Content']).group(1)
        # 獲取到消息原文
        old_msg = msg_information.get(old_msg_id)
        # 如果發送的是表情包
        if len(old_msg_id)<11:
            # 發送撤回的提示給文件助手
            itchat.send_file(face_bug,toUserName='filehelper')
        # 把暫時存儲的信息可以刪除掉,也可以選擇不刪除
        # os.remove(face_bug)
        else:
            msg_body = old_msg.get('group_name') + old_msg.get('msg_from') +"\n" + old_msg.get('msg_time_rec') \
                + "撤回了:" + "\n" + r"" + old_msg.get('msg_content')
            
            # 如果是分享的文件被撤回了,那麽就將分享的url加在msg_body中發送給文件助手
            if old_msg['msg_type'] == "Sharing":
                msg_body += "\n鏈接是:" + old_msg.get('msg_share_url')
            print msg_body
            # 將撤回消息發給文件助手
            itchat.send_msg(msg_body, toUserName='filehelper')
            
            # 有文件的話也要將文件發送回去
            if old_msg["msg_type"] == "Picture" \
                or old_msg["msg_type"] == "Recording" \
                or old_msg["msg_type"] == "Video" \
                or old_msg["msg_type"] == "Attachment":
                file = '@fil@%s' % (old_msg['msg_content'])
                itchat.send(msg=file, toUserName='filehelper')
                # 把暫時存儲的信息可以刪除掉,也可以選擇不刪除
                os.remove(old_msg['msg_content'])
            # 刪除字典舊消息
    msg_information.pop(old_msg_id) 
開發者ID:lb2281075105,項目名稱:Python-Spider,代碼行數:37,代碼來源:28 PythonCheHui.py

示例5: send_text

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send_msg [as 別名]
def send_text(text):
    #send text msgs to 'filehelper'
    #給文件助手發送文本信息
    try:
        itchat.send_msg(msg=text,toUserName='filehelper')
        return
    except (ConnectionError,NotImplementedError,KeyError):
        traceback.print_exc()
        print('\nConection error,failed to send the message!\n')
        return
    else:
        return 
開發者ID:QuantumLiu,項目名稱:Neural-Headline-Generator-CN,代碼行數:14,代碼來源:wechat_utils.py

示例6: t_send

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send_msg [as 別名]
def t_send(self,msg,toUserName='filehelper'):
        try:
            itchat.send_msg(msg=msg,toUserName=toUserName)
            return
        except (ConnectionError,NotImplementedError,KeyError):
            traceback.print_exc()
            print('\nConection error,failed to send the message!\n')
            return
        else:
            return 
開發者ID:QuantumLiu,項目名稱:Neural-Headline-Generator-CN,代碼行數:12,代碼來源:wechat_utils.py

示例7: get_note

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send_msg [as 別名]
def get_note(msg):
    msg['_id'] = msg['MsgId']
    db.msg_history.insert(msg)
    if u'邀請' in msg['Content'] or u'invited' in msg['Content']:
        pos1 = msg['Content'].rfind('"')
        pos2 = msg['Content'].rfind('"', 0, pos1)
        nick_name = msg['Content'][(pos2+1): pos1]
        itchat.send_msg(u'@%s 歡迎來到本群,我是群主的機器人助手[微笑]' % nick_name, msg['FromUserName']) 
開發者ID:soulmachine,項目名稱:weixinqunzhushou,代碼行數:10,代碼來源:main.py

示例8: text_reply

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send_msg [as 別名]
def text_reply(msg):
    itchat.send_msg(u'Hi,我是一個智能機器人,能幫助您自動化的管理微信群,把我拉入群,我就可以開始為你工作啦', msg['FromUserName']) 
開發者ID:soulmachine,項目名稱:weixinqunzhushou,代碼行數:4,代碼來源:main.py

示例9: add_friend

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send_msg [as 別名]
def add_friend(msg):
    itchat.add_friend(**msg['Text'])  # 該操作會自動將新好友的消息錄入,不需要重載通訊錄
    user_info = itchat.search_friends(userName=msg['RecommendInfo']['UserName'])
    itchat.send_msg(u'Hi,我是一個智能機器人,能幫助您自動化的管理微信群,把我拉入群,我就可以開始為你工作啦', user_info['UserName'])
    upsert_user(user_info) 
開發者ID:soulmachine,項目名稱:weixinqunzhushou,代碼行數:7,代碼來源:main.py


注:本文中的itchat.send_msg方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。