Python itchat.search_chatrooms() Examples

The following are 5 code examples of itchat.search_chatrooms(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module itchat , or try the search function .
Example #1
Source File: chat_utils.py    From tools_python with Apache License 2.0 6 votes vote down vote up
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) 
Example #2
Source File: wechat.py    From anack with GNU General Public License v3.0 6 votes vote down vote up
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') 
Example #3
Source File: chat_utils.py    From tools_python with Apache License 2.0 5 votes vote down vote up
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) 
Example #4
Source File: WeChatAssistant.py    From WeChatAssistant with Apache License 2.0 5 votes vote down vote up
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) 
Example #5
Source File: itchat_helper.py    From EverydayWechat with MIT License 5 votes vote down vote up
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]