本文整理汇总了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