def robocop(self, message, request_id, mode): request = Request.load(request_id, active=False) if request is None: return if mode == "cancel": reply = "Cancelled scan request %s" % (request.id,) message.privmsg(reply, self.scanchan()) nicks = CUT.get_user_nicks(request.user.name) for nick in nicks: message.privmsg(reply, nick) return if mode == "block": reply = "Updated request %s dists to %s" % (request.id, request.dists,) message.privmsg(reply, self.scanchan()) nicks = CUT.get_user_nicks(request.user.name) for nick in nicks: message.privmsg(reply, nick) return user = request.user planet = request.target requester = user.name if not Config.getboolean("Misc", "anonscans") else "Anon" dists_intel = planet.intel.dists if planet.intel else 0 message.privmsg("[%s] %s requested a %s Scan of %s:%s:%s Dists(i:%s%s) " % (request.id, requester, request.type, planet.x,planet.y,planet.z, dists_intel, "/r:%s" % request.dists if request.dists > 0 else "") + request.link, self.scanchan())
def blocks(self, message, user, params): id = params.group(1) dists = int(params.group(2)) + 1 request = Request.load(id) if request is None: message.reply("No open request number %s exists (idiot)." % (id, )) return if request.user is not user and not user.is_member( ) and not self.is_chan(message, self.scanchan()): message.reply( "Scan request %s isn't yours and you're not a scanner!" % (id, )) return request.dists = max(request.dists, dists) session.commit() reply = "Updated request %s dists to %s" % ( id, request.dists, ) message.reply(reply) if message.get_chan() != self.scanchan(): message.privmsg(reply, self.scanchan()) nicks = CUT.get_user_nicks(request.user.name) if message.get_nick() not in nicks: for nick in nicks: message.privmsg(reply, nick)
def cancel(self, message, user, params): id = params.group(1) request = Request.load(id) if request is None: message.reply("No open request number %s exists (idiot)." % (id, )) return if request.user is not user and not user.is_member( ) and not self.is_chan(message, self.scanchan()): message.reply( "Scan request %s isn't yours and you're not a scanner!" % (id, )) return request.active = False session.commit() reply = "Cancelled scan request %s" % (id, ) message.reply(reply) if message.get_chan() != self.scanchan(): message.privmsg(reply, self.scanchan()) nicks = CUT.get_user_nicks(request.user.name) if message.get_nick() not in nicks: for nick in nicks: message.privmsg(reply, nick)
def blocks(self, message, user, params): id = params.group(1) dists = int(params.group(2)) + 1 request = Request.load(id) if request is None: message.reply("No open request number %s exists (idiot)." % (id,)) return if request.user is not user and not user.is_member() and not self.is_chan(message, self.scanchan()): message.reply("Scan request %s isn't yours and you're not a scanner!" % (id,)) return # Update Intel planet = request.target if planet.intel is None: planet.intel = Intel() planet.intel.dists = max(planet.intel.dists, dists) request.dists = max(request.dists, dists) session.commit() reply = "Updated request %s dists to %s" % (id, request.dists) message.reply(reply) if message.get_chan() != self.scanchan(): message.privmsg(reply, self.scanchan()) nicks = CUT.get_user_nicks(request.user.name) if message.get_nick() not in nicks: for nick in nicks: message.privmsg(reply, nick)
def robocop(self, message, scantype, pa_id, x, y, z, names): nicks = [] reply = "%s on %s:%s:%s " % ( PA.get(scantype, "name"), x, y, z, ) reply += Config.get("URL", "viewscan") % (pa_id, ) for name in names.split(","): user = User.load(name) for nick in CUT.get_user_nicks(name): nicks.append(nick) message.privmsg(self.url(reply, user), nick) reply = "%s on %s:%s:%s " % ( PA.get(scantype, "name"), x, y, z, ) reply += "delivered to: " reply += ", ".join(nicks) if not Config.getboolean( "Misc", "anonscans") else "Anon" from Hooks.scans.request import request message.privmsg(reply, request().scanchan())
def admin_msg(message, priority=2): # Import these here or Core/connection.py will get upset. from Core.chanusertracker import CUT from Core.config import Config from Core.connection import Connection for a in Config.options("Admins"): for nick in CUT.get_user_nicks(a.lower()): Connection.write("PRIVMSG %s :%s" % (nick, message), priority)
def robocop(self, message, scantype, pa_id, x, y, z, names, scanner, reqs, old=False): nicks = [] reply = "Old " if old else "" reply += "%s on %s:%s:%s " % ( PA.get(scantype, "name"), x, y, z, ) if ("showscanner" in Config.options("Misc") and Config.getboolean("Misc", "showscanner") and scanner != 'None'): reply += "from %s " % (User.load(id=scanner).name) if User.load( id=scanner) not in (None, 'None') else "" reply += Config.get("URL", "viewscan") % (pa_id, ) if old: reply += " !request cancel %s if this is suitable." % (reqs) for name in names.split(","): user = User.load(name) for nick in CUT.get_user_nicks(name): nicks.append(nick) message.privmsg(self.url(reply, user), nick) if not old: reply = "[-%s] %s on %s:%s:%s " % ( reqs, PA.get(scantype, "name"), x, y, z, ) reply += "delivered to: " reply += ", ".join(nicks) if not Config.getboolean( "Misc", "anonscans") else "Anon" if Config.getboolean("Misc", "showurls"): reply += " (%s)" % (Config.get("URL", "viewscan") % (pa_id, )) from Hooks.scans.request import request message.privmsg(reply, request().scanchan())
def robocop(self, message, scantype, pa_id, x, y, z, names): nicks = [] reply = "%s on %s:%s:%s " % (PA.get(scantype,"name"),x,y,z,) reply+= Config.get("URL","viewscan") % (pa_id,) for name in names.split(","): user = User.load(name) for nick in CUT.get_user_nicks(name): nicks.append(nick) message.privmsg(self.url(reply, user), nick) reply = "%s on %s:%s:%s " % (PA.get(scantype,"name"),x,y,z,) reply+= "delivered to: " reply+= ", ".join(nicks) if not Config.getboolean("Misc", "anonscans") else "Anon" from Hooks.scans.request import request message.privmsg(reply, request().scanchan())
def cancel(self, message, user, params): cancel_ids = [] reply_ids = [] noexist = [] noaccess = [] for id in params.group(1).split(): if ':' in id: [start,end] = id.split(':') cancel_ids += range(int(start), int(end)+1) elif '-' in id: [start,end] = id.split('-') cancel_ids += range(int(start), int(end)+1) else: cancel_ids.append(int(id)) for id in cancel_ids: id = str(id) request = Request.load(id) if request is None: noexist.append(id) continue if request.user is not user and not user.is_member() and not self.is_chan(message, self.scanchan()): noaccess.append(id) continue request.active = False session.commit() reply = "Cancelled scan request %s" % (id) nicks = CUT.get_user_nicks(request.user.name) if message.get_nick() not in nicks: for nick in nicks: message.privmsg(reply, nick) reply_ids.append(id) if len(noexist) > 0: message.reply("No open request number %s exists (idiot)."%(", ".join(noexist),)) if len(noaccess) > 0: message.reply("Scan requests: %s aren't yours and you're not a scanner!"%(", ".join(noaccess),)) if len(reply_ids) > 0: reply = "Cancelled scan request %s" % (", ".join(reply_ids)) message.reply(reply) if message.get_chan() != self.scanchan(): message.privmsg(reply, self.scanchan())
def cancel(self, message, user, params): cancel_ids = [] reply_ids = [] noexist = [] noaccess = [] for id in params.group(1).split(): if ":" in id: [start, end] = id.split(":") cancel_ids += range(int(start), int(end) + 1) elif "-" in id: [start, end] = id.split("-") cancel_ids += range(int(start), int(end) + 1) else: cancel_ids.append(int(id)) for id in cancel_ids: id = str(id) request = Request.load(id) if request is None: noexist.append(id) continue if request.user is not user and not user.is_member() and not self.is_chan(message, self.scanchan()): noaccess.append(id) continue request.active = False session.commit() reply = "Cancelled scan request %s" % (id) nicks = CUT.get_user_nicks(request.user.name) if message.get_nick() not in nicks: for nick in nicks: message.privmsg(reply, nick) reply_ids.append(id) if len(noexist) > 0: message.reply("No open request number %s exists (idiot)." % (", ".join(noexist),)) if len(noaccess) > 0: message.reply("Scan requests: %s aren't yours and you're not a scanner!" % (", ".join(noaccess),)) if len(reply_ids) > 0: reply = "Cancelled scan request %s" % (", ".join(reply_ids)) message.reply(reply) if message.get_chan() != self.scanchan(): message.privmsg(reply, self.scanchan())
def cancel(self, message, user, params): id = params.group(1) request = Request.load(id) if request is None: message.reply("No open request number %s exists (idiot)." % (id,)) return if request.user is not user and not user.is_member() and not self.is_chan(message, self.scanchan()): message.reply("Scan request %s isn't yours and you're not a scanner!" % (id,)) return request.active = False session.commit() reply = "Cancelled scan request %s" % (id,) message.reply(reply) if message.get_chan() != self.scanchan(): message.privmsg(reply, self.scanchan()) nicks = CUT.get_user_nicks(request.user.name) if message.get_nick() not in nicks: for nick in nicks: message.privmsg(reply, nick)
def robocop(self, message, scantype, pa_id, x, y, z, names, scanner, reqs, old=False): nicks = [] reply = "Old " if old else "" reply += "%s on %s:%s:%s " % (PA.get(scantype,"name"),x,y,z,) if ("showscanner" in Config.options("Misc") and Config.getboolean("Misc", "showscanner") and scanner != 'None'): reply+= "from %s " % (User.load(id=scanner).name) if User.load(id=scanner) not in (None, 'None') else "" reply += Config.get("URL","viewscan") % (pa_id,) if old: reply += " !request cancel %s if this is suitable." % (reqs) for name in names.split(","): user = User.load(name) for nick in CUT.get_user_nicks(name): nicks.append(nick) message.privmsg(self.url(reply, user), nick) if not old: reply = "[-%s] %s on %s:%s:%s " % (reqs,PA.get(scantype,"name"),x,y,z,) reply+= "delivered to: " reply+= ", ".join(nicks) if not Config.getboolean("Misc", "anonscans") else "Anon" if Config.getboolean("Misc", "showurls"): reply += " (%s)" % (Config.get("URL","viewscan") % (pa_id,)) from Hooks.scans.request import request message.privmsg(reply, request().scanchan())