This telegram bot is utilised for the election season (kähmykausi) of Inkubio.
How to use:
-
Create a config.py file and fill it with the required information (example)
- bot_token = "your_token"
- Get this from BotFather
- group_ids = ["id1", "id2"]
- You can get these for example by adding @getidsbot to the chats
- But also other ways to obtain this
- forum_url = "https://yourforum.com/"
- bot_token = "your_token"
-
Configure the Discourse forum webhook settings
- Your forum -> Additional settings -> Webhooks -> Create
- URL where your code is working (local server or hosted somewhere)
- Content type: apllication/json
- Select triggering events (creation of topics and posts for this)
- Select in which discussion areas these events trigger can happen
- Tick "Active"
- Should be working now
-
Check the category_id's so you can determine which message to send (toimari/hallitus)
-
Run the kahmy_bot.py file.
-
Wait for someone to make a post to your forum and enjoy.
-
The messages contain a link to the topic in question for easy access from the chat
Bot is developed using Python version 3.12 and needed packages for run the project are flask and requests.
To help with the usage it is also recommended to tap from the forum API settings "retry web hook events". This ensures that if the messaging to the chat fails, the forum will try to push an update again (in 1, 5, 25 and 125 minutes) until successfull. This way even if something breaks, every message should get through and as a last resort from the logs, you can manually push individual events again.