Skip to content

Instantly share code, notes, and snippets.

@brunobord
Created December 14, 2012 21:44
Show Gist options
  • Save brunobord/4288912 to your computer and use it in GitHub Desktop.
Save brunobord/4288912 to your computer and use it in GitHub Desktop.
Django bot, used on #django-fr on Freenode. Very basic at the moment. Please be kind. Is using cmdbot: https://github.com/brunobord/cmdbot
#-*- coding: utf8 -*-
import logging
from cmdbot.core import Bot, direct
from cmdbot.core import logger
from cmdbot.configs import ArgumentConfiguration
logger.setLevel(logging.DEBUG)
class Djangobot(Bot):
welcome_message = "Salut les djangosaures !"
config_class = ArgumentConfiguration
@direct
def do_beer(self, line):
"Sending a Beer Over IP"
_, _, nick = line._raw_message.partition(' ')
if not nick:
self.reply("http://beeroverip.org/random/", line=line)
else:
self.reply("http://beeroverip.org/random/", nick=nick)
do_beer.aliases = ('bière', 'soif')
@direct
def do_hs(self, line):
"Remind people not to make too much Off-Topic"
verb, sep, rest = line._raw_message.partition(' ')
self.me("slaps %s - Merci de ne pas abuser du hors-sujet ;o)" % ', '.join(rest.split()))
if __name__ == '__main__':
b = Djangobot()
b.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment