当前位置: 首页>>代码示例>>Python>>正文


Python ircutils.isNick函数代码示例

本文整理汇总了Python中supybot.ircutils.isNick函数的典型用法代码示例。如果您正苦于以下问题:Python isNick函数的具体用法?Python isNick怎么用?Python isNick使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了isNick函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testIsNickNeverAllowsSpaces

 def testIsNickNeverAllowsSpaces(self):
     try:
         original = conf.supybot.protocols.irc.strictRfc()
         conf.supybot.protocols.irc.strictRfc.setValue(True)
         self.failIf(ircutils.isNick('foo bar'))
         conf.supybot.protocols.irc.strictRfc.setValue(False)
         self.failIf(ircutils.isNick('foo bar'))
     finally:
         conf.supybot.protocols.irc.strictRfc.setValue(original)
开发者ID:krattai,项目名称:AEBL,代码行数:9,代码来源:test_ircutils.py

示例2: tell

    def tell(self, irc, msg, args, target, text):
        """<nick> <text>

        Tells the <nick> whatever <text> is.  Use nested commands to your
        benefit here.
        """
        if target.lower() == 'me':
            target = msg.nick
        if ircutils.isChannel(target):
            irc.error('Dude, just give the command.  No need for the tell.')
            return
        if not ircutils.isNick(target):
            irc.errorInvalid('nick', target)
        if ircutils.nickEqual(target, irc.nick):
            irc.error('You just told me, why should I tell myself?',Raise=True)
        if target not in irc.state.nicksToHostmasks and \
             not ircdb.checkCapability(msg.prefix, 'owner'):
            # We'll let owners do this.
            s = 'I haven\'t seen %s, I\'ll let you do the telling.' % target
            irc.error(s, Raise=True)
        if irc.action:
            irc.action = False
            text = '* %s %s' % (irc.nick, text)
        s = '%s wants me to tell you: %s' % (msg.nick, text)
        irc.reply(s, to=target, private=True)
开发者ID:MrTiggr,项目名称:supybot_fixes,代码行数:25,代码来源:plugin.py

示例3: tell

    def tell(self, irc, msg, args, target, text):
        """<nick> <text>

        Tells the <nick> whatever <text> is.  Use nested commands to your
        benefit here.
        """
        if irc.nested:
            irc.error("This command cannot be nested.", Raise=True)
        if target.lower() == "me":
            target = msg.nick
        if ircutils.isChannel(target):
            irc.error("Dude, just give the command.  No need for the tell.")
            return
        if not ircutils.isNick(target):
            irc.errorInvalid("nick", target)
        if ircutils.nickEqual(target, irc.nick):
            irc.error("You just told me, why should I tell myself?", Raise=True)
        if target not in irc.state.nicksToHostmasks and not ircdb.checkCapability(msg.prefix, "owner"):
            # We'll let owners do this.
            s = "I haven't seen %s, I'll let you do the telling." % target
            irc.error(s, Raise=True)
        if irc.action:
            irc.action = False
            text = "* %s %s" % (irc.nick, text)
        s = "%s wants me to tell you: %s" % (msg.nick, text)
        irc.replySuccess()
        irc.reply(s, to=target, private=True)
开发者ID:krattai,项目名称:AEBL,代码行数:27,代码来源:plugin.py

示例4: getNick

def getNick(irc, msg, args, state):
    if ircutils.isNick(args[0], conf.supybot.protocols.irc.strictRfc()):
        if "nicklen" in irc.state.supported:
            if len(args[0]) > irc.state.supported["nicklen"]:
                state.errorInvalid(_("nick"), args[0], _("That nick is too long for this server."))
        state.args.append(args.pop(0))
    else:
        state.errorInvalid(_("nick"), args[0])
开发者ID:yenatch,项目名称:Limnoria,代码行数:8,代码来源:commands.py

示例5: replacer

    def replacer(self, irc, msg, regex):
        if not self.registryValue('enable', msg.args[0]):
            return
        iterable = reversed(irc.state.history)
        msg.tag('Replacer')

        try:
            (pattern, replacement, count) = self._unpack_sed(msg.args[1])
        except (ValueError, re.error) as e:
            self.log.warning(_("Replacer error: %s"), e)
            if self.registryValue('displayErrors', msg.args[0]):
                irc.error(_("Replacer error: %s" % e), Raise=True)
            return

        next(iterable)
        for m in iterable:
            if m.command in ('PRIVMSG', 'NOTICE') and \
                    m.args[0] == msg.args[0]:
                target = regex.group('nick')
                if not ircutils.isNick(str(target), strictRfc=True):
                    return
                if target and m.nick != target:
                    continue
                # Don't snarf ignored users' messages unless specifically
                # told to.
                if ircdb.checkIgnored(m.prefix) and not target:
                    continue
                # When running substitutions, ignore the "* nick" part of any actions.
                action = ircmsgs.isAction(m)
                if action:
                    text = ircmsgs.unAction(m)
                else:
                    text = m.args[1]

                if self.registryValue('ignoreRegex', msg.args[0]) and \
                        m.tagged('Replacer'):
                    continue
                if m.nick == msg.nick:
                    messageprefix = msg.nick
                else:
                    messageprefix = '%s thinks %s' % (msg.nick, m.nick)
                if regexp_wrapper(text, pattern, timeout=0.05, plugin_name=self.name(),
                                  fcn_name='replacer'):
                    if self.registryValue('boldReplacementText', msg.args[0]):
                        replacement = ircutils.bold(replacement)
                    subst = process(pattern.sub, replacement,
                                text, count, timeout=0.05)
                    if action:  # If the message was an ACTION, prepend the nick back.
                        subst = '* %s %s' % (m.nick, subst)
                    irc.reply(_("%s meant to say: %s") %
                              (messageprefix, subst), prefixNick=False)
                    return

        self.log.debug(_("Replacer: Search %r not found in the last %i messages of %s."),
                         msg.args[1], len(irc.state.history), msg.args[0])
        if self.registryValue("displayErrors", msg.args[0]):
            irc.error(_("Search not found in the last %i messages.") %
                      len(irc.state.history), Raise=True)
开发者ID:nathan0,项目名称:SupyPlugins,代码行数:58,代码来源:plugin.py

示例6: getNick

def getNick(irc, msg, args, state):
    if ircutils.isNick(args[0]):
        if 'nicklen' in irc.state.supported:
            if len(args[0]) > irc.state.supported['nicklen']:
                state.errorInvalid('nick', args[0],
                                 'That nick is too long for this server.')
        state.args.append(args.pop(0))
    else:
        state.errorInvalid('nick', args[0])
开发者ID:Criptomonedas,项目名称:supybot_fixes,代码行数:9,代码来源:commands.py

示例7: addNick

 def addNick(self, network, nick):
     """Adds a nick to the user's registered nicks on the network."""
     global users
     assert isinstance(network, basestring)
     assert ircutils.isNick(nick), 'got %s' % nick
     if users.getUserFromNick(network, nick) is not None:
         raise KeyError
     if network not in self.nicks:
         self.nicks[network] = []
     if nick not in self.nicks[network]:
         self.nicks[network].append(nick)
开发者ID:Erika-Mustermann,项目名称:Limnoria,代码行数:11,代码来源:ircdb.py

示例8: username

    def username(self, irc, msg, args, hostmask):
        """<hostmask|nick>

        Returns the username of the user specified by <hostmask> or <nick> if
        the user is registered.
        """
        if ircutils.isNick(hostmask):
            try:
                hostmask = irc.state.nickToHostmask(hostmask)
            except KeyError:
                irc.error(_('I haven\'t seen %s.') % hostmask, Raise=True)
        try:
            user = ircdb.users.getUser(hostmask)
            irc.reply(user.name)
        except KeyError:
            irc.error(_('I don\'t know who that is.'))
开发者ID:limebot,项目名称:LimeBot,代码行数:16,代码来源:plugin.py

示例9: invalidCommand

 def invalidCommand(self, irc, msg, tokens):
     if irc.isChannel(msg.args[0]):
         channel = msg.args[0]
         if self.registryValue('replyWhenInvalidCommand', channel):
             redirect_nick=None
             # we're looking for @factoid | nick
             if "|" in tokens and tokens.index("|") == len(tokens) - 2:
                 # get the nick
                 redirect_nick = tokens.pop()
                 c = irc.state.channels[channel]
                 if not ircutils.isNick(redirect_nick) or \
                    redirect_nick not in c.users:
                     irc.error('No such user.')
                     return
                 # don't want to talk to myself
                 if redirect_nick == irc.nick:
                     redirect_nick = None
                 # and get rid of the | character
                 tokens.pop()
             key = ' '.join(tokens)
             factoids = self._lookupFactoid(channel, key)
             self._replyFactoids(irc, msg, key, factoids, error=False)
                                 to=redirect_nick)
开发者ID:kblin,项目名称:supybot-gsoc,代码行数:23,代码来源:plugin.py

示例10: _tell

 def _tell(self, irc, msg, args, target, text, notice):
     if irc.nested:
         irc.error('This command cannot be nested.', Raise=True)
     if target.lower() == 'me':
         target = msg.nick
     if ircutils.isChannel(target):
         irc.error(_('Hey, just give the command.  No need for the tell.'))
         return
     if not ircutils.isNick(target):
         irc.errorInvalid('nick', target)
     if ircutils.nickEqual(target, irc.nick):
         irc.error(_('You just told me, why should I tell myself?'),
                   Raise=True)
     if target not in irc.state.nicksToHostmasks and \
          not ircdb.checkCapability(msg.prefix, 'owner'):
         # We'll let owners do this.
         s = _('I haven\'t seen %s, I\'ll let you do the telling.') % target
         irc.error(s, Raise=True)
     if irc.action:
         irc.action = False
         text = '* %s %s' % (irc.nick, text)
     s = _('%s wants me to tell you: %s') % (msg.nick, text)
     irc.replySuccess()
     irc.reply(s, to=target, private=True, notice=notice)
开发者ID:Poorchop,项目名称:Limnoria,代码行数:24,代码来源:plugin.py

示例11: set

 def set(self, s):
     if not ircutils.isNick(s):
         self.error()
     registry.String.set(self, s)
开发者ID:wonaldson,项目名称:supybot-PieSpy,代码行数:4,代码来源:config.py

示例12: setValue

 def setValue(self, v):
     if not (ircutils.isNick(v) or ircutils.isChannel(v)):
         self.error()
     registry.String.setValue(self, v)
开发者ID:hacklab,项目名称:doorbot,代码行数:4,代码来源:config.py

示例13: testIsNick

 def testIsNick(self):
     try:
         original = conf.supybot.protocols.irc.strictRfc()
         conf.supybot.protocols.irc.strictRfc.setValue(True)
         self.failUnless(ircutils.isNick("jemfinch"))
         self.failUnless(ircutils.isNick("jemfinch0"))
         self.failUnless(ircutils.isNick("[0]"))
         self.failUnless(ircutils.isNick("{jemfinch}"))
         self.failUnless(ircutils.isNick("[jemfinch]"))
         self.failUnless(ircutils.isNick("jem|finch"))
         self.failUnless(ircutils.isNick("\\```"))
         self.failUnless(ircutils.isNick("`"))
         self.failUnless(ircutils.isNick("A"))
         self.failIf(ircutils.isNick(""))
         self.failIf(ircutils.isNick("8foo"))
         self.failIf(ircutils.isNick("10"))
         self.failIf(ircutils.isNick("-"))
         self.failIf(ircutils.isNick("-foo"))
         conf.supybot.protocols.irc.strictRfc.setValue(False)
         self.failUnless(ircutils.isNick("[email protected]"))
     finally:
         conf.supybot.protocols.irc.strictRfc.setValue(original)
开发者ID:ProgVal,项目名称:Limnoria,代码行数:22,代码来源:test_ircutils.py

示例14: setValue

 def setValue(self, v):
     if v and not ircutils.isNick(v):
         raise registry.InvalidRegistryValue, \
               'Value must be a valid nick or the empty string.'
     registry.String.setValue(self, v)
开发者ID:Athemis,项目名称:Limnoria,代码行数:5,代码来源:config.py

示例15: testIsNick

 def testIsNick(self):
     try:
         original = conf.supybot.protocols.irc.strictRfc()
         conf.supybot.protocols.irc.strictRfc.setValue(True)
         self.failUnless(ircutils.isNick('jemfinch'))
         self.failUnless(ircutils.isNick('jemfinch0'))
         self.failUnless(ircutils.isNick('[0]'))
         self.failUnless(ircutils.isNick('{jemfinch}'))
         self.failUnless(ircutils.isNick('[jemfinch]'))
         self.failUnless(ircutils.isNick('jem|finch'))
         self.failUnless(ircutils.isNick('\\```'))
         self.failUnless(ircutils.isNick('`'))
         self.failUnless(ircutils.isNick('A'))
         self.failIf(ircutils.isNick(''))
         self.failIf(ircutils.isNick('8foo'))
         self.failIf(ircutils.isNick('10'))
         self.failIf(ircutils.isNick('-'))
         self.failIf(ircutils.isNick('-foo'))
         conf.supybot.protocols.irc.strictRfc.setValue(False)
         self.failUnless(ircutils.isNick('[email protected]'))
     finally:
         conf.supybot.protocols.irc.strictRfc.setValue(original)
开发者ID:krattai,项目名称:AEBL,代码行数:22,代码来源:test_ircutils.py


注:本文中的supybot.ircutils.isNick函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。