本文整理汇总了Python中supybot.ircmsgs.unban函数的典型用法代码示例。如果您正苦于以下问题:Python unban函数的具体用法?Python unban怎么用?Python unban使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unban函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unban
def unban():
try:
if msg.prefix in irc.state.channels[channel].bans:
irc.queueMsg(ircmsgs.unban(channel, msg.prefix))
except KeyError:
# We're not in the channel anymore.
pass
示例2: 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))
示例3: testBaninfo
def testBaninfo(self):
cb = self.getCallback()
self.feedBan('asd!*@*')
self.assertResponse('duration 1',
"[1] ban - asd!*@* - #test - never expires")
self.assertNotError('duration 1 10')
self.assertResponse('duration 1',
"[1] ban - asd!*@* - #test - expires soon")
self.assertNotError('duration 1 34502')
self.assertResponse('duration 1',
"[1] ban - asd!*@* - #test - expires in 9 hours and 35 minutes")
self.irc.feedMsg(ircmsgs.unban(self.channel, 'asd!*@*',
'[email protected]'))
self.assertResponse('duration 1',
"[1] ban - asd!*@* - #test - not active")
示例4: un
def un():
irc.queueMsg(ircmsgs.unban(msg.args[0],msg.nick))
示例5: testDurationInactiveBan
def testDurationInactiveBan(self):
self.feedBan('asd!*@*')
self.irc.feedMsg(ircmsgs.unban(self.channel, 'asd!*@*',
'[email protected]'))
self.assertResponse('duration 1 1',
"Failed to set duration time on 1 (ban was removed)")
示例6: unBan
def unBan():
if channel in irc.state.channels and \
banmask in irc.state.channels[channel].bans:
irc.queueMsg(unban(channel, banmask))
示例7: _slot
def _slot(self, lastItem):
irc = lastItem.irc
msg = lastItem.msg
channel = lastItem.channel
prefix = lastItem.prefix
nick = prefix.split('!')[0]
kind = lastItem.kind
if not ircutils.isChannel(channel):
return
if not self.registryValue('enable', channel):
return
try:
ircdb.users.getUser(msg.prefix) # May raise KeyError
capability = self.registryValue('exempt')
if capability:
if ircdb.checkCapability(msg.prefix,
','.join([channel, capability])):
self.log.info('Not punishing %s: they are immune.' %
prefix)
return
except KeyError:
pass
punishment = self.registryValue('%s.punishment' % kind, channel)
reason = self.registryValue('%s.kickmessage' % kind, channel)
if not reason:
reason = self.registryValue('kickmessage').replace('$kind', kind)
if punishment == 'kick':
self._eventCatcher(irc, msg, 'kicked', kicked_prefix=prefix)
if kind == 'kicked':
reason = _('You exceeded your kick quota.')
banmaskstyle = conf.supybot.protocols.irc.banmask
banmask = banmaskstyle.makeBanmask(prefix)
if punishment == 'kick':
msg = ircmsgs.kick(channel, nick, reason)
irc.queueMsg(msg)
elif punishment.startswith('ban'):
msg = ircmsgs.ban(channel, banmask)
irc.queueMsg(msg)
if punishment.startswith('ban+'):
delay = int(punishment[4:])
unban = functools.partial(irc.queueMsg,
ircmsgs.unban(channel, banmask))
schedule.addEvent(unban, delay + time.time())
elif punishment.startswith('kban'):
msg = ircmsgs.ban(channel, banmask)
irc.queueMsg(msg)
msg = ircmsgs.kick(channel, nick, reason)
irc.queueMsg(msg)
if punishment.startswith('kban+'):
delay = int(punishment[5:])
unban = functools.partial(irc.queueMsg,
ircmsgs.unban(channel, banmask))
schedule.addEvent(unban, delay + time.time())
elif punishment.startswith('mode'):
msg = ircmsgs.mode(channel, punishment[len('mode'):])
irc.queueMsg(msg)
elif punishment.startswith('umode'):
msg = ircmsgs.mode(channel, (punishment[len('umode'):], msg.nick))
irc.queueMsg(msg)
elif punishment.startswith('mmode'):
msg = ircmsgs.mode(channel, (punishment[len('mmode'):], banmask))
irc.queueMsg(msg)
elif punishment.startswith('command '):
tokens = callbacks.tokenize(punishment[len('command '):])
self.Proxy(irc, msg, tokens)
示例8: testUnban
def testUnban(self):
channel = '#supybot'
ban = '[email protected]'
self.assertEqual(str(ircmsgs.unban(channel, ban)),
'MODE %s -b :%s\r\n' % (channel, ban))
示例9: unban
def unban():
irc.queueMsg(ircmsgs.unban(channel, hostmask))