• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ircutils.isNick函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: reviewBans

    def reviewBans(self, irc=None):
        reviewTime = int(self.registryValue('request.review') * 86400)
        if not reviewTime:
            # time is zero, do nothing
            return
        now = time.mktime(time.gmtime())
        lastreview = self.pendingReviews.time
        self.pendingReviews.time = now # update last time reviewed
        if not lastreview:
            # initialize last time reviewed timestamp
            lastreview = now - reviewTime

        for channel, bans in self.bans.iteritems():
            if not self.registryValue('enabled', channel) \
                    or not self.registryValue('request', channel):
                continue

            for ban in bans:
                if guessBanType(ban.mask) in ('quiet', 'removal'):
                    # skip mutes and kicks
                    continue
                banAge = now - ban.when
                reviewWindow = lastreview - ban.when
                #self.log.debug('review ban: %s ban %s by %s (%s/%s/%s %s)', channel, ban.mask,
                #        ban.who, reviewWindow, reviewTime, banAge, reviewTime - reviewWindow)
                if reviewWindow <= reviewTime < banAge:
                    # ban is old enough, and inside the "review window"
                    try:
                        # ban.who should be a user hostmask
                        nick = ircutils.nickFromHostmask(ban.who)
                        host = ircutils.hostFromHostmask(ban.who)
                    except:
                        if ircutils.isNick(ban.who, strictRfc=True):
                            # ok, op's nick, use it
                            nick = ban.who
                            host = None
                        else:
                            # probably a ban restored by IRC server in a netsplit
                            # XXX see if something can be done about this
                            continue
                    if nickMatch(nick, self.registryValue('request.ignore', channel)):
                        # in the ignore list
                        continue
                    if not ban.id:
                        ban.id = self.get_banId(ban.mask, channel)
                    if nickMatch(nick, self.registryValue('request.forward', channel)):
                        s = "Hi, please somebody review the ban '%s' set by %s on %s in"\
                        " %s, link: %s/bans.cgi?log=%s" %(ban.mask, nick, ban.ascwhen, channel,
                                self.registryValue('bansite'), ban.id)
                        self._sendForward(irc, s, channel)
                    else:
                        s = "Hi, please review the ban '%s' that you set on %s in %s, link:"\
                        " %s/bans.cgi?log=%s" %(ban.mask, ban.ascwhen, channel,
                                self.registryValue('bansite'), ban.id)
                        msg = ircmsgs.privmsg(nick, s)
                        if host in self.pendingReviews \
                            and (nick, msg) not in self.pendingReviews[host]:
                            self.pendingReviews[host].append((nick, msg))
                        else:
                            self.pendingReviews[host] = [(nick, msg)]
                elif banAge < reviewTime:
                    # since we made sure bans are sorted by time, the bans left are more recent
                    break
开发者ID:Affix,项目名称:Fedbot,代码行数:63,代码来源:plugin.py


示例17: setValue

 def setValue(self, v):
     if not ircutils.isNick(v):
         self.error()
     else:
         registry.String.setValue(self, v)
开发者ID:Kefkius,项目名称:mazabot,代码行数:5,代码来源:conf.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ircutils.isUserHostmask函数代码示例发布时间:2022-05-27
下一篇:
Python ircutils.isChannel函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap