本文整理汇总了Python中supybot.ircutils.hostmaskPatternEqual函数的典型用法代码示例。如果您正苦于以下问题:Python hostmaskPatternEqual函数的具体用法?Python hostmaskPatternEqual怎么用?Python hostmaskPatternEqual使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hostmaskPatternEqual函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _kban
def _kban(self, irc, msg, args, bannedNick, reason):
# Check that they're not trying to make us kickban ourself.
channel = msg.args[0]
if not irc.isNick(bannedNick[0]):
self.log.warning('%q tried to kban a non nick: %q',
msg.prefix, bannedNick)
raise callbacks.ArgumentError
elif bannedNick == irc.nick:
self.log.warning('%q tried to make me kban myself.', msg.prefix)
irc.error('I cowardly refuse to kickban myself.')
return
if not reason:
reason = msg.nick
try:
bannedHostmask = irc.state.nickToHostmask(bannedNick)
except KeyError:
irc.error(format('I haven\'t seen %s.', bannedNick), Raise=True)
capability = ircdb.makeChannelCapability(channel, 'op')
banmaskstyle = conf.supybot.protocols.irc.banmask
banmask = banmaskstyle.makeBanmask(bannedHostmask, ["host", "user"])
# Check (again) that they're not trying to make us kickban ourself.
if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
if ircutils.hostmaskPatternEqual(bannedHostmask, irc.prefix):
self.log.warning('%q tried to make me kban myself.',msg.prefix)
irc.error('I cowardly refuse to ban myself.')
return
else:
self.log.warning('Using exact hostmask since banmask would '
'ban myself.')
banmask = bannedHostmask
# Now, let's actually get to it. Check to make sure they have
# #channel,op and the bannee doesn't have #channel,op; or that the
# bannee and the banner are both the same person.
def doBan():
if irc.state.channels[channel].isOp(bannedNick):
irc.queueMsg(ircmsgs.deop(channel, bannedNick))
irc.queueMsg(ircmsgs.ban(channel, banmask))
irc.queueMsg(ircmsgs.kick(channel, bannedNick, reason))
def f():
if channel in irc.state.channels and \
banmask in irc.state.channels[channel].bans:
irc.queueMsg(ircmsgs.unban(channel, banmask))
schedule.addEvent(f, 3600)
if bannedNick == msg.nick:
doBan()
elif ircdb.checkCapability(msg.prefix, capability):
if ircdb.checkCapability(bannedHostmask, capability):
self.log.warning('%s tried to ban %q, but both have %s',
msg.prefix, bannedHostmask, capability)
irc.error(format('%s has %s too, you can\'t ban him/her/it.',
bannedNick, capability))
else:
doBan()
else:
self.log.warning('%q attempted kban without %s',
msg.prefix, capability)
irc.errorNoCapability(capability)
exact,nick,user,host
开发者ID:kyl191,项目名称:aurora,代码行数:58,代码来源:plugin.py
示例2: checkIgnored
def checkIgnored(self, prefix):
now = time.time()
mask = getmask(prefix)
for (hostmask, expiration) in self.hostmasks.items():
if expiration and now > expiration:
del self.hostmasks[hostmask]
else:
if ircutils.hostmaskPatternEqual(hostmask, prefix) or ircutils.hostmaskPatternEqual(hostmask, mask):
return True
return False
开发者ID:jrabbit,项目名称:ubotu-fr,代码行数:10,代码来源:ircdb.py
示例3: 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
示例4: 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()
mask = getmask(hostmask)
for (pattern, expiration) in self.bans.items():
if now < expiration or not expiration:
if ircutils.hostmaskPatternEqual(pattern, hostmask) or ircutils.hostmaskPatternEqual(pattern, mask):
return True
else:
self.expiredBans.append((pattern, expiration))
del self.bans[pattern]
return False
开发者ID:jrabbit,项目名称:ubotu-fr,代码行数:13,代码来源:ircdb.py
示例5: setUser
def setUser(self, user, flush=True):
"""Sets a user (given its id) to the IrcUser given it."""
self.nextId = max(self.nextId, user.id)
try:
if self.getUserId(user.name) != user.id:
raise DuplicateHostmask, hostmask
except KeyError:
pass
for hostmask in user.hostmasks:
for (i, u) in self.iteritems():
if i == user.id:
continue
elif u.checkHostmask(hostmask):
# We used to remove the hostmask here, but it's not
# appropriate for us both to remove the hostmask and to
# raise an exception. So instead, we'll raise an
# exception, but be nice and give the offending hostmask
# back at the same time.
raise DuplicateHostmask, hostmask
for otherHostmask in u.hostmasks:
if ircutils.hostmaskPatternEqual(hostmask, otherHostmask):
raise DuplicateHostmask, hostmask
self.invalidateCache(user.id)
self.users[user.id] = user
if flush:
self.flush()
开发者ID:Elwell,项目名称:supybot,代码行数:26,代码来源:ircdb.py
示例6: doPrivmsg
def doPrivmsg(self, irc, msg):
if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
return
(channel, text) = msg.args
if irc.isChannel(channel):
irc = self._getRealIrc(irc)
if channel not in self.registryValue('channels'):
return
ignores = self.registryValue('ignores', channel)
for ignore in ignores:
if ircutils.hostmaskPatternEqual(ignore, msg.prefix):
self.log.debug('Refusing to relay %s, ignored by %s.',
msg.prefix, ignore)
return
# Let's try to detect other relay bots.
if self._checkRelayMsg(msg):
if self.registryValue('punishOtherRelayBots', channel):
self._punishRelayers(msg)
# Either way, we don't relay the message.
else:
self.log.warning('Refusing to relay message from %s, '
'it appears to be a relay message.',
msg.prefix)
else:
network = self._getIrcName(irc)
s = self._formatPrivmsg(msg.nick, network, msg)
m = self._msgmaker(channel, s)
self._sendToOthers(irc, m)
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:28,代码来源:plugin.py
示例7: doPrivmsg
def doPrivmsg(self, irc, msg):
channel, text = msg.args
text = text.lower()
if '#' in channel:
#print self.regex
#irc.reply('testing %s against %s' % (text, self._regexString))
if self.regex.match(text):
try:
hostmask = irc.state.nickToHostmask(msg.nick)
except KeyError:
return
(nick, user, host) = ircutils.splitHostmask(hostmask)
user = self._fnUser.sub('*', user)
banmask = ircutils.joinHostmask('*', user, msg.host)
if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
return
irc.queueMsg(ban(channel, banmask, 'For swearing. 5 minute timeout'))
irc.queueMsg(kick(channel, msg.nick, 'For swearing'))
def unBan():
if channel in irc.state.channels and \
banmask in irc.state.channels[channel].bans:
irc.queueMsg(unban(channel, banmask))
schedule.addEvent(unBan, time.time()+300)
elif 'fag' in text.split():
try:
hostmask = irc.state.nickToHostmask(msg.nick)
except KeyError:
return
(nick, user, host) = ircutils.splitHostmask(hostmask)
irc.reply('No thanks %s I don\'t smoke' % user)
return msg
开发者ID:chan-jesus,项目名称:no-cussing-supybot-plugin,代码行数:31,代码来源:plugin.py
示例8: unban
def unban(self, irc, msg, args, channel, hostmask):
"""[<channel>] [<hostmask|--all>]
Unbans <hostmask> on <channel>. If <hostmask> is not given, unbans
any hostmask currently banned on <channel> that matches your current
hostmask. Especially useful for unbanning yourself when you get
unexpectedly (or accidentally) banned from the channel. <channel> is
only necessary if the message isn't sent in the channel itself.
"""
if hostmask == '--all':
bans = irc.state.channels[channel].bans
self._sendMsg(irc, ircmsgs.unbans(channel, bans))
elif hostmask:
self._sendMsg(irc, ircmsgs.unban(channel, hostmask))
else:
bans = []
for banmask in irc.state.channels[channel].bans:
if ircutils.hostmaskPatternEqual(banmask, msg.prefix):
bans.append(banmask)
if bans:
irc.queueMsg(ircmsgs.unbans(channel, bans))
irc.replySuccess(format(_('All bans on %s matching %s '
'have been removed.'),
channel, msg.prefix))
else:
irc.error(_('No bans matching %s were found on %s.') %
(msg.prefix, channel))
开发者ID:Ban3,项目名称:Limnoria,代码行数:27,代码来源:plugin.py
示例9: hostmaskPatternEqual
def hostmaskPatternEqual(pattern, hostmask):
if pattern.count('!') != 1 or pattern.count('@') != 1:
return False
if pattern.count('$') == 1:
pattern = pattern.split('$',1)[0]
if pattern.startswith('%'):
pattern = pattern[1:]
return ircutils.hostmaskPatternEqual(pattern, hostmask)
开发者ID:Affix,项目名称:Fedbot,代码行数:8,代码来源:plugin.py
示例10: rroulette
def rroulette(self, irc, msg, args, spin):
"""[spin]
Fires the revolver. If the bullet was in the chamber, you're dead.
Tell me to spin the chambers and I will.
"""
if spin:
self._rouletteBullet = random.randrange(0, 6)
irc.reply('*SPIN* Are you feeling lucky?', prefixNick=False)
return
channel = msg.args[0]
if self._rouletteChamber == self._rouletteBullet:
self._rouletteBullet = random.randrange(0, 6)
self._rouletteChamber = random.randrange(0, 6)
if irc.nick in irc.state.channels[channel].ops or irc.nick in irc.state.channels[channel].halfops:
try:
bannedHostmask = irc.state.nickToHostmask(msg.nick)
except KeyError:
irc.error(format('I haven\'t seen %s.', msg.nick), Raise=True)
banmaskstyle = conf.supybot.protocols.irc.banmask
banmask = banmaskstyle.makeBanmask(bannedHostmask, ["nick", "host"])
if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
if ircutils.hostmaskPatternEqual(bannedHostmask, irc.prefix):
self.log.warning('%q played rroulette, but he\'s got the same hostmask as me, strangely enough.',msg.prefix)
irc.error('I\'m not playing this game.')
return
else:
self.log.warning('Using exact hostmask since banmask would '
'ban myself.')
banmask = bannedHostmask
def f():
if channel in irc.state.channels and banmask in irc.state.channels[channel].bans:
irc.queueMsg(ircmsgs.unban(channel, banmask))
schedule.addEvent(f, 60)
irc.queueMsg(ircmsgs.ban(channel, banmask))
irc.queueMsg(ircmsgs.kick(channel, msg.nick, 'BANG!'))
else:
irc.reply('*BANG* Hey, who put a blank in here?!',
prefixNick=False)
irc.reply('reloads and spins the chambers.', action=True)
else:
irc.reply('*click*')
self._rouletteChamber += 1
self._rouletteChamber %= 6
开发者ID:kyl191,项目名称:aurora,代码行数:44,代码来源:plugin.py
示例11: 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
示例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: doPrivmsg
def doPrivmsg(self, irc, msg):
notes = self._notes.pop(msg.nick, [])
# Let's try wildcards.
removals = []
for wildcard in self.wildcards:
if ircutils.hostmaskPatternEqual(wildcard, msg.nick):
removals.append(wildcard)
notes.extend(self._notes.pop(wildcard))
for removal in removals:
self.wildcards.remove(removal)
if notes:
irc = callbacks.SimpleProxy(irc, msg)
private = self.registryValue('private')
for (when, whence, note) in notes:
s = self._formatNote(when, whence, note)
irc.reply(s, private=private)
self._flushNotes()
开发者ID:Kefkius,项目名称:mazabot,代码行数:17,代码来源:plugin.py
示例14: doJoin
def doJoin(self, irc, msg):
channel = ircutils.toLower(msg.args[0])
mynick = irc.nick
user = msg.nick
hostname = irc.state.nickToHostmask(user)
if not ircutils.strEqual(irc.nick, msg.nick): # not me joining.
if channel in self._channels.keys(): # do we have a matching channel?
if irc.state.channels[channel].isOp(mynick): # am I an op?
for (hostmask, username) in self._channels[channel]:
if ircutils.hostmaskPatternEqual(hostmask, hostname): # do we have a matching user?
self.log.info("{0} matched {1} in {2} on username {3}. Sending ZNC challenge.".format(hostmask, user, channel, username))
challenge = self._zncchallenge()
self._challenges[user][channel] = (time.time() + 60, challenge, username)
challenge = "!ZNCAO CHALLENGE {0}".format(challenge)
def sendNotice(): # for the delayed send.
irc.queueMsg(ircmsgs.notice(user, challenge))
schedule.addEvent(sendNotice, (time.time() + choice(range(2, 6))))
break
开发者ID:reticulatingspline,项目名称:ZNC,代码行数:18,代码来源:plugin.py
示例15: callCommand
def callCommand(self, command, irc, msg, *args, **kwargs):
if conf.supybot.abuse.flood.ctcp():
now = time.time()
for (ignore, expiration) in self.ignores.items():
if expiration < now:
del self.ignores[ignore]
elif ircutils.hostmaskPatternEqual(ignore, msg.prefix):
return
self.floods.enqueue(msg)
max = conf.supybot.abuse.flood.ctcp.maximum()
if self.floods.len(msg) > max:
expires = conf.supybot.abuse.flood.ctcp.punishment()
self.log.warning('Apparent CTCP flood from %s, '
'ignoring CTCP messages for %s seconds.',
msg.prefix, expires)
ignoreMask = '*!%[email protected]%s' % (msg.user, msg.host)
self.ignores[ignoreMask] = now + expires
return
self.__parent.callCommand(command, irc, msg, *args, **kwargs)
开发者ID:Athemis,项目名称:Limnoria,代码行数:19,代码来源:plugin.py
示例16: getHostFromBan
def getHostFromBan(self, irc, msg, mask):
if irc not in self.lastStates:
self.lastStates[irc] = irc.state.copy()
if mask[0] == '%':
mask = mask[1:]
try:
(nick, ident, host) = ircutils.splitHostmask(mask)
except AssertionError:
# not a hostmask
return None
channel = None
chan = None
if mask[0] not in ('*', '?'): # Nick ban
if nick in self.nicks:
return self.nicks[nick]
else: # Host/ident ban
for (inick, ihost) in self.nicks.iteritems():
if ircutils.hostmaskPatternEqual(mask, ihost):
return ihost
return None
开发者ID:Affix,项目名称:Fedbot,代码行数:20,代码来源:plugin.py
示例17: _ban
def _ban(self, irc, nick, channel):
try:
hostmask = irc.state.nickToHostmask(nick)
except KeyError:
return
(nick, user, host) = ircutils.splitHostmask(hostmask)
user = self._fnUser.sub('*', user)
banmask = ircutils.joinHostmask('*', user, host)
if ircutils.hostmaskPatternEqual(banmask, irc.prefix):
return
irc.queueMsg(ircmsgs.ban(channel, banmask))
irc.queueMsg(ircmsgs.kick(channel, nick))
expiry = self.registryValue('autokban.timeout', channel)
if expiry > 0:
expiry += time.time()
def f():
if channel in irc.state.channels and \
banmask in irc.state.channels[channel].bans:
irc.queueMsg(ircmsgs.unban(channel, banmask))
schedule.addEvent(f, expiry)
开发者ID:D0MF,项目名称:supybot-plugins-1,代码行数:20,代码来源:plugin.py
示例18: lastlojban
def lastlojban(self, irc, msg, args, channel, nick, percent):
"""[channel] [nick] [percent]
Get the last Lojban message as determined by potential-percentage.
"""
if not percent:
percent = 40
for ircmsg in reversed(irc.state.history):
if ircmsg.command == 'PRIVMSG':
msgs = [ircmsg.args[1]]
if '{' in msgs[0]:
msgs = reversed(list(re.findall(r'\{(.+?)\}', msgs[0])))
for imsg in msgs:
if self._cenlai(imsg) >= percent:
if not channel or \
ircutils.strEqual(channel, ircmsg.args[0]):
if not nick or \
ircutils.hostmaskPatternEqual(nick,
ircmsg.nick):
irc.reply(imsg)
return
开发者ID:dag,项目名称:makfa,代码行数:21,代码来源:plugin.py
示例19: checkHostmask
def checkHostmask(self, hostmask, useAuth=True):
"""Checks a given hostmask against the user's hostmasks or current
authentication. If useAuth is False, only checks against the user's
hostmasks.
"""
if useAuth:
timeout = conf.supybot.databases.users.timeoutIdentification()
removals = []
try:
for (when, authmask) in self.auth:
if timeout and when+timeout < time.time():
removals.append((when, authmask))
elif hostmask == authmask:
return True
finally:
while removals:
self.auth.remove(removals.pop())
for pat in self.hostmasks:
if ircutils.hostmaskPatternEqual(pat, hostmask):
return pat
return False
开发者ID:Elwell,项目名称:supybot,代码行数:21,代码来源:ircdb.py
示例20: doPrivmsg
def doPrivmsg(self, irc, msg):
if ircmsgs.isCtcp(msg) and not ircmsgs.isAction(msg):
return
notes = self._notes.pop(msg.nick, [])
# Let's try wildcards.
removals = []
for wildcard in self.wildcards:
if ircutils.hostmaskPatternEqual(wildcard, msg.nick):
removals.append(wildcard)
notes.extend(self._notes.pop(wildcard))
for removal in removals:
self.wildcards.remove(removal)
if notes:
old_repliedto = msg.repliedTo
irc = callbacks.SimpleProxy(irc, msg)
private = self.registryValue('private')
for (when, whence, note) in notes:
s = self._formatNote(when, whence, note)
irc.reply(s, private=private, prefixNick=not private)
self._flushNotes()
msg.repliedTo = old_repliedto
开发者ID:carriercomm,项目名称:Limnoria,代码行数:21,代码来源:plugin.py
注:本文中的supybot.ircutils.hostmaskPatternEqual函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论