コード例 #1
0
ファイル: admin.py プロジェクト: pulilab/gaelord
 def get(self):
     key = self.request.get('key')
     resp = ''
     if key:
         try:
             filters.remove_filter(key)
         except filters.NonexistentFilterError, e:
             resp = e.msg
コード例 #2
0
ファイル: bot.py プロジェクト: pulilab/gaelord
    def delete_command(self, message=None):
        """Command handler for /delete i

        i -- the index from the filters' list

        Deletes the filter given by the index.
        """
        jid = message.sender.split('/')[0]

        try:
            i = int(message.arg)
            key = filters.subscriptions()[jid][i-1][1]
        except ValueError, IndexError:
            message.reply('Invalid index: %s' % message.arg or 'None')
        else:
            filters.remove_filter(key)
            message.reply('Deleted')

    def add_command(self, message=None):
        """Command handler for /add

        Starts the interactive filter creation.
        """
        global _is_input
        _is_input = True
        self.text_message(message)

    def _add_input_handler(self, message=None):
        """Interactive filter creation. The function populates a
        dictionary with the user's replies which is used to construct
        the RecordFilter object.