Skip to main content

a lightweight Slackbot framework for Python

Project description

Pypi Python Versions Build status

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

  1. In a new project folder for your bot:

mkdir myslackbot
cd myslackbot
  1. Install gendobot from pypi.

pip install gendobot
  1. Make a new file for your bot’s config:

touch config.yaml
  1. In your favorite text editor, edit config.yaml with the following:

gendo:
  channel: "#general"
  auth_token: "xoxb-1234567890-replace-this-with-token-from-slack"
  1. Next make another file for your bot’s logic:

touch mybot.py
  1. 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()
  1. 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


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)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page