本文整理汇总了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)