Skip to content

Instantly share code, notes, and snippets.

@kingcons
Created May 22, 2013 16:38
Show Gist options
  • Save kingcons/5629005 to your computer and use it in GitHub Desktop.
Save kingcons/5629005 to your computer and use it in GitHub Desktop.
import smokesignal
from helga.client import helga
from helga.extensions.base import CommandExtension, ContextualExtension
class MemoExtension(CommandExtension, ContextualExtension):
"""
Memos are very useful in IRC to leave a note for someone presently offline.
"""
NAME = 'memo'
usage = '[BOTNICK] memo for (RECIPIENT): (INPUT ...)'
memos = {}
def add_memo(self, user, memo):
deliver = lambda nick, chan: helga.msg(chan, memo)
smokesignal.once(('userJoined', 'privmsg'), deliver,
lambda nick, chan: nick == user)
def handle_message(self, opts, message):
recipient, memo = opts['RECIPIENT'], ' '.join(opts['INPUT'])
self.add_memo(recipient, memo)
message.response = "Remembered, I'll tell %(recipient)s when they're back."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment