Python itchat 模块,search_chatrooms() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用itchat.search_chatrooms()

项目:taokeCPS    作者:taokeCPS    | 项目源码 | 文件源码
def get_chatroom_name(number):

    owner_name = {
        '0':{'uin':'','name':'CPS','chatroom':'??0?','pid':'pid'},
        }
    number = str(number)
    if number == None: return None
    if number not in owner_name.keys(): return None
    name = owner_name[number]['chatroom']
    pid = owner_name[number]['pid']
    chatrooms = itchat.search_chatrooms(name)
    if not chatrooms: 
        return None
    else:
        try:
            chatrooms = itchat.search_chatrooms(name)[0]
            # chatroomprint(chatrooms)
            if chatrooms:
                return chatrooms['UserName'],pid
        except:
            return None
项目:group-manager    作者:ai-chinade    | 项目源码 | 文件源码
def send_group_invitation(msg) -> None:
    chatroom_id = itchat.search_chatrooms(name=GROUP_NAME)[0].UserName
    itchat.add_member_into_chatroom(chatroomUserName=chatroom_id, useInvitation=True, memberList=[msg.User])
项目:group-manager    作者:ai-chinade    | 项目源码 | 文件源码
def intro_upcomming_member(user: str, intro: str) -> None:
    chatroom_id = itchat.search_chatrooms(name=GROUP_NAME)[0].UserName
    itchat.send_msg(msg=GROUP_INTRO % (user, intro), toUserName=chatroom_id)
项目:wbot    作者:PY-Learning    | 项目源码 | 文件源码
def search_chatrooms(name=None, user_name=None):
        return itchat.search_chatrooms(name, user_name)
项目:auto_chat    作者:SmallPond    | 项目源码 | 文件源码
def get_task(taskList):
    '''
    ????? ???MyChat???  ???????get_tasklist ?????????
    :param taskList:
    :return:
    '''
    contacts = []
    chatrooms_list = []
    contact_list = []
    is_info_correct = True  # ????????
    for task in taskList:
        contact_list = itchat.search_friends(name=task[1])  # ????????
        # ??????????????????
        if len(contact_list) == 0:
            # ????????
            chatrooms_list = itchat.search_chatrooms(name=task[1])
            # ????????????????????
            if len(chatrooms_list) == 0:
                print("???????????.????????? -> ???{0}".format(task[1]))
                # ??????
                is_info_correct = False
                break
            else:
                contacts.append(MyChat(chatrooms_list[0], task[0], task[1],task[2]))

        # ????
        else:
            contacts.append(MyChat(contact_list[0], task[0], task[1], task[2]))

    if is_info_correct is False:
        return False
    else:
        return contacts
项目:wbot    作者:ciknight    | 项目源码 | 文件源码
def text_reply(msg):
    nickName = itchat.search_friends(userName=msg['FromUserName']).get('NickName', 'Unknown')
    logging.info('{}-{} send: {}'.format(nickName, msg['FromUserName'], msg['Content']))
    if msg["FromUserName"] == itchat.get_friends()[0]["UserName"]:
        # dont replay self
        return

    # if invite
    if faq.invite_key in msg['Text'].upper():
        # TODO Modify add_member_into_chatroom
        invite_friend = [{'UserName': msg['FromUserName']}]
        grouproom = itchat.search_chatrooms(name=faq.group_name)
        grouproom = grouproom and grouproom[0] or None
        result = itchat.add_member_into_chatroom(grouproom.get('UserName'),
                invite_friend, useInvitation=True)

        # invite success
        if result['BaseResponse']['Ret'] == 0:
            logging.info('invite user {}-{} successful'.format(nickName, msg['FromUserName']))
        else:
            logging.error('invite user {}-{} failed'.format(nickName, msg['FromUserName']))
            itchat.send(REPLAY_ERROR_TEXT, msg['FromUserName'])
    else:
        # else TuLing replay
        replay_text = tuling.replay_text(msg['Text'],
                msg['FromUserName']) or REPLAY_ERROR_TEXT
        logging.info('tuling replay user {}-{}: {}'.format(nickName, msg['FromUserName'], replay_text))
        itchat.send(replay_text, msg['FromUserName'])

    # TODO can not return Bool
    return
项目:wbot    作者:ciknight    | 项目源码 | 文件源码
def groupchat_reply(msg):
    groupNmae = itchat.search_chatrooms(userName=msg['FromUserName']).get('NickName')
    logging.info('group {}-{}: {}-{}: send {}'.format(
        groupNmae, msg['FromUserName'], msg['ActualNickName'], msg['ActualUserName'], msg['Content']))

    if msg['Text'][0] == interpreter.PY_SYMBLOE:
        replay_text = interpreter.run_py_cmd(msg['Text'][1:])
    elif msg['isAt']:
        replay_text = tuling.replay_text(msg['Text'], msg['ActualNickName']) or REPLAY_ERROR_TEXT
    else:
        replay_text = ''

    if replay_text:
        itchat.send(replay_text, msg['FromUserName'])
项目:wbot    作者:ciknight    | 项目源码 | 文件源码
def group_callback(msg):
    key = '{}:{}'.format(msg['FromUserName'], msg['RefMsgId'])
    groupNmae = itchat.search_chatrooms(userName=msg['FromUserName']).get('NickName')
    try:
        replay_text = '{} recall message is {}'.format(msg['ActualNickName'], itchat.get_cache(key))
        logging.info('group {}: {}: recall message is {}'.format(
            groupNmae, msg['ActualNickName'], replay_text))
    except KeyError as e:
        logging.error('Keyerror {}'.format(str(e)))
        return

    itchat.send(replay_text, msg['FromUserName'])