|
@@ -151,15 +151,21 @@ async def make_message_shot(bot, message):
|
|
|
output_path = make_temporary_filename('png')
|
|
|
avatar_path = make_temporary_filename('png')
|
|
|
|
|
|
- await bot.download_profile_photo(message.sender, file=avatar_path)
|
|
|
+ if message.sender is None:
|
|
|
+ await bot.download_profile_photo(message.peer_id.channel_id, file=avatar_path)
|
|
|
|
|
|
- full_name = get_display_name(message.sender)
|
|
|
+ full_name = await bot.get_entity(message.peer_id.channel_id)
|
|
|
+ full_name = full_name.title
|
|
|
+ else:
|
|
|
+ await bot.download_profile_photo(message.sender, file=avatar_path)
|
|
|
+
|
|
|
+ full_name = get_display_name(message.sender)
|
|
|
|
|
|
data = dumps({
|
|
|
'output_path': output_path,
|
|
|
'avatar_path': avatar_path,
|
|
|
'username': full_name if full_name else message.sender.username,
|
|
|
- 'username_color': await assign_color(message.sender.id),
|
|
|
+ 'username_color': await assign_color(message.sender.id if message.sender else message.peer_id.channel_id),
|
|
|
'text': message.text
|
|
|
}).encode('UTF-8')
|
|
|
|
|
@@ -180,13 +186,16 @@ async def save_handler(bot, event, command):
|
|
|
if command.argc >= 1:
|
|
|
emoji = command.args[0]
|
|
|
|
|
|
- if not is_emoji(emoji):
|
|
|
+ if len(emoji) not in range(1, 6)\
|
|
|
+ or not all(map(is_emoji, emoji)):
|
|
|
await event.reply('Указан некорректный эмодзи!!!')
|
|
|
|
|
|
return
|
|
|
|
|
|
path = await make_message_shot(bot, message)
|
|
|
|
|
|
+ return
|
|
|
+
|
|
|
try:
|
|
|
file = await add_sticker(bot, path, emoji)
|
|
|
|