Forward messages to multiple Telegram groups easily | Hack-X-Tronics 2021 FCRIT
The bot program is not well written due to the time constraints of Hack-X-Tronics event but the bot works well!
Telegram token removed for security reasons
Features:
- Now no need to manually send messages to different class groups!
- Using robust Telegram Bot Framework
- Send multiple texts,documents,photos
- Delete a sent message without any hassle [Can delete only the messages sent to the bot. The bot cannot delete the message forwarded to any groups]
- Send a message/ messages to the bot
- Then click on the inline buttons given by the bot (I made this bot for my engineering college)
- When you click on any button (say All 1st year), the message will be sent to that respective group/groups (for All 1st year it will be all the 1st year groups of all the departments)
- You can then click on other buttons and forward the same message to other groups too.
- Once done sending, click on 'Done' button and the message/messages will be cleared. Now you can send new set of messages which can be forwarded using the buttons.
- Bot can even send images or other documents as well.
- There is a 'delete send msg' button sent whenever a message is sent to the bot. Clicking on that button will delete that sent message from the database.
Send something to bot ______________________ |
Send forward command ______________________ |
Bot forwards the messages ______________________ |
Clearing the messages ______________________ |
---|---|---|---|
Delete a sent message
Can be done for files as well!
- The messages sent by admins are stored in 'Admin/<chat_id_of_admin>/' folder. '<chat_id_of_admin>/' folder stores admininfo.txt and chat.txt along with files (like .png, .pdf etc).
- chat.txt file stores the messages sent by that admin in JSON format. Messages are saved with message_id as 'key' and text sent as 'value'.
{"1825": "hello"}
- All the messages are concatenated and stored. Once 'Done' command is sent all the chat.txt is cleared and all the files are deleted
- admininfo.txt stored Admin's information in JSON format
{"id": 123456789, "is_bot": false, "first_name": "Ashwin", "username": "abcd", "language_code": "en"}
- This file contants the group chat ID stored in JSON format.
- 'Key' is the groups and 'value' is the group's chat ID. I have used Regex in the program for reading the values easily without using if-else, so according 'key' is named. Refer the regex added inside the program.
- To get group chat ID, add the bot to the group and send a command to the bot. The bot does not allow commands from a group so it replies with 'Not allowed!' followed by group's chat ID and Group's name