本文整理汇总了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)
示例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)
示例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')
示例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')
示例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
示例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
示例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)
示例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)
示例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')
示例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)
示例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)
示例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
示例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) # 简单日志
示例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))
示例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)