all repos — gif-escarbot @ 692a24c44d15d2a19f660124767bf2793442253a

Earthbound Café's custom delivery bot with other cool utilities built-in.

add admin_forward
Marco Andronaco andronacomarco@gmail.com
Sat, 24 Jun 2023 13:59:17 +0200
commit

692a24c44d15d2a19f660124767bf2793442253a

parent

4d9526acb2e33475f6e73d0da8a662488008209f

3 files changed, 39 insertions(+), 2 deletions(-)

jump to
M .env.example.env.example

@@ -1,3 +1,4 @@

token= group_id= channel_id= +admin_id=
M main.pymain.py

@@ -14,6 +14,13 @@

await update.channel_post.forward(GROUP_ID) return logger.info("Forwarded a message.") +async def admin_forward(update: Update, _): + try: + await update.message.forward(ADMIN_ID) + return logger.info(f"Forwarded this message to admin: {update.message.text}") + except: + return logger.error(f"Couldn't forward this update to admin: {update}") + def config_error(): logger.error("Please create and fill the .env file.") exit(1)

@@ -27,12 +34,14 @@ try:

TOKEN = str(getenv("token")) GROUP_ID = int(getenv("group_id")) CHANNEL_ID = int(getenv("channel_id")) + ADMIN_ID = int(getenv("admin_id")) except TypeError: config_error() - if '' in [TOKEN, GROUP_ID, CHANNEL_ID]: + if '' in [TOKEN, GROUP_ID, CHANNEL_ID, ADMIN_ID]: config_error() application = ApplicationBuilder().token(TOKEN).build() application.add_handler(MessageHandler(filters.ChatType.CHANNEL, forward)) + application.add_handler(MessageHandler(filters.ChatType.PRIVATE, admin_forward)) application.run_polling()
M send.pysend.py

@@ -9,11 +9,38 @@ "chat_id": getenv("group_id"),

"text": "Hello world!", "parse_mode": "markdown", - "reply_to_message_id": None, + "reply_to_message_id": "", "disable_web_page_preview": False, "disable_notification": False, } ## Config end + +''' EXAMPLES + +endpoint = "sendVideo" +payload = { + "chat_id": getenv("group_id"), + "video": "https://media.tenor.com/zKYNgCu5TjYAAAAC/ness-pk-fire.gif", + "caption": "Test caption", + + "parse_mode": "markdown", + "reply_to_message_id": "", + "disable_web_page_preview": False, + "disable_notification": False, +} + +endpoint = "sendPhoto" +payload = { + "chat_id": getenv("group_id"), + "photo": "https://media.tenor.com/zKYNgCu5TjYAAAAC/ness-pk-fire.gif", + "caption": "Test caption", + + "parse_mode": "markdown", + "reply_to_message_id": "", + "disable_web_page_preview": False, + "disable_notification": False, +} +''' from requests import post response = post(f"https://api.telegram.org/bot{getenv('token')}/{endpoint}", json=payload,