コード例 #1
0
ファイル: plugin.py プロジェクト: D0MF/supybot-plugins-1
 def _formatMemo(self, memo):
     user = plugins.getUserName(memo.by)
     L = [format('%s (added by %s at %t)', memo.text, user, memo.at)]
     for (at, by, text) in memo.appends:
         L.append(format('%s (appended by %s at %t)',
                         text, plugins.getUserName(by), at))
     sep = ircutils.bold(' :: ')
     return sep.join(L)
コード例 #2
0
ファイル: plugin.py プロジェクト: the1glorfindel/PoohBot
 def _formatNote(self, note, to):
     elapsed = utils.timeElapsed(time.time() - note.at)
     if note.to == to:
         author = plugins.getUserName(note.frm)
         return format("#%i: %s (Sent by %s %s ago)", note.id, note.text, author, elapsed)
     else:
         assert note.frm == to, "Odd, userid isn't frm either."
         recipient = plugins.getUserName(note.to)
         return format("#%i: %s (Sent to %s %s ago)", note.id, note.text, recipient, elapsed)
コード例 #3
0
 def _formatMemo(self, memo):
     user = plugins.getUserName(memo.by)
     L = [format('%s (added by %s at %t)', memo.text, user, memo.at)]
     for (at, by, text) in memo.appends:
         L.append(
             format('%s (appended by %s at %t)', text,
                    plugins.getUserName(by), at))
     sep = ircutils.bold(' :: ')
     return sep.join(L)
コード例 #4
0
ファイル: plugin.py プロジェクト: Athemis/Limnoria
 def _formatNoteId(self, msg, note, sent=False):
     if note.public or not ircutils.isChannel(msg.args[0]):
         if sent:
             sender = plugins.getUserName(note.to)
             return format('#%i to %s', note.id, sender)
         else:
             sender = plugins.getUserName(note.frm)
             return format('#%i from %s', note.id, sender)
     else:
         return format('#%i (private)', note.id)
コード例 #5
0
 def _formatNoteId(self, msg, note, sent=False):
     if note.public or not ircutils.isChannel(msg.args[0]):
         if sent:
             sender = plugins.getUserName(note.to)
             return format('#%i to %s', note.id, sender)
         else:
             sender = plugins.getUserName(note.frm)
             return format('#%i from %s', note.id, sender)
     else:
         return format('#%i (private)', note.id)
コード例 #6
0
 def _formatNote(self, note, to):
     elapsed = utils.timeElapsed(time.time() - note.at)
     if note.to == to:
         author = plugins.getUserName(note.frm)
         return format('#%i: %s (Sent by %s %s ago)',
                       note.id, note.text, author, elapsed)
     else:
         assert note.frm == to, 'Odd, userid isn\'t frm either.'
         recipient = plugins.getUserName(note.to)
         return format('#%i: %s (Sent to %s %s ago)',
                       note.id, note.text, recipient, elapsed)
コード例 #7
0
 def __str__(self):
     grabber = plugins.getUserName(self.grabber)
     if self.at:
         return format(_('%s (Said by: %s; grabbed by %s at %t)'),
                       self.text, self.hostmask, grabber, self.at)
     else:
         return format('%s', self.text)
コード例 #8
0
ファイル: plugin.py プロジェクト: ElectroCode/Limnoria
 def __str__(self):
     grabber = plugins.getUserName(self.grabber)
     if self.at:
         return format(_('%s (Said by: %s; grabbed by %s at %t)'),
                       self.text, self.hostmask, grabber, self.at)
     else:
         return format('%s', self.text)
コード例 #9
0
ファイル: plugin.py プロジェクト: Hoaas/Limnoria
    def factinfo(self, irc, msg, args, channel, key):
        """[<channel>] <factoid key>

        Returns the various bits of info on the factoid for the given key.
        <channel> is only necessary if the message isn't sent in the channel
        itself.
        """
        # Start building the response string
        s = key + ": "
        # Next, get all the info and build the response piece by piece
        info = self.db.getFactinfo(channel, key)
        if not info:
            irc.error(format(_("No such factoid: %q"), key))
            return
        (
            created_by,
            created_at,
            modified_by,
            modified_at,
            last_requested_by,
            last_requested_at,
            requested_count,
            locked_by,
            locked_at,
        ) = info
        # First, creation info.
        # Map the integer created_by to the username
        created_by = plugins.getUserName(created_by)
        created_at = time.strftime(conf.supybot.reply.format.time(), time.localtime(int(created_at)))
        s += format(_("Created by %s on %s."), created_by, created_at)
        # Next, modification info, if any.
        if modified_by is not None:
            modified_by = plugins.getUserName(modified_by)
            modified_at = time.strftime(conf.supybot.reply.format.time(), time.localtime(int(modified_at)))
            s += format(_(" Last modified by %s on %s."), modified_by, modified_at)
        # Next, last requested info, if any
        if last_requested_by is not None:
            last_by = last_requested_by  # not an int user id
            last_at = time.strftime(conf.supybot.reply.format.time(), time.localtime(int(last_requested_at)))
            req_count = requested_count
            s += format(_(" Last requested by %s on %s, requested %n."), last_by, last_at, (requested_count, "time"))
        # Last, locked info
        if locked_at is not None:
            lock_at = time.strftime(conf.supybot.reply.format.time(), time.localtime(int(locked_at)))
            lock_by = plugins.getUserName(locked_by)
            s += format(_(" Locked by %s on %s."), lock_by, lock_at)
        irc.reply(s)
コード例 #10
0
    def factinfo(self, irc, msg, args, channel, key):
        """[<channel>] <factoid key>

        Returns the various bits of info on the factoid for the given key.
        <channel> is only necessary if the message isn't sent in the channel
        itself.
        """
        # Start building the response string
        s = key + ': '
        # Next, get all the info and build the response piece by piece
        info = self.db.getFactinfo(channel, key)
        if not info:
            irc.error(format(_('No such factoid: %q'), key))
            return
        (created_by, created_at, modified_by, modified_at, last_requested_by,
         last_requested_at, requested_count, locked_by, locked_at) = info
        # First, creation info.
        # Map the integer created_by to the username
        created_by = plugins.getUserName(created_by)
        created_at = time.strftime(conf.supybot.reply.format.time(),
                                   time.localtime(int(created_at)))
        s += format(_('Created by %s on %s.'), created_by, created_at)
        # Next, modification info, if any.
        if modified_by is not None:
            modified_by = plugins.getUserName(modified_by)
            modified_at = time.strftime(conf.supybot.reply.format.time(),
                                        time.localtime(int(modified_at)))
            s += format(_(' Last modified by %s on %s.'), modified_by,
                        modified_at)
        # Next, last requested info, if any
        if last_requested_by is not None:
            last_by = last_requested_by  # not an int user id
            last_at = time.strftime(conf.supybot.reply.format.time(),
                                    time.localtime(int(last_requested_at)))
            req_count = requested_count
            s += format(_(' Last requested by %s on %s, requested %n.'),
                        last_by, last_at, (requested_count, 'time'))
        # Last, locked info
        if locked_at is not None:
            lock_at = time.strftime(conf.supybot.reply.format.time(),
                                    time.localtime(int(locked_at)))
            lock_by = plugins.getUserName(locked_by)
            s += format(_(' Locked by %s on %s.'), lock_by, lock_at)
        irc.reply(s)
コード例 #11
0
ファイル: plugin.py プロジェクト: Hoaas/Limnoria
 def _mostAuthored(self, irc, channel, limit):
     results = self.db.mostAuthored(channel, limit)
     L = ["%s (%s)" % (plugins.getUserName(t[0]), int(t[1])) for t in results]
     if L:
         author = _("author")
         if len(L) != 1:
             author = _("authors")
         irc.reply(format(_("Most prolific %s: %L"), author, L))
     else:
         irc.error(_("There are no factoids in my database."))
コード例 #12
0
ファイル: plugin.py プロジェクト: tigrmesh/Limnoria
 def _mostAuthored(self, irc, channel, limit):
     results = self.db.mostAuthored(channel, limit)
     L = ['%s (%s)' % (plugins.getUserName(t[0]), int(t[1]))
          for t in results]
     if L:
         author = _('author')
         if len(L) != 1:
             author = _('authors')
         irc.reply(format(_('Most prolific %s: %L'), author, L))
     else:
         irc.error(_('There are no factoids in my database.'))
コード例 #13
0
ファイル: plugin.py プロジェクト: Kefkius/mazabot
 def _mostAuthored(self, irc, channel, limit):
     results = self.db.mostAuthored(channel, limit)
     L = ['%s (%s)' % (plugins.getUserName(t[0]), int(t[1]))
          for t in results]
     if L:
         author = 'author'
         if len(L) != 1:
             author = 'authors'
         irc.reply(format('Most prolific %s: %L', author, L))
     else:
         irc.error('There are no factoids in my database.')
コード例 #14
0
ファイル: plugin.py プロジェクト: Latinx/supybot
 def __str__(self):
     user = plugins.getUserName(self.by)
     if self.options:
         options = format('Options: %s', '; '.join(map(str, self.options)))
     else:
         options = 'The poll has no options, yet'
     if self.status:
         status = 'open'
     else:
         status = 'closed'
     return format('Poll #%i: %q started by %s. %s.  Poll is %s.',
                   self.id, self.question, user, options, status)
コード例 #15
0
ファイル: plugin.py プロジェクト: affix/supybot-plugins
 def __str__(self):
     user = plugins.getUserName(self.by)
     if self.options:
         options = format('Options: %s', '; '.join(map(str, self.options)))
     else:
         options = 'The poll has no options, yet'
     if self.status:
         status = 'open'
     else:
         status = 'closed'
     return format('Poll #%i: %q started by %s. %s.  Poll is %s.', self.id,
                   self.question, user, options, status)
コード例 #16
0
ファイル: plugin.py プロジェクト: Criptomonedas/supybot_fixes
 def __str__(self):
     user = plugins.getUserName(self.by)
     if self.expires == 0:
         s = format('%s (Subject: %q, added by %s on %s)',
                    self.text, self.subject, self.by,
                    utils.str.timestamp(self.at))
     else:
         s = format('%s (Subject: %q, added by %s on %s, '
                    'expires at %s)',
                    self.text, self.subject, user,
                    utils.str.timestamp(self.at),
                    utils.str.timestamp(self.expires))
     return s
コード例 #17
0
ファイル: plugin.py プロジェクト: mogad0n/Limnoria
 def __str__(self):
     user = plugins.getUserName(self.by)
     if self.expires == 0:
         s = format(_('%s (Subject: %q, added by %s on %s)'),
                    self.text, self.subject, self.by,
                    utils.str.timestamp(self.at))
     else:
         s = format(
             _('%s (Subject: %q, added by %s on %s, '
               'expires at %s)'), self.text, self.subject, user,
             utils.str.timestamp(self.at),
             utils.str.timestamp(self.expires))
     return s
コード例 #18
0
ファイル: plugin.py プロジェクト: affix/supybot-plugins
 def results(self, channel, poll_id):
     db = self._getDb(channel)
     cursor = db.cursor()
     cursor.execute(
         """SELECT id, question, started_by, open
                       FROM polls WHERE id=%s""", poll_id)
     if cursor.rowcount == 0:
         raise dbi.NoRecordError
     (id, question, by, status) = cursor.fetchone()
     by = plugins.getUserName(by)
     cursor.execute(
         """SELECT count(user_id), option_id
                       FROM votes
                       WHERE poll_id=%s
                       GROUP BY option_id
                       UNION
                       SELECT 0, id AS option_id
                       FROM options
                       WHERE poll_id=%s
                       AND id NOT IN (
                             SELECT option_id FROM votes
                             WHERE poll_id=%s)
                       GROUP BY option_id
                       ORDER BY count(user_id) DESC""", poll_id, poll_id,
         poll_id)
     if cursor.rowcount == 0:
         raise PollError, 'This poll has no votes yet.'
     else:
         options = []
         for count, option_id in cursor.fetchall():
             cursor.execute(
                 """SELECT option FROM options
                               WHERE id=%s AND poll_id=%s""", option_id,
                 poll_id)
             option = cursor.fetchone()[0]
             options.append(
                 OptionRecord(option_id, votes=int(count), text=option))
     return PollRecord(poll_id,
                       question=question,
                       status=status,
                       by=by,
                       options=options)
コード例 #19
0
ファイル: plugin.py プロジェクト: Latinx/supybot
 def results(self, channel, poll_id):
     db = self._getDb(channel)
     cursor = db.cursor()
     cursor.execute("""SELECT id, question, started_by, open
                       FROM polls WHERE id=%s""",
                       poll_id)
     if cursor.rowcount == 0:
         raise dbi.NoRecordError
     (id, question, by, status) = cursor.fetchone()
     by = plugins.getUserName(by)
     cursor.execute("""SELECT count(user_id), option_id
                       FROM votes
                       WHERE poll_id=%s
                       GROUP BY option_id
                       UNION
                       SELECT 0, id AS option_id
                       FROM options
                       WHERE poll_id=%s
                       AND id NOT IN (
                             SELECT option_id FROM votes
                             WHERE poll_id=%s)
                       GROUP BY option_id
                       ORDER BY count(user_id) DESC""",
                       poll_id, poll_id, poll_id)
     if cursor.rowcount == 0:
         raise PollError, 'This poll has no votes yet.'
     else:
         options = []
         for count, option_id in cursor.fetchall():
             cursor.execute("""SELECT option FROM options
                               WHERE id=%s AND poll_id=%s""",
                               option_id, poll_id)
             option = cursor.fetchone()[0]
             options.append(OptionRecord(option_id, votes=int(count),
                                         text=option))
     return PollRecord(poll_id, question=question, status=status, by=by,
                       options=options)
コード例 #20
0
ファイル: plugin.py プロジェクト: nod/boombot
 def __str__(self):
     at = time.strftime(conf.supybot.reply.format.time(),
                        time.localtime(float(self.at)))
     grabber = plugins.getUserName(self.grabber)
     return '%s (Said by: %s; grabbed by %s at %s)' % \
               (self.text, self.hostmask, grabber, at)
コード例 #21
0
 def __str__(self):
     at = time.strftime(conf.supybot.reply.format.time(),
                        time.localtime(float(self.at)))
     grabber = plugins.getUserName(self.grabber)
     return '%s (Said by: %s; grabbed by %s at %s)' % \
               (self.text, self.hostmask, grabber, at)
コード例 #22
0
ファイル: plugin.py プロジェクト: Wintervenom/Xn
 def __str__(self):
     grabber = plugins.getUserName(self.grabber).split('!', 2)
     return format('%s grabbed: %s',
                   grabber[0], self.text)
コード例 #23
0
ファイル: plugin.py プロジェクト: jreese/supybot-plugins
 def __str__(self):
     grabber = plugins.getUserName(self.grabber)
     return format('%s (Said by: %s; grabbed by %s at %t)',
                   self.text, self.hostmask, grabber, float(self.at))