本文整理匯總了Python中telethon.tl.types.InputPeerChat方法的典型用法代碼示例。如果您正苦於以下問題:Python types.InputPeerChat方法的具體用法?Python types.InputPeerChat怎麽用?Python types.InputPeerChat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類telethon.tl.types
的用法示例。
在下文中一共展示了types.InputPeerChat方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: iter_resume_entities
# 需要導入模塊: from telethon.tl import types [as 別名]
# 或者: from telethon.tl.types import InputPeerChat [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,))
示例2: save_resume_entities
# 需要導入模塊: from telethon.tl import types [as 別名]
# 或者: from telethon.tl.types import InputPeerChat [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)
示例3: enqueue_entities
# 需要導入模塊: from telethon.tl import types [as 別名]
# 或者: from telethon.tl.types import InputPeerChat [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)
示例4: group_has_sedbot
# 需要導入模塊: from telethon.tl import types [as 別名]
# 或者: from telethon.tl.types import InputPeerChat [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)
示例5: group_has_sedbot
# 需要導入模塊: from telethon.tl import types [as 別名]
# 或者: from telethon.tl.types import InputPeerChat [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)
示例6: main
# 需要導入模塊: from telethon.tl import types [as 別名]
# 或者: from telethon.tl.types import InputPeerChat [as 別名]
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)
示例7: unpack_id
# 需要導入模塊: from telethon.tl import types [as 別名]
# 或者: from telethon.tl.types import InputPeerChat [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