mirror of
https://github.com/civsocit/olgram.git
synced 2025-12-17 16:06:17 +00:00
mailing second iteration
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import logging
|
||||
from io import BytesIO
|
||||
from aiogram.types import Message, CallbackQuery, InlineKeyboardMarkup
|
||||
from aiogram.utils.exceptions import TelegramAPIError
|
||||
from aiogram import types, Bot as AioBot
|
||||
@@ -39,15 +41,23 @@ async def send_stored_message(storage: dict, bot: AioBot, chat_id: int):
|
||||
return await bot.send_message(chat_id, storage["mailing_text"], parse_mode="HTML")
|
||||
if content_type == types.ContentType.LOCATION:
|
||||
return await bot.send_location(chat_id, storage["mailing_location"][0], storage["mailing_location"][1])
|
||||
if content_type == types.ContentType.AUDIO:
|
||||
return await bot.send_audio(chat_id, audio=storage["mailing_audio"], caption=storage.get("mailing_caption"))
|
||||
if content_type == types.ContentType.DOCUMENT:
|
||||
return await bot.send_document(chat_id, document=storage["mailing_document"],
|
||||
caption=storage.get("mailing_caption"))
|
||||
if content_type == types.ContentType.PHOTO:
|
||||
return await bot.send_photo(chat_id, photo=storage["mailing_photo"],
|
||||
caption=storage.get("mailing_caption"))
|
||||
if content_type == types.ContentType.VIDEO:
|
||||
return await bot.send_video(chat_id, video=storage["mailing_video"],
|
||||
caption=storage.get("mailing_caption"))
|
||||
if content_type in (types.ContentType.AUDIO, types.ContentType.VIDEO, types.ContentType.DOCUMENT,
|
||||
types.ContentType.PHOTO):
|
||||
caption = storage.get("mailing_caption")
|
||||
if storage.get("mailing_id"):
|
||||
logging.info("Mailing use file id")
|
||||
obj = storage["mailing_id"]
|
||||
else:
|
||||
logging.info("Mailing upload file")
|
||||
obj = types.InputFile(BytesIO(storage["mailing_data"]), filename=storage.get("mailing_file_name"))
|
||||
|
||||
if content_type == types.ContentType.AUDIO:
|
||||
return (await bot.send_audio(chat_id, audio=obj, caption=caption)).audio.file_id
|
||||
if content_type == types.ContentType.PHOTO:
|
||||
return (await bot.send_photo(chat_id, photo=obj, caption=caption)).photo[-1].file_id
|
||||
if content_type == types.ContentType.VIDEO:
|
||||
return (await bot.send_video(chat_id, video=obj, caption=caption)).video.file_id
|
||||
if content_type == types.ContentType.DOCUMENT:
|
||||
return (await bot.send_document(chat_id, document=obj, caption=caption)).document.file_id
|
||||
|
||||
raise NotImplementedError("Mailing, unknown content type")
|
||||
|
||||
Reference in New Issue
Block a user