Python telethon.tl.types.InputPeerChat() Examples

The following are 7 code examples of telethon.tl.types.InputPeerChat(). 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 telethon.tl.types , or try the search function .
Example #1
Source File: dumper.py    From telegram-export with Mozilla Public License 2.0 6 votes vote down vote up
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,)) 
Example #2
Source File: dumper.py    From telegram-export with Mozilla Public License 2.0 6 votes vote down vote up
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) 
Example #3
Source File: downloader.py    From telegram-export with Mozilla Public License 2.0 5 votes vote down vote up
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) 
Example #4
Source File: sed.py    From BotHub with Apache License 2.0 5 votes vote down vote up
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) 
Example #5
Source File: sed.py    From X-tra-Telegram with Apache License 2.0 5 votes vote down vote up
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) 
Example #6
Source File: Ping_server.py    From Awesome-Python-Scripts with MIT License 5 votes vote down vote up
def main():
    j
    api_id = #####
    api_hash = '######################'

# Your Account Sid and Auth Token from twilio.com/console
    account_sid = '###############'
    auth_token = '################'
    clients = Client(account_sid, auth_token)


#telegram_Side
    client = TelegramClient('session_name', api_id, api_hash)
    client.start()
#print(client.get_me().stringify())
#updates = client(ImportChatInviteRequest('FDVzKw8BPHTp2wyhwNqT2Q'))
    siteList=[site_list]
    for i in siteList:
        print(i)
        r = requests.head(i)
        if r.status_code == 200:
            message=i +"  returned  200"
            chat = InputPeerChat(chatID)
            client.send_message(chat, message)
            sms= clients.messages.create(to="#####",from_="##########",body="the  "+i+"   is not responding now  ")
            call = clients.calls.create(url='http://demo.twilio.com/docs/voice.xml',to='############',from_='#############')
            print(call.sid)
        else:
            chat = InputPeerChat(chatID)
            message="oops  " + i + "   not available at the moment"
            client.send_message(chat, message) 
Example #7
Source File: util.py    From tgfilestream with GNU Affero General Public License v3.0 5 votes vote down vote up
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