Esempio n. 1
0
 def short_str(self):
     ret = config.getescaped('Tracker', 'list item') % {
         'id': self.id,
         'subject': self.subject(),
         'expiry': self.expiry()
         }
     return ret
Esempio n. 2
0
    def historyCmd(self, call, args):
        """!%(name)shistory [#id|search]
        
        Shows/searches the unactive %(name)ss list, or give detailled info
        about one %(name)s."""
        r = self.search( ' '.join(args), self.search_keys, self.get_cmp_funcs(),
            lambda item: item.expired() )

        if not r:
            raise InputError(_("No matches."))

        if len(r) == 1:
            call.reply(r[0].long_str(), config.getescaped('Tracker', 'list separator'))
        else:
            call.reply(
                config.getescaped('Tracker', 'list separator')\
                    .join((item.short_str() for item in r)),
                config.getescaped('Tracker', 'list separator')
                )
Esempio n. 3
0
    def listCmd(self, call, args):
        """!%(name)slist [#id|search]
        
        Shows/searches the active %(name)ss list, or give detailled info
        about one %(name)s."""
        r = self.search( ' '.join(args), self.search_keys, self.get_cmp_funcs(),
            lambda item: not item.expired() or (item.deleted and item.deleted + 86400 > itime() )\
                or not item.deleted and item.start + item.length + 86400 > itime())

        if not r:
            raise InputError(_("No matches."))

        if len(r) == 1:
            call.reply(r[0].long_str(), config.getescaped('Tracker', 'list separator'))
        else:
            call.reply(
                config.getescaped('Tracker', 'list separator')\
                    .join((item.short_str() for item in r)),
                config.getescaped('Tracker', 'list separator')
                )
Esempio n. 4
0
 def long_str(self):
     ret = [self.short_str()]
     meta_names = {
             'edited_by': 'Edited by',
             'deleted_by': 'Deleted by',
             'author': 'Author'
         }
     meta_funcs = {
             'edited_by': lambda l: ', '.join(l)
         }
     meta_names.update(self.meta_names)
     meta_funcs.update(self.meta_funcs)
     for meta, val in self.meta.iteritems():
         if not val:
             continue
         ret.append(
            config.getescaped('Tracker', 'list meta') %
                 {
                     'name': meta_names.get(meta, meta),
                     'val': meta_funcs.get(meta, str)(val)
                 }
             )
     return config.getescaped('Tracker', 'list separator').join(ret)
Esempio n. 5
0
    def motdCmd(self, call, args):
        """!motd [...|--]]
        
        Sets the message of the day in the channel topic.
        !motd -- will make it empty"""

        if not args:
            call.reply(config.getescaped('Topic', 'separator').join(self.motd_str))
            return

        if len(args) == 1 and args[0] == '--':
            self.motd_str = []
        else:
            self.motd_from_str(' '.join(args))
            db.runOperation("""
                UPDATE meta
                SET val=?
                WHERE key="motd"
            """, (' '.join(args),))
        self.setmotd()