当前位置: 首页>>代码示例>>Python>>正文


Python itchat.get_chatrooms方法代码示例

本文整理汇总了Python中itchat.get_chatrooms方法的典型用法代码示例。如果您正苦于以下问题:Python itchat.get_chatrooms方法的具体用法?Python itchat.get_chatrooms怎么用?Python itchat.get_chatrooms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在itchat的用法示例。


在下文中一共展示了itchat.get_chatrooms方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SendText2ChatRoom

# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import get_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') 
开发者ID:YinChao126,项目名称:anack,代码行数:18,代码来源:wechat.py

示例2: __init__

# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import get_chatrooms [as 别名]
def __init__(self, roomNicks):
        global wxRooms, myUid
        itchat.auto_login(hotReload=True, enableCmdQR=2, exitCallback=wechatExit)
        all_rooms = itchat.get_chatrooms(update=True)
        for r in all_rooms:
            if r['NickName'] in roomNicks:
                wxRooms[r['UserName']] = r['NickName']
                wxRoomNicks[r['NickName']] = r['UserName']
                logger.info('Room {} found.'.format(r["NickName"]))
            else:
                logger.info('{}: {}'.format(r['UserName'], r['NickName']))

        friends = itchat.get_friends()
        myUid = friends[0]["UserName"] 
开发者ID:tuna,项目名称:fishroom,代码行数:16,代码来源:wechat.py

示例3: send_to_group_chat

# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import get_chatrooms [as 别名]
def send_to_group_chat(target_group_chat_name, file_names):
    """
    群聊
    :param target_group_chat_name:
    :param file_name:
    :return:
    """
    rooms = itchat.get_chatrooms(update=True)

    # 目标群聊对象
    target_room = None
    for room in rooms:
        group_chat_name = room.get('NickName')
        if target_group_chat_name == group_chat_name:
            target_room = room
            break

    if target_room:
        if isinstance(file_names, list):
            for file_name in file_names:
                target_room.send_image(file_name)
        else:
            target_room.send_image(file_names)

        print('发送完毕!')
    else:
        print('抱歉,不存在这个群聊') 
开发者ID:xingag,项目名称:spider_python,代码行数:29,代码来源:chat_utils.py

示例4: wechat_login

# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import get_chatrooms [as 别名]
def wechat_login(self):
        try:
            itchat.auto_login(hotReload=True)
        except:
            q.put("您的微信未能正确登陆,可能是注册时间太短,微信禁止登陆网页版微信")
        chatroomsList =itchat.get_chatrooms()
        for chatroom in chatroomsList:
            group_list.append(chatroom["NickName"])
        js.writejson('groupdata.json',group_list)
        self.ShowGroup()
        self.ShowFriends()
        itchat.run() 
开发者ID:LyuDun,项目名称:WeChatAssistant,代码行数:14,代码来源:WeChatAssistant.py

示例5: PrintChatRoomList

# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import get_chatrooms [as 别名]
def PrintChatRoomList():
    '''
    @ 显示当前可见的群聊名
    '''
    rooms = itchat.get_chatrooms(update=True)
    for s in rooms:
        print(s['NickName']) 
开发者ID:YinChao126,项目名称:anack,代码行数:9,代码来源:wechat.py

示例6: init_data

# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import get_chatrooms [as 别名]
def init_data():
    """ 初始化微信所需数据 """
    set_system_notice('登录成功')
    itchat.get_friends(update=True)  # 更新好友数据。
    itchat.get_chatrooms(update=True)  # 更新群聊数据。

    init_wechat_config()  # 初始化所有配置内容

    # 提醒内容不为空时,启动定时任务
    alarm_dict = config.get('alarm_info').get('alarm_dict')
    if alarm_dict:
        init_alarm(alarm_dict)  # 初始化定时任务

    print('初始化完成,开始正常工作。') 
开发者ID:sfyc23,项目名称:EverydayWechat,代码行数:16,代码来源:main.py

示例7: get_group

# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import get_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] 
开发者ID:sfyc23,项目名称:EverydayWechat,代码行数:14,代码来源:itchat_helper.py

示例8: __init__

# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import get_chatrooms [as 别名]
def __init__(self):
        self.user_count = 0
        self.selfUser = None
        self.user_dict = {}
        self.current_user = None    # 当前正在聊天的用户
        self.room_dept = -1          # 用于记录好友和群聊的分界点id
        self.cmd = Cmd(self)        # 初始化一个命令管理器, 此命令管理器管理所有的命令

        itchat.auto_login(hotReload=True,enableCmdQR = 2,exitCallback=itchat.logout) #登录并记录登录状态
        threading.Thread(target=itchat.run).start()             # 线程启动run实现
        self.loadUserList(itchat.get_friends(),'f')             # 加载好友
        self.loadUserList(itchat.get_chatrooms(),'r')           # 加载群聊 
开发者ID:TheThreeDog,项目名称:TouchFish,代码行数:14,代码来源:User.py

示例9: reloadUserList

# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import get_chatrooms [as 别名]
def reloadUserList(self):
        '''
        重载好友列表,如果程序运行期间添加了好友或群聊,通过此命令刷新
        '''
        self.selfUser = None
        self.current_user = None
        self.user_dict = {}
        self.user_count = 0
        self.loadUserList(itchat.get_friends(),'f')             # 加载好友
        self.loadUserList(itchat.get_chatrooms(),'r')           # 加载群聊 
开发者ID:TheThreeDog,项目名称:TouchFish,代码行数:12,代码来源:User.py

示例10: start

# 需要导入模块: import itchat [as 别名]
# 或者: from itchat import get_chatrooms [as 别名]
def start():
    @itchat.msg_register([TEXT, MAP, CARD, NOTE, SHARING,PICTURE, RECORDING, ATTACHMENT, VIDEO,FRIENDS])
    def recive_contact_msg(msg):
        contact_name = get_contact_name(msg)
        try:
            wechatMain.recive_message(msg,contact_name)
            notify('TWchat',"new message from: "+contact_name)
        except AttributeError:
            pass
    
    @itchat.msg_register(TEXT, isGroupChat=True)
    def recive_group_msg(msg):
        group_name = get_group_name(msg)
        try:
            wechatMain.recive_message(msg,group_name)
            notify('TWchat',"new message from: "+group_name)
        except AttributeError:
            pass
        return   

    def on_contact_item_click(button,info):
        wechatMain.chatListBox.addNewChat(info[0],info[1])
        wechatMain.set_current_chat(info[0],info[1])
        wechatMain.chatListBox.show_chat()
        return 
    def on_chat_item_click(button,info):
        wechatMain.set_current_chat(info[0],info[1])
        return
    palette = [
        ('left', 'black', 'light gray'),
        ('right', 'black', 'dark cyan'),
        ('button', 'dark green','black'),
        ('mybg', 'black','dark cyan'),
        ('tobg', 'dark blue','light gray'),
        ('edit', 'dark cyan','black'),
        ('bg', 'dark green', 'black'),]
    print ('''
 _____  _    _  _____  _   _   ___   _____ 
|_   _|| |  | |/  __ \| | | | / _ \ |_   _|
  | |  | |  | || /  \/| |_| |/ /_\ \  | |  
  | |  | |/\| || |    |  _  ||  _  |  | |  
  | |  \  /\  /| \__/\| | | || | | |  | |  
  \_/   \/  \/  \____/\_| |_/\_| |_/  \_/  
            ''')

    wechatMain = wegui.WechatMain(palette)
    itchat.auto_login(enableCmdQR=2,hotReload=True)
    itchat.run(blockThread=False)
    userInfo =itchat.web_init()['User']
    owner_id = userInfo['UserName']
    owner_name = userInfo['NickName']
    contactlist= itchat.get_friends(update=True)
    chatlist = itchat.get_chatrooms()
    #contactlist = sorted(contactlist,key=lambda x:(x['RemarkPYInitial'],x['PYInitial']))
    contactlist = sorted(contactlist,key=lambda x:(lazy_pinyin(get_name(x))))
    wechatMain.initUserInfo(owner_id,owner_name,on_contact_item_click,on_chat_item_click,contactlist,chatlist)
    wechatMain.bind_itchat(itchat)
    wechatMain.createLoop() 
开发者ID:huanglizhuo,项目名称:TWchat,代码行数:60,代码来源:__init__.py


注:本文中的itchat.get_chatrooms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。