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


Python types.InputPeerChannel方法代码示例

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


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

示例1: iter_resume_entities

# 需要导入模块: from telethon.tl import types [as 别名]
# 或者: from telethon.tl.types import InputPeerChannel [as 别名]
def iter_resume_entities(self, context_id):
        """
        Returns an iterator over the entities that need resuming for the
        given context_id. Note that the entities are *removed* once the
        iterator is consumed completely.
        """
        c = self.conn.execute("SELECT ID, AccessHash FROM ResumeEntity "
                              "WHERE ContextID = ?", (context_id,))
        row = c.fetchone()
        while row:
            kind = resolve_id(row[0])[1]
            if kind == types.PeerUser:
                yield types.InputPeerUser(row[0], row[1])
            elif kind == types.PeerChat:
                yield types.InputPeerChat(row[0])
            elif kind == types.PeerChannel:
                yield types.InputPeerChannel(row[0], row[1])
            row = c.fetchone()

        c.execute("DELETE FROM ResumeEntity WHERE ContextID = ?",
                  (context_id,)) 
开发者ID:expectocode,项目名称:telegram-export,代码行数:23,代码来源:dumper.py

示例2: save_resume_entities

# 需要导入模块: from telethon.tl import types [as 别名]
# 或者: from telethon.tl.types import InputPeerChannel [as 别名]
def save_resume_entities(self, context_id, entities):
        """
        Saves the given entities for resuming at a later point.
        """
        rows = []
        for ent in entities:
            ent = get_input_peer(ent)
            if isinstance(ent, types.InputPeerUser):
                rows.append((context_id, ent.user_id, ent.access_hash))
            elif isinstance(ent, types.InputPeerChat):
                rows.append((context_id, ent.chat_id, None))
            elif isinstance(ent, types.InputPeerChannel):
                rows.append((context_id, ent.channel_id, ent.access_hash))
        c = self.conn.cursor()
        c.executemany("INSERT OR REPLACE INTO ResumeEntity "
                      "VALUES (?,?,?)", rows) 
开发者ID:expectocode,项目名称:telegram-export,代码行数:18,代码来源:dumper.py

示例3: enqueue_entities

# 需要导入模块: from telethon.tl import types [as 别名]
# 或者: from telethon.tl.types import InputPeerChannel [as 别名]
def enqueue_entities(self, entities):
        """
        Enqueues the given iterable of entities to be dumped later by a
        different coroutine. These in turn might enqueue profile photos.
        """
        for entity in entities:
            eid = utils.get_peer_id(entity)
            self._displays[eid] = utils.get_display_name(entity)
            if isinstance(entity, types.User):
                if entity.deleted or entity.min:
                    continue  # Empty name would cause IntegrityError
            elif isinstance(entity, types.Channel):
                if entity.left:
                    continue  # Getting full info triggers ChannelPrivateError
            elif not isinstance(entity, (types.Chat,
                                         types.InputPeerUser,
                                         types.InputPeerChat,
                                         types.InputPeerChannel)):
                # Drop UserEmpty, ChatEmpty, ChatForbidden and ChannelForbidden
                continue

            if eid in self._checked_entity_ids:
                continue
            else:
                self._checked_entity_ids.add(eid)
                if isinstance(entity, (types.User, types.InputPeerUser)):
                    self._user_queue.put_nowait(entity)
                else:
                    self._chat_queue.put_nowait(entity) 
开发者ID:expectocode,项目名称:telegram-export,代码行数:31,代码来源:downloader.py

示例4: on_mentioned

# 需要导入模块: from telethon.tl import types [as 别名]
# 或者: from telethon.tl.types import InputPeerChannel [as 别名]
def on_mentioned(event):
    if not event.message.from_id:  # Channel messages don't have a from_id
        return
    if event.from_id not in blocked_user_ids:
        return

    peer = await borg.get_input_entity(event.chat_id)
    if isinstance(peer, InputPeerChannel):
        o = tlf.channels.ReadMessageContentsRequest(peer, [event.message.id])
    else:
        o = tlf.messages.ReadMessageContentsRequest([event.message.id])
    await borg(o) 
开发者ID:mkaraniya,项目名称:BotHub,代码行数:14,代码来源:superblock.py

示例5: group_has_sedbot

# 需要导入模块: from telethon.tl import types [as 别名]
# 或者: from telethon.tl.types import InputPeerChannel [as 别名]
def group_has_sedbot(group):
    if isinstance(group, types.InputPeerChannel):
        full = await borg(functions.channels.GetFullChannelRequest(group))
    elif isinstance(group, types.InputPeerChat):
        full = await borg(functions.messages.GetFullChatRequest(group.chat_id))
    else:
        return False

    return any(KNOWN_RE_BOTS.match(x.username or '') for x in full.users) 
开发者ID:mkaraniya,项目名称:BotHub,代码行数:11,代码来源:sed.py

示例6: group_has_sedbot

# 需要导入模块: from telethon.tl import types [as 别名]
# 或者: from telethon.tl.types import InputPeerChannel [as 别名]
def group_has_sedbot(group):
    if isinstance(group, types.InputPeerChannel):
        full = await bot(functions.channels.GetFullChannelRequest(group))
    elif isinstance(group, types.InputPeerChat):
        full = await bot(functions.messages.GetFullChatRequest(group.chat_id))
    else:
        return False

    return any(KNOWN_RE_BOTS.match(x.username or '') for x in full.users) 
开发者ID:Dark-Princ3,项目名称:X-tra-Telegram,代码行数:11,代码来源:sed.py

示例7: unpack_id

# 需要导入模块: from telethon.tl import types [as 别名]
# 或者: from telethon.tl.types import InputPeerChannel [as 别名]
def unpack_id(file_id: int) -> Tuple[TypeInputPeer, int]:
    is_group = file_id & group_bit
    is_channel = file_id & channel_bit
    chat_id = file_id >> chat_id_offset & pack_bit_mask
    msg_id = file_id >> msg_id_offset & pack_bit_mask
    if is_channel:
        peer = InputPeerChannel(channel_id=chat_id, access_hash=0)
    elif is_group:
        peer = InputPeerChat(chat_id=chat_id)
    else:
        peer = InputPeerUser(user_id=chat_id, access_hash=0)
    return peer, msg_id 
开发者ID:tulir,项目名称:tgfilestream,代码行数:14,代码来源:util.py


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