This is just a simple bot I created to use with my family's chat room on GroupMe.
I created a simple command invocation scheme to get the bot to react to messages.
It is invoked in the following way:
!hb help
This command lists out all of the available commands that can be invoked.
It is invoked in the following way:
!hb birthday
This command prints out a list of everyone's birthday in the family. This also gives their current age and also says which person has the next closest birthday, and how many days away that birthday is.
NOTE: This command requires setting up a database and logging into the included admin so that you can set birthdays.
It is invoked in the following way:
!hb dadjoke
This command retrieves a dad joke at random from the https://icanhazdadjoke.com api and returns it to the group.
Invoked in the following way:
!hb weather
This command retrieves current weather from openweathermap API for some locations
setup in the database. This Weather
location database can be setup in the
admin portal.
Update: openweathermap data sucks. It always seems to be off by 5-10 degrees F. So I'm trying out weatherapi.com for now. So far I think it looks fine.
Invoked in the following way:
!hb ai <prompt>
This command uses the OpenAI completion api to respond to whatever the user
enters in the <prompt>
.
To run tests locally, just run the following command:
$ ./manage.py test --settings=website.local_settings
NOTE: the website.local_settings
option is necessary for running the tests
in the right environment.
From project root on local machine:
eb ssh hansenbot-env
Change to the current app directory
cd /var/app/current/
Activate the virtual env
source $(find /var/app/venv/*/bin/activate)
Load your environment variables
export $(sudo cat /opt/elasticbeanstalk/deployment/env | xargs)
Now you can run management commands
python manage.py shell
NOTE: Now that the github action is all set up all you have to do is push your changes to master and a new build will automatically deploy to github. Neat!
- GroupMe Developer Bots portal: https://dev.groupme.com/bots
- Github Action used: https://github.com/einaregilsson/beanstalk-deploy