git clone https://github.com/mikhail/alphabot.git
cd alphabot
pip install -e .
Alphabot has some support for conversation flow:
If you installed alphabot as a python package then simply run it:
alphabot -S alphabot/sample-scripts/ # or...
alphabot -S path/to/your/scripts/
export SLACK_TOKEN=xoxb-YourToken
alphabot --engine slack -S path/to your/scripts/
Function decorators
@bot.on_start()
def some_command():
# This command will execute whenever a bot starts
Generic event matcher. Useful for things that aren't chat-initiated, like people joining a room, emoji events, etc...
This command will get executed when an event is received with key type and value "something"
@bot.on(type="something")
def some_command(event: dict):
# event contents depend on the event. For slack - https://api.slack.com/events-api#receiving_events
log.debug(event)
Most common decorator - executes when the listener sees the regex. If direct is set to True then this will only trigger if the message is sent in a DM or if the message begins with @<bot name>
@bot.add_command('regex here', direct=False)
def normal_command(message: Chat):
await message.reply('Regex was matched!')
WIP - Uses NaiveBayesClassifier to do some primitive language learning.
@bot.learn(['Print seven', 'What is your lucky number', 'Give me a number between six and eight'])
def text_match_command(message: Chat):
await message.reply('Seven!')
year (int|str) - 4-digit year month (int|str) - month (1-12) day (int|str) - day of the (1-31) week (int|str) - ISO week (1-53) day_of_week (int|str) - number or name of weekday (0-6 or mon,tue,wed,thu,fri,sat,sun) hour (int|str) - hour (0-23) minute (int|str) - minute (0-59) second (int|str) - second (0-59) start_date (datetime|str) - earliest possible date/time to trigger on (inclusive) end_date (datetime|str) - latest possible date/time to trigger on (inclusive) timezone (datetime.tzinfo|str) - time zone to use for the date/time calculations (defaults to scheduler timezone)
@bot.on_schedule(minute=0)
def on_the_hour():
channel = bot.get_channel(name='hourly')
await channel.send('The time has come!')
Bot functions
bot.api(method: str, params: dict)
bot.send(text, to, extra)
bot.get_channel(**kwargs)