Last active
September 18, 2016 02:10
-
-
Save attakei/dc9ff80105672099001bb2d7504cca58 to your computer and use it in GitHub Desktop.
todo_demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Core] | |
Name = tododemo | |
Module = tododemo | |
[Python] | |
Version = 2+ | |
[Documentation] | |
Description = Todo Demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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