Skip to content

Instantly share code, notes, and snippets.

@attakei
Last active September 18, 2016 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save attakei/dc9ff80105672099001bb2d7504cca58 to your computer and use it in GitHub Desktop.
Save attakei/dc9ff80105672099001bb2d7504cca58 to your computer and use it in GitHub Desktop.
todo_demo
[Core]
Name = tododemo
Module = tododemo
[Python]
Version = 2+
[Documentation]
Description = Todo Demo
# -*- coding:utf8 -*-
from errbot import BotPlugin, botcmd
class TodoDemo(BotPlugin):
# Not work
# @botcmd
# def set_todo(self, msg, args):
# from_id = str(msg.frm)
# todolist = self[from_id]
# todolist.append(args)
# Work
@botcmd
def set_todo(self, msg, args):
from_id = str(msg.frm)
todolist = self.get(from_id, [])
todolist.append(args)
self[from_id] = todolist
return 'Saved'
@botcmd
def show_todo(self, msg, args):
from_id = str(msg.frm)
return self.get(from_id, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment