A collection of Slack bots.
- Create a virtual environment based on python3.
- Get the python requirements:
pip install -r requirements.txt
- Create a slackers.cfg (see: slackers.cfg.example)
ec2bot monitors an SQS queue for ec2 events. This includes any state change notification for the ec2 instances in your account. State changes are reported to the configured channel subject to the configuration parameters described below. Slack messages will look something like this:
ec2bot uses boto3, which means that you also need to configure your shell to have access to the SQS queue. That's beyond the scope of this document, but the author uses the AWS_PROFILE
environment variable to select the correct AWS credentials.
- Create an SQS queue (called
awsmonitor
for this example) - Create a new CloudWatch Rule with a source of
aws.ec2
and a target ofawsmonitor
- Create a Slack Bot (Workspace -> Manage Apps -> Custom Integrations -> Bots -> Add Configuration)
- Edit slackers.cfg with your slack token, SQS queue name, and channel name.
- Start up the bot!
python ec2bot.py slackers.cfg
Nag the slack channel when instances start up that are missing this list of tags. REQUIRED_TAGS should be a comma separated list of tags that should be present on every instance.
Set IGNORED_INSTANCE_NAME_REGEX to a regex string to ignore certain indexes. TODO: This should be more configurable beyond a single regex and should be possible to apply to other tags and metadata. Likely this should be a more general solution that allows for json path queries.
Set IGNORED_STATES to a comma separated list of states to ignore. If the state matches one of these states, the event will not appear in the Slack channel.
A bunch of jank that trains a markov chain generator and imitates that user on Slack.
Once propertly trained, wybott will say things like:
First, get some content to train on. I did this initially by pulling everything that a particular user said publicly from our elasticsearch index and putting it into a file, one line per sentence.
Next, train a model. I used wybott-trainer.py
to train the model based on the file of sentences.
Finally, run the bot with that model. python wybott.py
will use slackers.cfg
to find your model and connect to Slack.