escarbot/forward.py (view raw)
1from telegram import Update
2from escarbot.config import CHANNEL_ID, GROUP_ID, ADMIN_ID
3import logging
4logger = logging.getLogger(__name__)
5
6async def forward(update: Update, _):
7 if not update.effective_chat.id == CHANNEL_ID:
8 return logger.info("Ignoring message since it did not come from the correct chat_id.")
9
10 if update.channel_post is None:
11 return logger.warn("Got an invalid message from the correct chat_id.")
12
13 await update.channel_post.forward(GROUP_ID)
14 return logger.info("Forwarded a message.")
15
16async def admin_forward(update: Update, _):
17 try:
18 await update.message.forward(ADMIN_ID)
19 return logger.info(f"Forwarded this message to admin: { update.message.text }")
20 except:
21 return logger.error(f"Couldn't forward this update to admin: { update }")