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 write(self, text): # Write something to the server, the message will be split up by newlines and at 450chars max params = text.split(":")[0] + ":" text = ":".join(text.split(":")[1:]) if text: for line in text.split("\n"): while line: Connection.write((params + line)[:450]) line = line[450 - len(params):] else: Connection.write(params[:-1])
def write(self, text): # Write something to the server, the message will be split up by newlines and at 450chars max params = text.split(":")[0] + ":" text = ":".join(text.split(":")[1:]) if text: for line in text.split("\n"): while line: Connection.write((params + line)[:450]) line = line[450 - len(params):] else: Connection.write(params[:-1])
def write(self, text, color=False, priority=0): # Write something to the server, the message will be split up by newlines and at 450chars max # Set Priority l = len(text) p = 5 + priority if l < 100: p -= 1 elif l > 150: p += min(l,400) // 100 + l // 450 ## n = False try: n = self.get_pnick() except: p += 2 if n: if n in Config.options("Admins"): p -= 2 try: u = User.load(n) if u: if u.is_admin(): p -= 1 elif u.is_galmate(): p += 1 else: p +=2 except: p += 2 # Split message and send colon = text.find(":") if colon != -1: while text[colon-1] != " " and colon != -1: colon = text.find(":",colon+1) if colon != -1: params = text[:colon+1] text = text[colon+1:] if colon == -1: params = text text = None if text: if color: params += "\x03"+Config.get("Connection", "color") for line in text.split("\n"): line while line: i = len(line) while len(line[:i]) > (450 - len(params)): i = line.rfind(" ", 0, i) if i == -1: Connection.write((params + line)[:450]) line = line[450 - len(params):] continue Connection.write(params + line[:i], p) line = line[i+1:] else: Connection.write(params, p)
def write(self, text, color=False): # Write something to the server, the message will be split up by newlines and at 450chars max params = text.split(":")[0] + ":" text = ":".join(text.split(":")[1:]) if text: if color: params += "\x03"+Config.get("Connection", "color") for line in text.split("\n"): line while line: i = len(line) while len(line[:i]) > (450 - len(params)): i = line.rfind(" ", 0, i) if i == -1: Connection.write((params + line)[:450]) line = line[450 - len(params):] continue Connection.write(params + line[:i]) line = line[i+1:] else: Connection.write(params[:-1])
def reset(self): self.Channels.clear() self.Nicks.clear() self.Pusers.clear() Connection.write("WHOIS %s" % (Merlin.nick, ))
def reset(self): self.Channels.clear() self.Nicks.clear() self.Pusers.clear() Connection.write("WHOIS %s" % (Merlin.nick,))
def write(self, text, color=False, priority=0): # Write something to the server, the message will be split up by newlines and at 450chars max # Set Priority p = 5 + priority if Config.getint("Connection", "antiflood") > 0: l = len(text) if l < 100: p -= 1 elif l > 150: p += min(l, 400) // 100 + l // 450 n = False try: n = self.get_pnick() except: p += 2 if n: if n in Config.options("Admins"): p -= 2 try: u = User.load(n) if u: if u.is_admin(): p -= 1 elif u.is_galmate(): p += 1 else: p += 2 except: p += 2 # Split message and send colon = text.find(":") if colon != -1: while text[colon - 1] != " " and colon != -1: colon = text.find(":", colon + 1) if colon != -1: params = text[:colon + 1] text = text[colon + 1:] if colon == -1: params = text text = None if text: if color: params += "\x03" + Config.get("Connection", "color") for line in text.split("\n"): while line: i = len(line) while i > (450 - len(params)): i = max(line.rfind(" ", 0, i), line.rfind(",", 0, i)) if i == -1: while len(params + line) > 450: Connection.write((params + line)[:450], p) line = line[450 - len(params):] i = len(line) continue Connection.write(params + line[:i + 1], p) line = line[i + 1:] else: Connection.write(params, p)