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


Python itchat.send方法代碼示例

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


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

示例1: add_friends_msg

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def add_friends_msg(msg):
    """ 監聽添加好友請求 為了自動同意好友請求"""

    if not IS_AUTO_ADD_FRIEND:  # 如果是已關閉添加好友功能,則直接返回
        return
        # print(json.dumps(msg, ensure_ascii=False))

    userid = msg['RecommendInfo']['UserName']
    nickname = msg['RecommendInfo']['NickName']
    # 黑名單用戶不能加群
    if userid in black_uuid_list:
        set_note('黑名單用戶『{}』不能通過好友請求'.format(nickname))
        return

    content = msg['RecommendInfo']['Content']  # 獲取驗證消息
    if add_friend_compile.findall(content):
        time.sleep(random.randint(1, 2))  # 隨機休眠(1~3)秒,用於防檢測機器人
        itchat.add_friend(**msg['Text'])  # 同意加好友請求
        time.sleep(random.randint(1, 2))
        itchat.send(note_first_meet_text, userid)  # 給剛交的朋友發送歡迎語句
        note = '已添加好友:{}'.format(nickname)
        set_note(note)
    else:
        note = '添加好友失敗:用戶「{}」 發來的驗證消息「{}」。'.format(nickname, content)
        set_note(note) 
開發者ID:sfyc23,項目名稱:WechatAddGroupHelper,代碼行數:27,代碼來源:WechatAddGroupHelper.py

示例2: monitorMsg

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [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

示例3: get_push

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def get_push(all_list = []):
    stock_symbol_list, price_low_list, price_high_list = handle(all_list)
    localtime = datetime.datetime.now()    # 獲取當前時間
    now = localtime.strftime('%H:%M:%S')
    data = ts.get_realtime_quotes(stock_symbol_list)    # 獲取股票信息
    price_list = data['price']
    itchat.send(now, toUserName='filehelper')
    print(now)

    for i in range(int(len(all_list) / 3)):
        content = stock_symbol_list[i] + ' 當前價格為 ' + price_list[i] + '\n'
        if float(price_list[i]) <=  float(price_low_list[i]):
            itchat.send(content + '低於最低預警價格', toUserName='filehelper')
            print(content + '低於最低預警價格')
        elif float(price_list[i]) >=  float(price_high_list[i]):
            itchat.send(content + '高於最高預警價格', toUserName='filehelper')
            print(content + '高於最高預警價格')
        else:
            itchat.send(content + '價格正常', toUserName='filehelper')
            print(content + '價格正常')
    itchat.send('***** end *****', toUserName='filehelper')
    print('***** end *****\n') 
開發者ID:onshek,項目名稱:Stock_WeChat,代碼行數:24,代碼來源:sw.py

示例4: get_remind

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def get_remind(all_list = []):
    stock_symbol_list, price_low_list, price_high_list = handle(all_list)
    localtime = datetime.datetime.now()    # 獲取當前時間
    now = localtime.strftime('%H:%M:%S')
    data = ts.get_realtime_quotes(stock_symbol_list)    # 獲取股票信息
    price_list = data['price']
    itchat.send(now, toUserName='filehelper')
    print(now)

    for i in range(int(len(all_list) / 3)):
        content = stock_symbol_list[i] + ' 當前價格為 ' + price_list[i] + '\n'
        if float(price_list[i]) <=  float(price_low_list[i]):
            itchat.send(content + '低於最低預警價格', toUserName='filehelper')
            print(content + '低於最低預警價格')
        elif float(price_list[i]) >=  float(price_high_list[i]):
            itchat.send(content + '高於最高預警價格', toUserName='filehelper')
            print(content + '高於最高預警價格')
        else:
            print(content + '價格正常')
    itchat.send('***** end *****', toUserName='filehelper')
    print('***** end *****\n') 
開發者ID:onshek,項目名稱:Stock_WeChat,代碼行數:23,代碼來源:sw.py

示例5: push

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def push(all_list = []):
    itchat.send('Stock_WeChat 已開始執行!', toUserName='filehelper')
    print('Stock_WeChat 已開始執行!')
    while True:
        try:
            get_push(all_list)
            time.sleep(2.9)
        except KeyboardInterrupt:
            itchat.send('Stock_WeChat 已執行完畢!\n'
                '更多有意思的小玩意,請戳---->\n'
                '[https://github.com/ipreacher/tricks]', 
                toUserName='filehelper')
            print('\n'
                'Stock_WeChat 已執行完畢!\n'
                '更多有意思的小玩意,請戳---->\n'
                '[https://github.com/ipreacher/tricks]')
            break 
開發者ID:onshek,項目名稱:Stock_WeChat,代碼行數:19,代碼來源:sw.py

示例6: remind

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def remind(all_list = []):
    itchat.send('Stock_WeChat 已開始執行!', toUserName='filehelper')
    print('Stock_WeChat 已開始執行!')
    while True:
        try:
            get_remind(all_list)
            time.sleep(2.9)
        except KeyboardInterrupt:
            itchat.send('Stock_WeChat 已執行完畢!\n'
                '更多有意思的小玩意,請戳---->\n'
                '[https://github.com/ipreacher/tricks]', 
                toUserName='filehelper')
            print('\n'
                'Stock_WeChat 已執行完畢!\n'
                '更多有意思的小玩意,請戳---->\n'
                '[https://github.com/ipreacher/tricks]')
            break 
開發者ID:onshek,項目名稱:Stock_WeChat,代碼行數:19,代碼來源:sw.py

示例7: send_photo

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def send_photo(self, target, photo_data, sender=None):
        ft = imghdr.what('', photo_data)
        if ft is None:
            return
        filename = "image." + ft
        data_io = io.BytesIO(photo_data)
        roomid = wxRoomNicks[target]
        if sender is not None:
            itchat.send(msg="{} sent a photo...".format(sender), toUserName=roomid)
        itchat.send_image(fileDir=filename, toUserName=roomid, file_=data_io) 
開發者ID:tuna,項目名稱:fishroom,代碼行數:12,代碼來源:wechat.py

示例8: send_msg

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def send_msg(self, target, content, sender=None, first=False, **kwargs):
        logger.info("Sending message to " + target)
        roomid = wxRoomNicks[target]
        if sender is not None:
            itchat.send(msg="[{}] {}".format(sender,content), toUserName=roomid)
        else:
            itchat.send(content, toUserName=roomid) 
開發者ID:tuna,項目名稱:fishroom,代碼行數:9,代碼來源:wechat.py

示例9: send_word_helper

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def send_word_helper(content):
    """
    向文件傳輸助手發送文字
    :param content:
    :return:
    """
    itchat.send(content, toUserName='filehelper') 
開發者ID:xingag,項目名稱:tools_python,代碼行數:9,代碼來源:chat_utils.py

示例10: send_word_to_person

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def send_word_to_person(name, content):
    """
    發送消息給某個人
    :param name:
    :param content:
    :return:
    """
    users = itchat.search_friends(name)
    userName = users[0]['UserName']
    itchat.send(content, toUserName=userName) 
開發者ID:xingag,項目名稱:tools_python,代碼行數:12,代碼來源:chat_utils.py

示例11: send_messages_in_queue

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def send_messages_in_queue(self):
        while(True):
            (username, message) = self.send_msg_queue.get()
            itchat.send(message, toUserName = username)

            time.sleep(0.5) 
開發者ID:LouYu2015,項目名稱:WerewolvesWechatBot,代碼行數:8,代碼來源:wechat.py

示例12: group_note_msg

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def group_note_msg(msg):
    """ 群通知處理 """
    # print('NOTE', json.dumps(msg, ensure_ascii=False))
    group_uuid = msg['FromUserName']  # 獲取當前群的 uuid
    if group_uuid in group_infos_dict:  # 判斷是否為同一個群組
        text = msg['Text']  # 通知的內容
        invite_names = invite_compile.findall(text)  # 判斷是否是加入了新用戶
        if invite_names:  # 用於邀請
            invite_name = invite_names[0]  # 加入者的昵稱
            time.sleep(random.randint(1, 2))
            if note_invite_welcome:
                # 艾特用戶,不過接口已經不支持艾特用戶了
                note = note_invite_welcome.format(atname=invite_name)
                itchat.send(note, group_uuid)  # 向群裏發送歡迎語句
            update_group_info(group_uuid, True)  # 更新群信息
            return
        remove_nicknames = note_remove_complie.findall(text)
        if remove_nicknames:
            remove_nickname = remove_nicknames[0]
            for ml in msg['User']['MemberList']:
                username = ml['UserName']
                if remove_nickname == ml['NickName']:
                    black_uuid_list.append(username)  # 將用戶加入黑名單
                    break
            update_group_info(group_uuid, True)  # 更新群信息
            return 
開發者ID:sfyc23,項目名稱:WechatAddGroupHelper,代碼行數:28,代碼來源:WechatAddGroupHelper.py

示例13: set_note

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def set_note(note, onle_log=False):
    """
    發送日誌
    :param note: 日誌內容
    :param onle_log: Bool 是否隻輸出日誌,不發送到文件助手中
    :return:
    """
    if not onle_log:
        itchat.send(note, 'filehelper')
    print(note)  # 簡單日誌 
開發者ID:sfyc23,項目名稱:WechatAddGroupHelper,代碼行數:12,代碼來源:WechatAddGroupHelper.py

示例14: send_mail

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def send_mail(title, content):
    """
    發送郵件
    :param title: 標題
    :param content: 內容
    """
    if not IS_OPEN_EMAIL_NOTICE:
        return
    try:
        yag.send(to_emails, title, content)
        print('已發送郵件:{}'.format(title))
    except Exception as exception:
        print(str(exception)) 
開發者ID:sfyc23,項目名稱:WechatAddGroupHelper,代碼行數:15,代碼來源:WechatAddGroupHelper.py

示例15: text_reply

# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import send [as 別名]
def text_reply(msg):
    print(msg)
    if (Listen_Flag == True):
        if msg['Type'] == 'Text':
            reply_content = msg['Text']
            for key, value in keyword_dict.items():
                if re.search(key, reply_content):
                    itchat.send(value, toUserName=msg['FromUserName'])
                    str = '(%s) -> %s\n' % (
                        msg.User['NickName'], reply_content)
                    q.put(str) 
開發者ID:LyuDun,項目名稱:WeChatAssistant,代碼行數:13,代碼來源:WeChatAssistant.py


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