#NEWLINE# @ internationalizeDocstring #NEWLINE# def todo( self , irc , msg , args , user , taskid ) : #NEWLINE# #INDENT# '[<username>] [<task id>]\n\n        Retrieves a task for the given task id.  If no task id is given, it\n        will return a list of task ids that that user has added to their todo\n        list.\n        ' #NEWLINE# try : #NEWLINE# #INDENT# u = ircdb . users . getUser ( msg . prefix ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# u = None #NEWLINE# #UNINDENT# if ( ( u != user ) and ( not self . registryValue ( 'allowThirdpartyReader' ) ) ) : #NEWLINE# #INDENT# irc . error ( _ ( 'You are not allowed to see other users todo-list.' ) ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( not taskid ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# tasks = self . db . getTodos ( user . id ) #NEWLINE# utils . sortBy ( operator . attrgetter ( 'priority' ) , tasks ) #NEWLINE# tasks = [ format ( _ ( '#%i: %s' ) , t . id , self . _shrink ( t . task ) ) for t in tasks ] #NEWLINE# Todo = 'Todo' #NEWLINE# if ( len ( tasks ) != 1 ) : #NEWLINE# #INDENT# Todo = 'Todos' #NEWLINE# #UNINDENT# irc . reply ( format ( _ ( '%s for %s: %L' ) , Todo , user . name , tasks ) ) #NEWLINE# #UNINDENT# except dbi . NoRecordError : #NEWLINE# #INDENT# if ( u != user ) : #NEWLINE# #INDENT# irc . reply ( _ ( 'That user has no tasks in their todo list.' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# irc . reply ( _ ( 'You have no tasks in your todo list.' ) ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# t = self . db . get ( user . id , taskid ) #NEWLINE# if t . active : #NEWLINE# #INDENT# active = _ ( 'Active' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# active = _ ( 'Inactive' ) #NEWLINE# #UNINDENT# if t . priority : #NEWLINE# #INDENT# t . task += format ( _ ( ', priority: %i' ) , t . priority ) #NEWLINE# #UNINDENT# at = time . strftime ( conf . supybot . reply . format . time ( ) , time . localtime ( t . at ) ) #NEWLINE# s = format ( _ ( '%s todo for %s: %s (Added at %s)' ) , active , user . name , t . task , at ) #NEWLINE# irc . reply ( s ) #NEWLINE# #UNINDENT# except dbi . NoRecordError : #NEWLINE# #INDENT# irc . errorInvalid ( _ ( 'task id' ) , taskid )