コード例 #1
0
ファイル: DiabloCommon.py プロジェクト: Chaosteil/diablobot
def get_services_account(irc, nick):
    """irc object, nick str
    Returns a tuple (status, name). status indicates whether the nick is logged in to NickServ.
    1: user not seen, 2: WHOIS in progress, 3: user known to be not logged in, 4: user logged in
    but expired, 5: logged in and current.
    The second element of the tuple is None for statuses 1-3 and the NickServ account name for
    statuses 4-5.
    """
    if nick not in whois.keys():
        # user hasn't been seen before
        irc.queueMsg(ircmsgs.whois(nick, nick))
        whois[nick] = None    # None indicates that a WHOIS is in process
        return (1, )

    elif whois[nick] == None:
        # user has been seen but WHOIS did not yet finish
        return (2, )

    elif whois[nick] == -1:
        # user is known, but is not logged in to NickServ
        # we'll check again, in case they have logged in since the last time
        irc.queueMsg(ircmsgs.whois(nick, nick))
        return (3, )

    else:
        # user is known and authenticated
        if time.time() - whois[nick][1] > 36000:
            # but ten hour have passed, so refresh the entry
            irc.queueMsg(ircmsgs.whois(nick, nick))
            return (4, whois[nick][0])

        else:
            # known and authenticated less than ten hours ago
            return (5, whois[nick][0])
コード例 #2
0
ファイル: plugin.py プロジェクト: nW44b/Limnoria
    def auth(self, irc, msg, args):
        """takes no argument

        Tries to authenticate you using network services.
        If you get no reply, it means you are not authenticated to the
        network services."""
        nick = ircutils.toLower(msg.nick)
        self._requests[(irc.network, msg.nick)] = (time.time(), msg.prefix, irc)
        irc.queueMsg(ircmsgs.whois(nick, nick))
コード例 #3
0
ファイル: plugin.py プロジェクト: the1glorfindel/PoohBot
 def whatNick(self, irc, msg, args, otherIrc, nick):
     """[<network>] <nick>
     """
     # The double nick here is necessary because single-nick WHOIS only works
     # if the nick is on the same server (*not* the same network) as the user
     # giving the command.  Yeah, it made me say wtf too.
     nick = ircutils.toLower(nick)
     otherIrc.queueMsg(ircmsgs.whois(nick, nick))
     self._whois[(otherIrc, nick)] = (irc, msg, {})
コード例 #4
0
ファイル: plugin.py プロジェクト: TingPing/Limnoria
    def whois(self, irc, msg, args, otherIrc, nick):
        """[<network>] <nick>

        Returns the WHOIS response <network> gives for <nick>.  <network> is
        only necessary if the network is different than the network the command
        is sent on.
        """
        # The double nick here is necessary because single-nick WHOIS only works
        # if the nick is on the same server (*not* the same network) as the user
        # giving the command.  Yeah, it made me say wtf too.
        nick = ircutils.toLower(nick)
        otherIrc.queueMsg(ircmsgs.whois(nick, nick))
        self._whois[(otherIrc, nick)] = (irc, msg, {}, 'whois')
コード例 #5
0
ファイル: plugin.py プロジェクト: NeoMahler/Limnoria
    def whois(self, irc, msg, args, otherIrc, nick):
        """[<network>] <nick>

        Returns the WHOIS response <network> gives for <nick>.  <network> is
        only necessary if the network is different than the network the command
        is sent on.
        """
        # The double nick here is necessary because single-nick WHOIS only works
        # if the nick is on the same server (*not* the same network) as the user
        # giving the command.  Yeah, it made me say wtf too.
        nick = ircutils.toLower(nick)
        otherIrc.queueMsg(ircmsgs.whois(nick, nick))
        self._whois[(otherIrc, nick)] = (irc, msg, {}, 'whois')
コード例 #6
0
 def testWhois(self):
     with conf.supybot.protocols.irc.strictRfc.context(True):
         self.assertEqual(str(ircmsgs.whois('foo')), 'WHOIS :foo\r\n')
         self.assertEqual(str(ircmsgs.whois('foo,bar')), 'WHOIS :foo,bar\r\n')
         self.assertRaises(AssertionError, ircmsgs.whois, '#foo')
         self.assertRaises(AssertionError, ircmsgs.whois, 'foo,#foo')
コード例 #7
0
ファイル: plugin.py プロジェクト: 4poc/competitionbot
 def processAccount(self, irc, msg, nick, callback):
     if nick in self._cache:
         callback[0](*callback[1:])
     else:
         self._requests[(irc.network, nick)] = callback
         irc.queueMsg(ircmsgs.whois(nick, nick))
コード例 #8
0
ファイル: test_ircmsgs.py プロジェクト: ElectroCode/Limnoria
 def testWhois(self):
     with conf.supybot.protocols.irc.strictRfc.context(True):
         self.assertEqual(str(ircmsgs.whois('foo')), 'WHOIS :foo\r\n')
         self.assertEqual(str(ircmsgs.whois('foo,bar')), 'WHOIS :foo,bar\r\n')
         self.assertRaises(AssertionError, ircmsgs.whois, '#foo')
         self.assertRaises(AssertionError, ircmsgs.whois, 'foo,#foo')
コード例 #9
0
 def doJoin(self, irc, msg):
     self._add(irc, msg, "join")
     nick = msg.nick
     irc.queueMsg(ircmsgs.whois(nick, nick))
コード例 #10
0
ファイル: plugin.py プロジェクト: affix/Fedbot
 def sendWhois(self, irc, nick, do_reply=False, *args):
     nick = nick.lower()
     irc.queueMsg(ircmsgs.whois(nick, nick))
     if do_reply:
         self.replies[nick] = [args[0], args[1:]]