def unstab(self,irc,msg,args,channel,user): """<user> Removes +q from a user in channel""" hmask = irc.state.nickToHostmask(user) hostmask = ircutils.joinHostmask('*', '*', ircutils.hostFromHostmask(hmask)) irc.queueMsg(ircmsgs.IrcMsg('MODE {} -q {}'.format(channel,hostmask)))
def k(self, irc, msg, args, nicks): """[user] ... [user] Kick mit Timeban """ if(self._checkCPO(irc, msg)): hostmasks = [] for nick in nicks: prefix = irc.state.nickToHostmask(nick) user = ircutils.userFromHostmask(prefix) host = ircutils.hostFromHostmask(prefix) hostmask = '*!*@%s' % host if(host.find('mibbit.com') != -1): hostmask = '*!%s@*.mibbit.com' % user hostmasks.append(hostmask) hostmask = '*!*@%s' % self._numToDottedQuad(user) hostmasks.append(hostmask) irc.queueMsg(ircmsgs.bans(msg.args[0], hostmasks)) irc.queueMsg(ircmsgs.kicks(msg.args[0], nicks, 'Your behavior is not conducive to the desired environment.')) def unban(): irc.queueMsg(ircmsgs.unbans(msg.args[0], hostmasks)) schedule.addEvent(unban, time.time() + 900) irc.noReply()
def stab(self,irc,msg,args,channel,user,timer,reason): """<user> [seconds] [reason (ignored)] Stabs a user, putting them on quiet for a random time up to 10 mins.""" hmask = irc.state.nickToHostmask(user) hostmask = ircutils.joinHostmask('*', '*', ircutils.hostFromHostmask(hmask)) irc.queueMsg(ircmsgs.IrcMsg('MODE {0} +q {1}'.format(channel,hostmask))) t = time.time() r = timer if not r > 0: r = random.randint(30,600) expires = t+r len={} len['m'] = len['s'] = 0 while r > 59: len['m']+=1 r-=60 len['s'] = r irc.queueMsg(ircmsgs.IrcMsg('NOTICE {0} :{1} has been quieted for {2}:{3:0>2}'.format(msg.nick,user,len['m'],len['s']))) def f(): irc.queueMsg(ircmsgs.IrcMsg('MODE {0} -q {1}'.format(channel,hostmask))) schedule.addEvent(f,expires) irc.noReply()
def gethost(self, irc, msg, args, nick): """[<nick>] Returns the host of <nick>. If <nick> is not given, return the host of the person who called the command. """ if not nick: nick = msg.nick irc.reply(ircutils.hostFromHostmask(irc.state.nickToHostmask(nick)))
def unstab(self, irc, msg, args, channel, user): """<user> Removes +q from a user in channel""" hmask = irc.state.nickToHostmask(user) hostmask = ircutils.joinHostmask('*', '*', ircutils.hostFromHostmask(hmask)) irc.queueMsg( ircmsgs.IrcMsg('MODE {0} -q {1}'.format(channel, hostmask)))
def _remove_kebab(self, irc, channel, target): prefix = irc.state.nickToHostmask(target) host = ircutils.hostFromHostmask(prefix) hostmask = "*!*@%s" % host irc.queueMsg(ircmsgs.ban(channel, hostmask)) if target in irc.state.channels[channel].users: irc.queueMsg(ircmsgs.kick(channel, target, "Das Volk hat entschieden.")) def unban(): irc.queueMsg(ircmsgs.unban(channel, hostmask)) schedule.addEvent(unban, time.time() + int(self.registryValue("ban_duration")))
def mibbit(self, irc, msg, args, nick): """<nick> Mibbit-Check auf <nick> """ prefix = irc.state.nickToHostmask(nick) user = ircutils.userFromHostmask(prefix) host = ircutils.hostFromHostmask(prefix) if(host.find('mibbit.com') != -1): ip = self._numToDottedQuad(user) record = self._record_by_addr(ip) if record: reply = u'%s (%s)' % (ip, self._geoip_city_check(record)) else: reply = u'geoIP Fehler!' else: reply = u'%s benutzt kein mibbit' % nick irc.reply(reply.encode('utf-8'))
def _sendReviews(self, irc, msg): host = ircutils.hostFromHostmask(msg.prefix) if host in self.pendingReviews: self._banreviewfix() for nick, m in self.pendingReviews[host]: if msg.nick != nick and not irc.isChannel(nick): # I'm a bit extra careful here # correct nick in msg m = ircmsgs.privmsg(msg.nick, m.args[1]) irc.queueMsg(m) del self.pendingReviews[host] # check if we have any reviews by nick to send if None in self.pendingReviews: L = self.pendingReviews[None] for i, v in enumerate(L): nick, m = v if ircutils.strEqual(msg.nick, nick): irc.queueMsg(m) del L[i] if not L: del self.pendingReviews[None]
def mibbits(self, irc, msg, args): """ Zeigt alle mibbit-Benutzer im Kanal an """ mibbits = [] for nick in irc.state.channels[msg.args[0]].users: prefix = irc.state.nickToHostmask(nick) user = ircutils.userFromHostmask(prefix) host = ircutils.hostFromHostmask(prefix) if(host.find('mibbit.com') != -1): ip = self._numToDottedQuad(user) record = self._record_by_addr(ip) if record: mibbits.append(u'%s (%s, %s)' % (nick, ip, self._geoip_city_check(record))) else: mibbits.append('%s (geoIP Fehler)' % (nick)) if len(mibbits) > 0: reply = u'mibbits: %s' % (', '.join(mibbits)) else: reply = u'Keine mibbits entdeckt!' irc.reply(reply.encode('utf-8'))
def stab(self, irc, msg, args, channel, user, timer, reason): """<user> [seconds] [reason (ignored)] Stabs a user, putting them on quiet for a random time up to 10 mins.""" hmask = irc.state.nickToHostmask(user) hostmask = ircutils.joinHostmask('*', '*', ircutils.hostFromHostmask(hmask)) irc.queueMsg( ircmsgs.IrcMsg('MODE {0} +q {1}'.format(channel, hostmask))) if timer is not None: t = time.time() r = timer if not timer > 0: r = random.randint(30, 600) expires = t + r len = {} len['m'] = len['s'] = 0 while r > 59: len['m'] += 1 r -= 60 len['s'] = r irc.queueMsg( ircmsgs.IrcMsg( 'NOTICE +{0} :{1} has been quieted for {2}:{3:0>2}'.format( channel, user, len['m'], len['s']))) def f(): irc.queueMsg( ircmsgs.IrcMsg('MODE {0} -q {1}'.format(channel, hostmask))) schedule.addEvent(f, expires) irc.noReply()
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