Update to latest Telethon master

ninja_fix
Lonami Exo 2018-06-22 10:46:39 +02:00
parent 65277214fe
commit 961d6c1445
5 changed files with 17 additions and 13 deletions

View File

@ -10,6 +10,6 @@ async def _(event):
return
await event.delete()
mentions = "@all"
async for x in borg.iter_participants(await event.input_chat, 100):
async for x in borg.iter_participants(await event.get_input_chat(), 100):
mentions += f"[\u2063](tg://user?id={x.id})"
await event.respond(mentions)

View File

@ -144,7 +144,7 @@ async def reparse(event):
return
await borg(EditMessageRequest(
peer=await event.input_chat,
peer=await event.get_input_chat(),
id=event.message.id,
message=message,
no_webpage=not bool(event.message.media),

View File

@ -11,9 +11,10 @@ from uniborg import util
async def get_target_message(event):
if event.is_reply and (await event.reply_message).from_id == borg.uid:
return await event.reply_message
async for message in borg.iter_messages(await event.input_chat, limit=20):
if event.is_reply and (await event.get_reply_message()).from_id == borg.uid:
return await event.get_reply_message()
async for message in borg.iter_messages(
await event.get_input_chat(), limit=20):
if message.out:
return message
@ -22,7 +23,7 @@ async def await_read(chat, message):
chat = telethon.utils.get_peer_id(chat)
async def read_filter(read_event):
return (telethon.utils.get_peer_id(await read_event.input_chat) == chat
return (read_event.chat_id == chat
and read_event.is_read(message))
fut = borg.await_event(events.MessageRead(inbox=False), read_filter)
@ -44,7 +45,7 @@ async def delete(event):
return
target = await get_target_message(event)
if target:
chat = await event.input_chat
chat = await event.get_input_chat()
await await_read(chat, target)
await asyncio.sleep(.5)
if command == 'edit':

View File

@ -83,16 +83,19 @@ async def on_message(event):
async def on_regex(event):
if event.fwd_from:
return
if not event.is_private and await group_has_sedbot(await event.input_chat):
if not event.is_private and\
await group_has_sedbot(await event.get_input_chat()):
return
chat_id = utils.get_peer_id(await event.input_chat)
chat_id = utils.get_peer_id(await event.get_input_chat())
m, s = doit(chat_id, event.pattern_match, await event.reply_message)
m, s = doit(chat_id, event.pattern_match, await event.get_reply_message())
if m is not None:
s = f"{HEADER}{s}"
out = await borg.send_message(await event.input_chat, s, reply_to=m.id)
out = await borg.send_message(
await event.get_input_chat(), s, reply_to=m.id
)
last_msgs[chat_id].appendleft(out)
elif s is not None:
await event.reply(s)

View File

@ -28,7 +28,7 @@ async def on_snip(event):
else:
media = None
await borg.send_message(await event.input_chat, snip['text'],
await borg.send_message(await event.get_input_chat(), snip['text'],
file=media,
reply_to=event.message.reply_to_msg_id)
@ -38,7 +38,7 @@ async def on_snip(event):
@borg.on(events.NewMessage(pattern=r'\.snips (\S+)', outgoing=True))
async def on_snip_save(event):
name = event.pattern_match.group(1)
msg = await event.reply_message
msg = await event.get_reply_message()
if msg:
snips.pop(name, None)
snip = {'type': TYPE_TEXT, 'text': msg.message or ''}