本文整理汇总了Python中itchat.search_chatrooms方法的典型用法代码示例。如果您正苦于以下问题:Python itchat.search_chatrooms方法的具体用法?Python itchat.search_chatrooms怎么用?Python itchat.search_chatrooms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类itchat
的用法示例。
在下文中一共展示了itchat.search_chatrooms方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SendText2ChatRoom
# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import search_chatrooms [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')
示例2: send_word_to_group
# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import search_chatrooms [as 别名]
def send_word_to_group(group_name, word):
"""
群聊中发送文字
:param group_name:
:param content:
:return:
"""
# 获取所有群聊
# 显示所有的群聊信息,默认是返回保存到通讯录中的群聊
itchat.dump_login_status()
target_rooms = itchat.search_chatrooms(name=group_name)
if target_rooms and len(target_rooms) > 0:
target_rooms[0].send_msg(word)
else:
print('【发送文字】抱歉,不存在这个群聊:%s' % group_name)
示例3: send_file_to_group
# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import search_chatrooms [as 别名]
def send_file_to_group(group_name, file_name):
"""
发送文件到群聊
:param group_name:
:param file:
:return:
"""
itchat.dump_login_status()
target_rooms = itchat.search_chatrooms(name=group_name)
if target_rooms and len(target_rooms) > 0:
target_rooms[0].send_file(file_name)
else:
print('【发送文件】抱歉,不存在这个群聊:%s' % group_name)
示例4: SendMessage
# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import search_chatrooms [as 别名]
def SendMessage(self):
for i, group in enumerate(group_list):
if(self.c_Listname.selection_includes(i) == True):
groups = itchat.search_chatrooms(name=group)
groupname = groups[0]['UserName']
str = self.c_input.get(1.0, END)
self.c_input.delete(1.0, END)
itchat.send(str, toUserName=groupname)
示例5: get_group
# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import search_chatrooms [as 别名]
def get_group(group_name, update=False):
"""
根据群组名获取群组数据
:param group_name:str, 群组名
:param update: bool 强制更新群组数据
:return: obj 单个群组信息
"""
if update: itchat.get_chatrooms(update=True)
if not group_name: return None
groups = itchat.search_chatrooms(name=group_name)
if not groups: return None
return groups[0]