Skip to content

Instantly share code, notes, and snippets.

View gbin's full-sized avatar

Guillaume Binet gbin

View GitHub Profile
@gbin
gbin / hipchatex.plug
Last active August 29, 2015 14:26
This demonstrate how to extend an existing backend with a custom feature for your (private) plugins.
[Core]
Name = HipchatEx
Module = hipchatex
[Documentation]
Description = This is my customized hipchat backend.
@gbin
gbin / school.py
Last active August 30, 2015 16:20
Simple sample to read a file and return the output
from errbot import BotPlugin, botcmd
from os.path import join
DAYS_PATH = 'f:/errplugins/'
class School(BotPlugin):
@botcmd
def missed_day(self, msg, args):
"""Get missed day and provide assignment summary."""
with open(join(DAYS_PATH, "summary.%s" % args), 'r') as f:
@gbin
gbin / asciiart.py
Created October 4, 2015 22:07
Errbot recipes: dependencies
from errbot import BotPlugin, botcmd
from pyfiglet import Figlet
class AsciiArt(BotPlugin):
@botcmd
def big(self, mess, args):
return "```\n" + Figlet(font='slant').renderText(args) + "\n```"
@gbin
gbin / asciiart.plug
Last active October 4, 2015 22:13
Errbot recipes: Minimal plugin
[Core]
Name = AsciiArt
Module = asciiart
[Documentation]
Description = Make what you say big !
[Python]
Version = 3
@gbin
gbin / asciiart.py
Created October 4, 2015 22:15
Errbot recipes: Online help
from errbot import BotPlugin, botcmd
class AsciiArt(BotPlugin):
""" Ascii Art related commands. """
@botcmd
def big(self, mess, args):
""" Generates a big version of what you want to say."""
return args.upper()
@gbin
gbin / asciiart.py
Last active October 4, 2015 22:23
Errbot recipes: templates
from errbot import BotPlugin, botcmd
from pyfiglet import Figlet
class AsciiArt(BotPlugin):
""" Ascii Art related commands. """
@botcmd(template='biginfo')
def big(self, mess, args):
""" Generates a big version of what you want to say."""
return {'small': args, 'big': Figlet(font='slant').renderText(args)}
@gbin
gbin / asciiart.py
Created October 4, 2015 22:31
Errbot recipes: Arguments parsing.
from errbot import BotPlugin, botcmd
from pyfiglet import Figlet, FigletFont
class AsciiArt(BotPlugin):
""" Ascii Art related commands. """
@botcmd(split_args_with=' ')
def big(self, mess, args):
""" Generates a big version of what you want to say."""
fonts = FigletFont.getFonts()
if len(args) <= 1 or args[0] not in fonts:
@gbin
gbin / asciiart.py
Created October 4, 2015 22:34
Errbot recipes: Async messages
import random, time
from errbot import BotPlugin, botcmd
from pyfiglet import Figlet, FigletFont
class AsciiArt(BotPlugin):
""" Ascii Art related commands. """
@botcmd
def big(self, mess, args):
""" Generates 3 big versions with a random font."""
for font in random.sample(FigletFont.getFonts(), 3)
@gbin
gbin / asciiart.py
Created October 4, 2015 22:38
Errbot recipes: Create a poller
from datetime import datetime
from errbot import BotPlugin, botcmd
from pyfiglet import Figlet, FigletFont
class AsciiArt(BotPlugin):
""" Ascii Art related commands. """
def activate(self):
super().activate()
self.start_poller(60, self.talking_clock) # callbacks every minute
@gbin
gbin / asciiart.py
Created October 4, 2015 22:42
Errbot recipes: Webhooks
from errbot import BotPlugin, botcmd
from pyfiglet import Figlet
class AsciiArt(BotPlugin):
""" Ascii Art related commands. """
@webhook
def alert(self, request):
msg = request['msg']
self.send('gbin', "```\n" + Figlet().renderText('ALERT') + "\n```\n" + msg)