本文整理汇总了Python中supybot.ircmsgs.kick函数的典型用法代码示例。如果您正苦于以下问题:Python kick函数的具体用法?Python kick怎么用?Python kick使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了kick函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _slot
def _slot(self, lastItem):
irc = lastItem.irc
msg = lastItem.msg
channel = lastItem.channel
prefix = lastItem.prefix
nick = prefix.split('!')[0]
kind = lastItem.kind
try:
ircdb.users.getUser(msg.prefix) # May raise KeyError
capability = self.registryValue('exempt')
if capability:
if ircdb.checkCapability(msg.prefix, capability):
return
except KeyError:
pass
punishment = self.registryValue('%s.punishment' % kind, channel)
reason = _('%s flood detected') % kind
if punishment == 'kick':
msg = ircmsgs.kick(channel, nick, reason)
irc.queueMsg(msg)
elif punishment == 'ban':
msg = ircmsgs.ban(channel, prefix)
irc.queueMsg(msg)
elif punishment == 'kban':
msg = ircmsgs.kick(channel, nick, reason)
irc.queueMsg(msg)
msg = ircmsgs.ban(channel, prefix)
irc.queueMsg(msg)
elif punishment.startswith('mode'):
msg = ircmsgs.mode(channel, punishment[len('mode'):])
irc.queueMsg(msg)
elif punishment.startswith('command '):
tokens = callbacks.tokenize(punishment[len('command '):])
self.Proxy(irc, msg, tokens)
示例2: _gegen
def _gegen(self, irc, msg, target):
if self._is_voting_enabled(irc, msg, reply=True) and self._check_privileges(irc, msg, reply=True):
channel = msg.args[0]
users = irc.state.channels[channel].users
voting_id = self._calculate_id(target, channel)
if target == msg.nick or target == irc.nick:
if self._can_be_kicked(irc, channel, msg.nick):
irc.queueMsg(ircmsgs.kick(channel, msg.nick, "Snibeti snab XDD"))
self._user_left(irc, msg.nick, channel)
return
if voting_id in self.running_votes:
voting = self.running_votes[voting_id]
if voting.add_vote(msg.nick):
voting_count = voting.count_votes(users)
if voting_count >= voting.threshold:
if target in irc.state.channels[channel].ops:
irc.queueMsg(ircmsgs.notice(channel, "Einen Versuch war's wert! :--D"))
for nick in voting.votes:
if self._can_be_kicked(irc, channel, nick):
irc.queueMsg(ircmsgs.kick(channel, nick, "Bis zum nächsten mal!"))
self._user_left(irc, nick, channel)
else:
self._remove_kebab(irc, channel, target)
del self.running_votes[voting_id]
else:
irc.reply("Stimme gegen %s registriert. Braucht noch %d weitere Stimme(n)." % (
target, voting.threshold - voting_count))
else:
voting_count = voting.count_votes(users)
irc.reply("Du hast bereits gegen %s gestimmt! Braucht noch %d weitere Stimme(n)." % (
target, voting.threshold - voting_count))
else:
active_users = self._calculate_active_user(irc, msg)
if target not in active_users:
irc.reply("%s ist inaktiv. Antrag abgelehnt." % target)
return
voting_threshold = self._calculate_voting_threshold(irc, msg, active_users)
voting = Voting(channel, target, msg.nick, voting_threshold)
voting.add_vote(msg.nick)
self.running_votes[voting_id] = voting
def clean_up():
if voting_id in self.running_votes:
message = "Abstimmung gegen %s ist erfolglos ausgelaufen." % self.running_votes[voting_id].target
irc.queueMsg(ircmsgs.notice(channel, message))
del self.running_votes[voting_id]
schedule.addEvent(clean_up, time.time() + int(self.registryValue("voting_timeout")))
irc.reply("Abstimmung gegen %s gestartet. Braucht noch %d weitere Stimme(n)." % (
target, voting.threshold - 1))
示例3: _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 = _('%s flood detected') % 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 == 'ban':
msg = ircmsgs.ban(channel, banmask)
irc.queueMsg(msg)
elif punishment == 'kban':
msg = ircmsgs.ban(channel, banmask)
irc.queueMsg(msg)
msg = ircmsgs.kick(channel, nick, reason)
irc.queueMsg(msg)
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'):], nick))
irc.queueMsg(msg)
elif punishment.startswith('command '):
tokens = callbacks.tokenize(punishment[len('command '):])
self.Proxy(irc, msg, tokens)
示例4: inFilter
def inFilter(self, irc, msg):
self.filtering = True
# We need to check for bad words here rather than in doPrivmsg because
# messages don't get to doPrivmsg if the user is ignored.
if msg.command == 'PRIVMSG':
channel = msg.args[0]
self.updateRegexp(channel)
s = ircutils.stripFormatting(msg.args[1])
if ircutils.isChannel(channel) and self.registryValue('kick', channel):
if self.words and self.regexp.search(s):
c = irc.state.channels[channel]
cap = ircdb.makeChannelCapability(channel, 'op')
if c.isHalfopPlus(irc.nick):
if c.isHalfopPlus(msg.nick) or \
ircdb.checkCapability(msg.prefix, cap):
self.log.debug("Not kicking %s from %s, because "
"they are halfop+ or can't be "
"kicked.", msg.nick, channel)
else:
message = self.registryValue('kick.message', channel)
irc.queueMsg(ircmsgs.kick(channel, msg.nick, message))
else:
self.log.warning('Should kick %s from %s, but not opped.',
msg.nick, channel)
return msg
示例5: roulette
def roulette(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:
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
示例6: 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
示例7: saveLast
def saveLast(self,irc,msg,match):
r".+"
channel = msg.args[0]
try: self.buffer[channel]
except: self.buffer[channel]=[]
# Stuff for multikick
if channel in self.kickuser:
for each in self.kickuser[channel]:
if each in msg.nick.lower() and not self.kickuser[channel][each]['num'] <= 0:
irc.queueMsg(ircmsgs.ban(msg.args[0], msg.nick))
irc.queueMsg(ircmsgs.kick(msg.args[0], msg.nick, "{}".format(self.kickuser[channel][each]['msg'].replace('#n',str(self.kickuser[channel][each]['num'])))))
self.kickuser[channel][each]['num']-=1
def un():
irc.queueMsg(ircmsgs.unban(msg.args[0],msg.nick))
schedule.addEvent(un,time.time()+random.randint(10,60)) # 30,120
# END
line = match.group(0).replace('\x01ACTION','*').strip('\x01')
if msg.nick.lower() in self.annoyUser:
def fu():
irc.queueMsg(ircmsgs.IrcMsg('NOTICE {} :\x02\x03{},{}{}'.format(msg.nick,random.randint(0,15),random.randint(0,15),line)))
schedule.addEvent(fu,time.time()+random.randint(2,60))
if re.match(r"^u[/].*[/].*[/].*$", match.group(0)) or re.match(r"^s[/].*[/].*$", match.group(0)):
return 1
self.buffer[channel].insert(0,[msg.nick,line])
if len(self.buffer[channel]) > self.buffsize: self.buffer[channel].pop(self.buffsize)
return 1
示例8: floodPunish
def floodPunish(self, irc, msg, floodType, dummy = False):
channel = msg.args[0]
if (not irc.nick in irc.state.channels[channel].ops) and\
(not irc.nick in irc.state.channels[channel].halfops):
self.log.warning("%s flooded in %s, but not opped.",\
msg.nick, channel)
return
if msg.nick in self.immunities:
self.log.debug("Not punnishing %s, they are immune.",
msg.nick)
return
if msg.nick in irc.state.channels[channel].ops or\
msg.nick in irc.state.channels[channel].halfops or\
msg.nick in irc.state.channels[channel].voices:
self.log.debug("%s flooded in %s. But"\
+ " I will not punish them because they have"\
+ " special access.", msg.nick, channel)
return
if ircdb.checkCapability(msg.prefix, 'trusted') or\
ircdb.checkCapability(msg.prefix, 'admin') or\
ircdb.checkCapability(msg.prefix, channel + ',op'):
self.log.debug("%s flooded in %s. But"\
+ " I will not punish them because they are"\
+ " trusted.", msg.nick, channel)
return
if msg.host in self.offenses and self.offenses[msg.host] > 2:
hostmask = irc.state.nickToHostmask(msg.nick)
banmaskstyle = conf.supybot.protocols.irc.banmask
banmask = banmaskstyle.makeBanmask(hostmask)
if not dummy:
irc.queueMsg(ircmsgs.ban(channel, banmask))
self.log.warning("Banned %s (%s) from %s for repeated"\
+ " flooding.", banmask, msg.nick, channel)
reason = floodType + " flood detected."
if floodType == "Paste":
reason += " Use a pastebin like pastebin.ubuntu.com or gist.github.com."
if not dummy:
irc.queueMsg(ircmsgs.kick(channel, msg.nick, reason))
self.log.warning("Kicked %s from %s for %s flooding.",\
msg.nick, channel, floodType)
# Don't schedule the same nick twice
if not (msg.host in self.offenses):
schedule.addEvent(self.clearOffenses, time.time()+300,
args=[msg.host])
self.offenses[msg.host] = 0 # Incremented below
self.offenses[msg.host] += 1
self.immunities[msg.nick] = True
schedule.addEvent(self.unImmunify, time.time()+3,
args=[msg.nick])
示例9: kickme
def kickme(self, irc, msg, args, reason):
"""[<reason>]
Kick yourself."""
if ircutils.isChannel(msg.args[0]):
irc.queueMsg(ircmsgs.kick(msg.args[0], msg.nick, reason or ''))
else:
irc.error(_("This command must be run in a channel."))
示例10: detonate
def detonate(self, irc):
self.active = False
self.thrown = False
if self.showCorrectWire:
# self.irc.reply('Should\'ve gone for the %s wire!' % self.goodWire)
s = "%s should've gone for the %s wire!" % (self.victim, self.goodWire)
self.irc.queueMsg(ircmsgs.action(self.channel, s))
if self.showArt:
self.irc.sendMsg(
ircmsgs.privmsg(self.channel, "\x031,1.....\x0315,1_.\x0314,1-^^---....,\x0315,1,-_\x031,1.......")
)
self.irc.sendMsg(
ircmsgs.privmsg(self.channel, "\x031,1.\x0315,1_--\x0314,1,.';,`.,';,.;;`;,.\x0315,1--_\x031,1...")
)
self.irc.sendMsg(
ircmsgs.privmsg(self.channel, "\x0315,1<,.\x0314,1;'`\".,;`..,;`*.,';`.\x0315,1;'>)\x031,1.")
)
self.irc.sendMsg(
ircmsgs.privmsg(self.channel, "\x0315,1I.:;\x0314,1.,`;~,`.;'`,.;'`,..\x0315,1';`I\x031,1.")
)
self.irc.sendMsg(
ircmsgs.privmsg(self.channel, "\x031,1.\x0315,1\\_.\x0314,1`'`..`';.,`';,`';,\x0315,1_../\x031,1..")
)
self.irc.sendMsg(
ircmsgs.privmsg(self.channel, "\x031,1....\x0315,1```\x0314,1--. . , ; .--\x0315,1'''\x031,1.....")
)
self.irc.sendMsg(
ircmsgs.privmsg(
self.channel,
"\x031,1..........\x034,1I\x031,1.\x038,1I\x037,1I\x031,1.\x038,1I\x034,1I\x031,1...........",
)
)
self.irc.sendMsg(
ircmsgs.privmsg(
self.channel,
"\x031,1..........\x034,1I\x031,1.\x037,1I\x038,1I\x031,1.\x037,1I\x034,1I\x031,1...........",
)
)
self.irc.sendMsg(
ircmsgs.privmsg(
self.channel, "\x031,1.......,\x034,1-=\x034,1II\x037,1..I\x034,1.I=-,\x031,1........"
)
)
self.irc.sendMsg(
ircmsgs.privmsg(
self.channel, "\x031,1.......\x034,1`-=\x037,1#$\x038,1%&\x037,1%$#\x034,1=-'\x031,1........"
)
)
else:
self.irc.sendMsg(ircmsgs.privmsg(self.channel, "KABOOM!"))
self.irc.queueMsg(ircmsgs.kick(self.channel, self.victim, "BOOM!"))
def reinvite():
if not self.victim in irc.state.channels[self.channel].users:
self.irc.queueMsg(ircmsgs.invite(self.victim, self.channel))
if not self.responded:
schedule.addEvent(reinvite, time.time() + 5)
示例11: testKick
def testKick(self):
# do it as the stock test user, because he has admin capability and can kick
gpg = self.irc.getCallback('GPG')
gpg.authed_users['[email protected]'] = {'nick':'test',
'keyid':'AAAAAAAAAAAAAAA4', 'fingerprint':'AAAAAAAAAAAAAAAAAAA1AAAAAAAAAAAAAAA4'}
self.prefix = '[email protected]'
self.assertRegexp('gpg ident', 'are identified')
self.irc.feedMsg(msg=ircmsgs.kick("#test", 'test', prefix=self.prefix))
self.assertRegexp('gpg ident', 'not identified')
示例12: doJoin
def doJoin(self, irc, msg):
user = ircutils.userFromHostmask(msg.prefix)
if user == 'root' or user == '~root':
channel = msg.args[0]
s = self.registryValue('warning', channel)
if self.registryValue('warn', channel):
irc.queueMsg(ircmsgs.notice(msg.nick, s))
if self.registryValue('kick', channel):
irc.queueMsg(ircmsgs.kick(channel, msg.nick, s))
示例13: doBan
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)
示例14: raptors
def raptors(self, irc, msg, args):
"""takes no arguments"""
channel = msg.args[0]
if irc.nick in irc.state.channels[channel].ops:
irc.queueMsg(ircmsgs.kick(channel, msg.nick, 'Raptor Attack!'))
irc.reply( ("%(name)s just got attacked by several raptors. As they " +
"pick the remaining meat from %(name)s's bones they look up " +
"and see BamaWOLF...") % {'name': msg.nick}, prefixNick=False )
else:
irc.reply("runs screaming", action=True)
示例15: doPrivmsg
def doPrivmsg(self, irc, msg):
currentChannel = msg.args[0]
if irc.isChannel(msg.args[0]):
if (msg.args[1] == '\_o< quack!'):
message = msg.nick + ", don't pretend to be me!";
# If kickMode is enabled for this channel, and the bot have op capability, let's kick!
if self.registryValue('kickMode', currentChannel) and irc.nick in irc.state.channels[currentChannel].ops:
irc.queueMsg(ircmsgs.kick(currentChannel, msg.nick, message))
else:
# Else, just say it
irc.reply(message)