A telegram bot to fetch the latest NTU Hub News and to get live screenshots of campus locations. The bot is currently hosted on Heroku and can be accessed via this link.
NTU_CampusBot v1.2.0
- Crowd density using MSE image comparison
- Subscribers are now returned as list of usernames, first names or group chat names
- Bug fixes
You'll need the Heroku CLI if you want to host this bot. For more information on how to install it, check out their docs.
# install virtualenv
$ pip install virtualenv
# create a VE
$ virtualenv venv
# enter the VE
$ venv\Scripts\activate # if you're using Windows OR
$ source venv/bin/activate # if you're not using Windows
# install the dependencies
$ pip install -r requirements.txt
# run the bot
$ heroku local
Create a .env
file so you don't have to hardcode these into the codes directly. See the template below on how to create it (note that the number of X's do not reflect the actual character count of these items).
ADMINISTRATORS=XXXX,XXXX,XXXX
BOT_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
TWITTER_ACCESS_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
TWITTER_ACCESS_TOKEN_SECRET=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
TWITTER_CONSUMER_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
TWITTER_CONSUMER_SECRET=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
The required dependencies are already inside the requirements.txt
and Procfile
has already been setup to activate a worker. You'll need to create your own heroku app and push this project there to get it up and running.
Don't forget to set the concurrency level for a worker to 1 via Heroku CLI.
$ heroku ps:scale worker=1
Commands | Description |
---|---|
/start | Returns the welcome message, including disclaimer and other info. |
/peek | Returns a keyboard of available locations. Clicking on an item will return the current screenshot of the area, and if available, along with the current crowd density. |
/help | Returns a list of available commands. |
/news | Returns 5 news items from NTU News Hub. |
/about | Returns information about the bot, including version and authors. |
/subscribe | Registers user to receive tweets from NTUsg. |
/unsubscribe | Unregisters user to stop receiving tweets. Will return an error message if user is not subscribed. |
/shuttle | Returns a keyboard of available internal shuttle bus services around NTU. Clicking on an item will return a snapshot of the route, along with a list of stops. |
Commands | Description |
---|---|
/start | Returns the current status of the bot. Pass the optional parameter force to receive the standard /start message. |
/broadcast | Broadcasts a text message to all subscribers. Requires the message. |
/stats | Returns statistics about the bot including the total number of times each command has been called and the number of times tweets have been sent out. Command will be omitted from the list if it has never been called before. |
/subscribers | Returns a list of subscribed users/groups as a list of usernames/group chat names/first names. |
/maintenance | Toggles maintenance mode on/off. Setting maintenance mode on disables standard users from using the bot. Pass the optional parameter on OR off to specify the mode. |
-
Conflict: terminated by other long poll or webhook error
Check that there is no other instance of the bot running elsewhere.
-
Bot seems unresponsive when fetching /news?
NTU Hub News page responds slowly, so you might need to wait a little longer for your news to arrive.