Update interactive_telegram_client.py

Updated as per review
This commit is contained in:
Joscha Götzer 2018-02-20 04:18:45 +01:00 committed by GitHub
parent b5f273c753
commit 3cc5bef700
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,9 @@ from telethon.utils import get_display_name
from telethon import ConnectionMode, TelegramClient
from telethon.errors import SessionPasswordNeededError
from telethon.tl.types import (PeerChat, UpdateShortChatMessage, UpdateShortMessage)
from telethon.tl.types import (
PeerChat, UpdateShortChatMessage, UpdateShortMessage
)
def sprint(string, *args, **kwargs):
@ -190,7 +192,7 @@ class InteractiveTelegramClient(TelegramClient):
print(' !d <msg-id>: Deletes a message by its id')
print(' !dm <msg-id>: Downloads the given message Media (if any).')
print(' !dp: Downloads the current dialog Profile picture.')
print(' !i: prints information about this chat..')
print(' !i: Prints information about this chat..')
print()
# And start a while loop to chat
@ -235,8 +237,7 @@ class InteractiveTelegramClient(TelegramClient):
# And print it to the user
sprint('[{}:{}] (ID={}) {}: {}'.format(
msg.date.hour, msg.date.minute, msg.id, name,
content))
msg.date.hour, msg.date.minute, msg.id, name, content))
# Send photo
elif msg.startswith('!up '):
@ -286,7 +287,8 @@ class InteractiveTelegramClient(TelegramClient):
print("{:<{width}} : {}".format(
attr,
getattr(entity, attr, ''),
width=longest_attr))
width=longest_attr)
)
# Send chat message (if any)
elif msg:
@ -374,6 +376,5 @@ class InteractiveTelegramClient(TelegramClient):
else:
who = self.get_entity(update.from_id)
sprint('<< {} @ {} sent "{}"'.format(
get_display_name(which), get_display_name(who),
update.message
get_display_name(which), get_display_name(who), update.message
))