本文整理匯總了Python中itchat.content方法的典型用法代碼示例。如果您正苦於以下問題:Python itchat.content方法的具體用法?Python itchat.content怎麽用?Python itchat.content使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類itchat
的用法示例。
在下文中一共展示了itchat.content方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle_message
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [as 別名]
def handle_message(msg, content):
global wxHandle, wxRooms, myUid
room = msg["FromUserName"]
nick = msg["ActualNickName"]
if wxRooms.get(room) is None:
logger.info("Not in rooms to forward!!!")
return
if msg["ActualUserName"] == myUid:
logger.info("My own message:)")
return
date, time = get_now_date_time()
fish_msg = Message(
ChannelType.Wechat, nick, wxRooms[room], content,
mtype=MessageType.Text, date=date, time=time)
wxHandle.send_to_bus(wxHandle,fish_msg)
示例2: add_friends_msg
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [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)
示例3: note_msg
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [as 別名]
def note_msg(msg):
print_msg(get_whole_msg(msg))
content = HTMLParser().unescape(msg['Content'])
try:
content_tree = ETree.fromstring(content)
except Exception:
# invent/remove to chatroom
return
if content_tree is None:
return
revoked = content_tree.find('revokemsg')
if revoked is None:
return
old_msg_id = revoked.find('msgid').text
old_msg = msg_store.get(old_msg_id)
if old_msg is None:
return
msg_send = get_whole_msg(old_msg, download=True)
for m in msg_send:
bot.send(m, toUserName='filehelper')
clear_timeouted_message()
示例4: gpu_status
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [as 別名]
def gpu_status(self,av_type_list):
for t in av_type_list:
cmd='nvidia-smi -q --display='+t
#print('\nCMD:',cmd,'\n')
r=os.popen(cmd)
info=r.readlines()
r.close()
content = " ".join(info)
#print('\ncontent:',content,'\n')
index=content.find('Attached GPUs')
s=content[index:].replace(' ','').rstrip('\n')
self.t_send(s, toUserName='filehelper')
time.sleep(.5)
#th.exit()
#==============================================================================
#
#==============================================================================
示例5: on_text_message
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [as 別名]
def on_text_message(msg):
log_message(TEXT, msg)
content = msg["Content"]
handle_message(msg, content)
示例6: on_map_message
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [as 別名]
def on_map_message(msg):
log_message(MAP, msg)
content = "(Map message received)"
handle_message(msg, content)
示例7: on_card_message
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [as 別名]
def on_card_message(msg):
log_message(CARD, msg)
content = "(Card message received)"
handle_message(msg, content)
示例8: on_note_message
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [as 別名]
def on_note_message(msg):
log_message(NOTE, msg)
content = "(Note message received)"
handle_message(msg, content)
示例9: on_recording_message
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [as 別名]
def on_recording_message(msg):
log_message(RECORDING, msg)
content = "(Recording message received)"
handle_message(msg, content)
示例10: on_voice_message
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [as 別名]
def on_voice_message(msg):
log_message(VOICE, msg)
content = "(Voice message received)"
handle_message(msg, content)
示例11: on_video_message
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [as 別名]
def on_video_message(msg):
log_message(VIDEO, msg)
content = "(Video message received)"
handle_message(msg, content)
示例12: send_msg
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [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)
示例13: exit_callback
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [as 別名]
def exit_callback():
"""
微信已經登出
"""
time_ = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
online_time = get_online_time()
title = '您服務器上的微信「{}」已離線'.format(wechat_nick_name)
content = '離線時間:{} \n一共在線時長:{} \n離線原因:未知'.format(time_, online_time)
send_mail(title, content)
set_note(title + content, True)
stop_scheduler()
stop_system()
示例14: send_mail
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [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))
示例15: information
# 需要導入模塊: import itchat [as 別名]
# 或者: from itchat import content [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)