a lightweight Slackbot framework for Python
Project description
Description
Gendo is a Slack bot/wrapper around Python’s SlackClient, that allows anyone to have a Slack bot up and running in minutes.
Installation
In a new project folder for your bot:
mkdir myslackbot
cd myslackbot
Install gendobot from pypi.
pip install gendobot
Make a new file for your bot’s config:
touch config.yaml
In your favorite text editor, edit config.yaml with the following:
gendo:
channel: "#general"
auth_token: "xoxb-1234567890-replace-this-with-token-from-slack"
Next make another file for your bot’s logic:
touch mybot.py
Also in your favorite text editor, edit mybot.py with the following:
#!/usr/bin/env/python
# -*- coding: utf-8 -*-
import os
from gendo import Gendo
path = os.path.dirname(os.path.abspath(__file__))
path_to_yaml = os.path.join(path, 'config.yaml')
gendo = Gendo.config_from_yaml(path_to_yaml)
@gendo.listen_for('morning')
def morning(user, message):
return "mornin' @{user.username}"
if __name__ == '__main__':
gendo.run()
Now try running it, run the following command then say “morning” in Slack.
python mybot.py
7. Next let's add a task that runs every 5 minutes, simply add the following to your *mybot.py* file:
@gendo.cron('*/5 * * * *')
def some_task():
gendo.speak("every 5 minutes", "#leakychat")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gendobot-2.0.0.tar.gz
(5.4 kB
view hashes)