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


Python ircutils.isUserHostmask函数代码示例

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


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

示例1: doMode

 def doMode(self, irc, msg):
     channel = msg.args[0]
     chanOp = ircdb.makeChannelCapability(channel, 'op')
     chanVoice = ircdb.makeChannelCapability(channel, 'voice')
     chanHalfOp = ircdb.makeChannelCapability(channel, 'halfop')
     if not ircdb.checkCapability(msg.prefix, chanOp):
         irc.sendMsg(ircmsgs.deop(channel, msg.nick))
     for (mode, value) in ircutils.separateModes(msg.args[1:]):
         if not value:
             continue
         if ircutils.strEqual(value, msg.nick):
             # We allow someone to mode themselves to oblivion.
             continue
         if irc.isNick(value):
             hostmask = irc.state.nickToHostmask(value)
             if mode == '+o':
                 if not self.isOp(irc, channel, hostmask):
                     irc.queueMsg(ircmsgs.deop(channel, value))
             elif mode == '+h':
                 if not ircdb.checkCapability(hostmask, chanHalfOp):
                      irc.queueMsg(ircmsgs.dehalfop(channel, value))
             elif mode == '+v':
                 if not ircdb.checkCapability(hostmask, chanVoice):
                     irc.queueMsg(ircmsgs.devoice(channel, value))
             elif mode == '-o':
                 if ircdb.checkCapability(hostmask, chanOp):
                     irc.queueMsg(ircmsgs.op(channel, value))
             elif mode == '-h':
                 if ircdb.checkCapability(hostmask, chanOp):
                     irc.queueMsg(ircmsgs.halfop(channel, value))
             elif mode == '-v':
                 if ircdb.checkCapability(hostmask, chanOp):
                     irc.queueMsg(ircmsgs.voice(channel, value))
         else:
             assert ircutils.isUserHostmask(value)
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:35,代码来源:plugin.py

示例2: addHostmask

 def addHostmask(self, hostmask):
     """Adds a hostmask to the user's hostmasks."""
     assert ircutils.isUserHostmask(hostmask), 'got %s' % hostmask
     if len(unWildcardHostmask(hostmask)) < 8:
         raise ValueError, \
               'Hostmask must contain at least 8 non-wildcard characters.'
     self.hostmasks.add(hostmask)
开发者ID:Elwell,项目名称:supybot,代码行数:7,代码来源:ircdb.py

示例3: add

        def add(self, irc, msg, args, user, hostmask, password):
            """[<name>] [<hostmask>] [<password>]

            Adds the hostmask <hostmask> to the user specified by <name>.  The
            <password> may only be required if the user is not recognized by
            hostmask.  <password> is also not required if an owner user is
            giving the command on behalf of some other user.  If <hostmask> is
            not given, it defaults to your current hostmask.  If <name> is not
            given, it defaults to your currently identified name.  This message
            must be sent to the bot privately (not on a channel) since it may
            contain a password.
            """
            caller_is_owner = ircdb.checkCapability(msg.prefix, 'owner')
            if not hostmask:
                hostmask = msg.prefix
            if not ircutils.isUserHostmask(hostmask):
                irc.errorInvalid(_('hostmask'), hostmask,
                                 _('Make sure your hostmask includes a nick, '
                                 'then an exclamation point (!), then a user, '
                                 'then an at symbol (@), then a host.  Feel '
                                 'free to use wildcards (* and ?, which work '
                                 'just like they do on the command line) in '
                                 'any of these parts.'),
                                 Raise=True)
            try:
                otherId = ircdb.users.getUserId(hostmask)
                if otherId != user.id:
                    if caller_is_owner:
                        err = _('That hostmask is already registered to %s.')
                        err %= otherId
                    else:
                        err = _('That hostmask is already registered.')
                    irc.error(err, Raise=True)
            except KeyError:
                pass
            if not user.checkPassword(password) and \
               not user.checkHostmask(msg.prefix) and \
               not caller_is_owner:
                    irc.error(conf.supybot.replies.incorrectAuthentication(),
                              Raise=True)
            try:
                user.addHostmask(hostmask)
            except ValueError as e:
                irc.error(str(e), Raise=True)
            try:
                ircdb.users.setUser(user)
            except ircdb.DuplicateHostmask as e:
                user.removeHostmask(hostmask)
                if caller_is_owner:
                    err = _('That hostmask is already registered to %s.') \
                              % e.args[0]
                else:
                    err = _('That hostmask is already registered.')
                irc.error(err, Raise=True)
            except ValueError as e:
                irc.error(str(e), Raise=True)
            irc.replySuccess()
开发者ID:Hoaas,项目名称:Limnoria,代码行数:57,代码来源:plugin.py

示例4: _getId

 def _getId(self, irc, userNickHostmask):
     try:
         id = ircdb.users.getUserId(userNickHostmask)
     except KeyError:
         if not ircutils.isUserHostmask(userNickHostmask):
             hostmask = irc.state.nickToHostmask(userNickHostmask)
             id = ircdb.users.getUserId(hostmask)
         else:
             raise KeyError
     return id
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:10,代码来源:plugin.py

示例5: getHostmask

def getHostmask(irc, msg, args, state):
    if ircutils.isUserHostmask(args[0]) or (not conf.supybot.protocols.irc.strictRfc() and args[0].startswith("$")):
        state.args.append(args.pop(0))
    else:
        try:
            hostmask = irc.state.nickToHostmask(args[0])
            state.args.append(hostmask)
            del args[0]
        except KeyError:
            state.errorInvalid(_("nick or hostmask"), args[0])
开发者ID:yenatch,项目名称:Limnoria,代码行数:10,代码来源:commands.py

示例6: getHostmask

def getHostmask(irc, msg, args, state):
    if ircutils.isUserHostmask(args[0]):
        state.args.append(args.pop(0))
    else:
        try:
            hostmask = irc.state.nickToHostmask(args[0])
            state.args.append(hostmask)
            del args[0]
        except KeyError:
            state.errorInvalid(_('nick or hostmask'), args[0])
开发者ID:boamaod,项目名称:Limnoria,代码行数:10,代码来源:commands.py

示例7: testHostmaskPatternEqual

 def testHostmaskPatternEqual(self):
     for msg in msgs:
         if msg.prefix and ircutils.isUserHostmask(msg.prefix):
             s = msg.prefix
             self.failUnless(ircutils.hostmaskPatternEqual(s, s), "%r did not match itself." % s)
             banmask = ircutils.banmask(s)
             self.failUnless(ircutils.hostmaskPatternEqual(banmask, s), "%r did not match %r" % (s, banmask))
     s = "[email protected]"
     self.failUnless(ircutils.hostmaskPatternEqual(s, s))
     s = "jamessan|[email protected]" "abr-ubr1.sbo-abr.ma.cable.rcn.com"
     self.failUnless(ircutils.hostmaskPatternEqual(s, s))
开发者ID:ProgVal,项目名称:Limnoria,代码行数:11,代码来源:test_ircutils.py

示例8: testBanmask

 def testBanmask(self):
     for msg in msgs:
         if ircutils.isUserHostmask(msg.prefix):
             banmask = ircutils.banmask(msg.prefix)
             self.failUnless(
                 ircutils.hostmaskPatternEqual(banmask, msg.prefix), "%r didn't match %r" % (msg.prefix, banmask)
             )
     self.assertEqual(ircutils.banmask("[email protected]"), "*!*@host")
     self.assertEqual(ircutils.banmask("[email protected]"), "*!*@host.tld")
     self.assertEqual(ircutils.banmask("[email protected]"), "*!*@*.host.tld")
     self.assertEqual(ircutils.banmask("[email protected]::"), "*!*@2001::*")
开发者ID:ProgVal,项目名称:Limnoria,代码行数:11,代码来源:test_ircutils.py

示例9: isImmune

 def isImmune(self, irc, msg):
     if not ircutils.isUserHostmask(msg.prefix):
         self.log.debug('%q is immune, it\'s a server.', msg)
         return True # It's a server prefix.
     if ircutils.strEqual(msg.nick, irc.nick):
         self.log.debug('%q is immune, it\'s me.', msg)
         return True # It's the bot itself.
     if msg.nick in self.registryValue('immune', msg.args[0]):
         self.log.debug('%q is immune, it\'s configured to be immune.', msg)
         return True
     return False
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:11,代码来源:plugin.py

示例10: doAccount

	def doAccount (self,irc,msg):
		if ircutils.isUserHostmask(msg.prefix):
			nick = ircutils.nickFromHostmask(msg.prefix)
			for channel in irc.state.channels:
				chan = self.getChan(irc,channel)
				if nick in chan.nicks:
					a = chan.nicks[nick]
					account = msg.args[0]
					if account == '*':
						account = ''
					a[1] = account
					chan.nicks[nick] = a
开发者ID:ncoevoet,项目名称:ChanReg,代码行数:12,代码来源:plugin.py

示例11: checkBan

 def checkBan(self, hostmask):
     """Checks whether a given hostmask is banned by the channel banlist."""
     assert ircutils.isUserHostmask(hostmask), 'got %s' % hostmask
     now = time.time()
     for (pattern, expiration) in self.bans.items():
         if now < expiration or not expiration:
             if ircutils.hostmaskPatternEqual(pattern, hostmask):
                 return True
         else:
             self.expiredBans.append((pattern, expiration))
             del self.bans[pattern]
     return False
开发者ID:Elwell,项目名称:supybot,代码行数:12,代码来源:ircdb.py

示例12: testBanmask

 def testBanmask(self):
     for msg in msgs:
         if ircutils.isUserHostmask(msg.prefix):
             banmask = ircutils.banmask(msg.prefix)
             self.failUnless(ircutils.hostmaskPatternEqual(banmask,
                                                           msg.prefix),
                             '%r didn\'t match %r' % (msg.prefix, banmask))
     self.assertEqual(ircutils.banmask('[email protected]'), '*!*@host')
     self.assertEqual(ircutils.banmask('[email protected]'),
                      '*!*@host.tld')
     self.assertEqual(ircutils.banmask('[email protected]'),
                      '*!*@*.host.tld')
     self.assertEqual(ircutils.banmask('[email protected]::'), '*!*@2001::*')
开发者ID:krattai,项目名称:AEBL,代码行数:13,代码来源:test_ircutils.py

示例13: proxyuser

	def proxyuser (self,irc,msg,args,nick):
		"""<nick|ip> 
		check<nick|ip>  against configured DNSBLS"""
		if ircutils.isUserHostmask(nick)
			h = irc.state.nickToHostmask(nick)
			(n,i,h) = ircutils.splitHostmask(h)
		else:
			h = nick
		check = self.check(h,'')
		if check and len(check):
			irc.reply(', '.join(check))
		else:
			irc.reply('%s is clean' % nick)
开发者ID:ProgVal,项目名称:ProxyCheck,代码行数:13,代码来源:plugin.py

示例14: getOtherUser

def getOtherUser(irc, msg, args, state):
    if ircutils.isUserHostmask(args[0]):
        state.errorNoUser(args[0])
    try:
        state.args.append(ircdb.users.getUser(args[0]))
        del args[0]
    except KeyError:
        try:
            getHostmask(irc, msg, [args[0]], state)
            hostmask = state.args.pop()
            state.args.append(ircdb.users.getUser(hostmask))
            del args[0]
        except (KeyError, callbacks.Error):
            state.errorNoUser(name=args[0])
开发者ID:Kefkius,项目名称:mazabot,代码行数:14,代码来源:commands.py

示例15: checkIgnored

 def checkIgnored(self, hostmask):
     """Checks whether a given hostmask is to be ignored by the channel."""
     if self.lobotomized:
         return True
     if world.testing:
         return False
     assert ircutils.isUserHostmask(hostmask), 'got %s' % hostmask
     if self.checkBan(hostmask):
         return True
     now = time.time()
     for (pattern, expiration) in self.ignores.items():
         if now < expiration or not expiration:
             if ircutils.hostmaskPatternEqual(pattern, hostmask):
                 return True
         else:
             del self.ignores[pattern]
             # Later we may wish to keep expiredIgnores, but not now.
     return False
开发者ID:Elwell,项目名称:supybot,代码行数:18,代码来源:ircdb.py


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