lets look at an example (funBot):
import requests
from bs4 import BeautifulSoup
from boten import core
class Bot(core.BaseBot):
def command_make_me_laugh(self):
page = BeautifulSoup(requests.post('http://devopsreactions.tumblr.com/random').content)
post_content = page.find("div", {"class": "item_content"})
yield unicode(page.find('div', {"class": "post_title"}).find('a').contents[0])
yield post_content.find('img')['src']now, if someone will type /fun make_me_laugh (or even /fun mak as boten matches prefix) he will send funny post from devopsreactions
Create a new function and ask for args, Boten will validate the user input for you.
def command_ping(self, user_name):
yield "pong {}".format(user_name)/fun ping will fail with error message of
*Function name: /ping
Mandatory args are: user_name
Optional args are:*
def command_ping(self, user_name="default"):
yield "pong {}".format(user_name)/fun ping will send pong default
but /fun ping user_name=moshe will send pong moshe
you can yield for messages while running, if you want to send message with slide colors you need to use core.SlackMessage
yield core.SlackMessage()
.icon(':low_brightness:')
.username('jenkinsBot')
.text("unitTests failure", color="danger")Simply /fun help, /fun ping help
- create python file under
bots_available - link from
bots_availabletobots_enabled - add new slash command in slack ui - Integrations