summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2022-09-06 21:02:38 -0400
committerTest_User <hax@andrewyu.org>2022-09-06 21:02:38 -0400
commitec8b1682e86535333c34966f6aafee349e609641 (patch)
treee37c4ca566962b8fd169cc0d6f7e635237b5dedc
parentc3c84a3c6aa633d0833f74d6ce1c99397a7fa8e2 (diff)
downloadcoupserv-ec8b1682e86535333c34966f6aafee349e609641.tar.gz
coupserv-ec8b1682e86535333c34966f6aafee349e609641.zip
fix deprecated CoupServ.py still being in the repo
-rw-r--r--.gitignore3
-rwxr-xr-xCoupServ.py298
-rw-r--r--commands.lua6
3 files changed, 8 insertions, 299 deletions
diff --git a/.gitignore b/.gitignore
index 43b648d..71ea114 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
CoupServConfig.json
+
+# deprecated version
+CoupServ.py
diff --git a/CoupServ.py b/CoupServ.py
deleted file mode 100755
index c4576a0..0000000
--- a/CoupServ.py
+++ /dev/null
@@ -1,298 +0,0 @@
-#!/usr/bin/env python3
-
-"""
-HaxServ, a pseudoserver for inspircd3.
-
-Written by: Test_User <hax@andrewyu.org>
-
-This is free and unencumbered software released into the public
-domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-"""
-
-import threading
-import socket
-import json
-import math
-import time
-import ssl
-import sys
-import os
-
-def send(msg):
- return s.sendall(msg.encode("UTF-8", "surrogateescape")+b"\n")
-
-def recv():
- return s.recv(1024).decode("UTF-8", "surrogateescape")
-
-def save():
- with open("CoupServTmp.json", "w") as config_file:
- json.dump(config, config_file, indent='\t', sort_keys=True)
- os.replace("CoupServTmp.json", "CoupServConfig.json")
-
-try:
- with open("CoupServConfig.json") as config_file:
- config = json.load(config_file)
-except FileNotFoundError:
- print("No config found! Please make one then try again")
- exit()
-
-rickroll = """We're no strangers to love
-You know the rules, and so do I
-A full commitment is what I'm thinking of
-You wouldn't get this from any other guy
-
-I just wanna tell you how I'm feeling
-Gotta make you, understand
-
-Never gonna give you up
-Never gonna let you down
-Never gonna run around and desert you
-
-Never gonna make you cry
-Never gonna say goodbye
-Never gonna tell a lie, and hurt you
-
-We've known each other, for so long
-Your heart's been aching but, you're too shy to say it
-Inside we both know what's been going on
-We know the game and we're gonna play it
-
-And if you ask me how I'm feeling
-Don't tell me you're too hot to see
-
-Never gonna give you up
-Never gonna let you down
-Never gonna run around, and desert you
-
-Never gonna make you cry
-Never gonna say goodbye
-never gonna tell a lie, and hurt you
-
-Never gonna give you up
-Never gonna let you down
-Never gonna run around, and desert you
-
-Never gonna make you cry
-Never gonna say goodbye
-never gonna tell a lie, and hurt you
-
-Give you up
-Never gonna give, never gonna give
-Give you up
-Never gonna give, never gonna give
-
-We've known each other, for so long
-Your heart's been aching but, you're too shy to say it
-Inside we both know what's been going on
-We know the game and we're gonna play it
-
-I just wanna tell you how I'm feelin
-Gotta make you, understand
-Never gonna give you up
-Never gonna let you down
-Never gonna run around, and desert you
-Never gonna make you cry
-Never gonna say goodbye
-never gonna tell a lie, and hurt you
-Never gonna give you up
-Never gonna let you down
-Never gonna run around, and desert you
-Never gonna make you cry
-Never gonna say goodbye
-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))
-
-send("SERVER hax.irc.andrewyu.org "+config["send_password"]+" 0 1HC :HaxServ")
-
-msg = ""
-
-connected_server = ""
-
-servlist = {}
-userlist = {}
-chanlist = {}
-
-usercount = 0
-
-def read_and_send():
- for line in sys.stdin:
- try:
- send(line)
- except Exception:
- pass
-
-threading.Thread(target=read_and_send, daemon=True).start()
-
-def detect_broken():
- while True:
- send("")
- time.sleep(15)
-
-threading.Thread(target=detect_broken, daemon=True).start()
-
-try:
- while True:
- newmsg = recv()
- if newmsg == "":
- os._exit(1)
- msg += newmsg
- split_msg = msg.split("\n")
- if len(split_msg) < 2:
- continue
- commands = split_msg[0:-1]
- msg = split_msg[-1]
- for command in commands:
- print(command.encode("UTF-8", "surrogateescape"))
-
- source = ""
- if command.startswith(":"):
- source = command.split(" ")[0][1:]
- command = " ".join(command.split(" ")[1:])
-
- lastarg = " :".join(command.split(" :")[1:])
- args = command.split(" :")[0].split(" ")[1:]
- args.append(lastarg)
- command = command.split(" :")[0].split(" ")[0].upper()
-
- if command == "PING":
- send(":"+args[1]+" PONG "+args[1]+" "+source)
- elif command == "SERVER":
- if source != "":
- continue
- 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")
- for channel in config["channels"]:
- send("FJOIN "+channel+" "+str(math.floor(time.time()))+" + :,1HC000000")
- send("MODE "+channel+" +o 1HC000000")
- send("ENDBURST")
- elif command == "UID":
- userlist[args[0]] = {
- "server": source,
- "nick_ts": args[1],
- "nick": args[2],
- "hostname": args[3],
- "vhost": args[4],
- "ident": args[5],
- "ip": args[6],
- "user_ts": args[7],
- "umodes": args[8],
- "realname": args[9],
-
- "opertype": None
- }
- elif command == "OPERTYPE":
- try:
- userlist[source]["opertype"] = args[0]
- except KeyError:
- print("Unable to find oper!\r\n")
- elif command == "NICK":
- try:
- userlist[source]["nick"] = args[0]
- userlist[source]["nick_ts"] = args[1]
- except KeyError:
- 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 args[0][0] == "#":
- chan = args[0]
- resp = chan
- args[1] = args[1][1:]
- else:
- resp = source
- chan = False
-
- cmd = args[1].split(" ")[0].lower()
- argv = args[1].split(" ")[1:]
-
- send(":1HC000000 PRIVMSG "+config["log_chan"]+" :"+userlist[source]["nick"]+" executed command: "+args[1])
-
- if len(cmd) == 0:
- continue
- elif cmd[0] == ":":
- send(args[1])
- elif cmd == "get":
- if argv[0] == "uid":
- try:
- send(":1HC000000 PRIVMSG "+resp+" :"+[key for key in userlist if userlist[key]["nick"] == argv[1]][0])
- except IndexError:
- send(":1HC000000 PRIVMSG "+resp+" :Nick not found!")
- elif argv[0] == "ts":
- try:
- send(":1HC000000 PRIVMSG "+resp+" :"+userlist[argv[1]]["nick_ts"])
- except KeyError:
- send(":1HC000000 PRIVMSG "+resp+" :UID not found!")
- elif cmd == "jupe":
- send("RSQUIT :"+argv[0])
- send(":1HC SERVER "+argv[0]+" * 0 010 :No")
- elif cmd == "sanick":
- send(":1HC000000 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 &')
- elif cmd == "spam":
- for _ in range(0, int(argv[1])):
- send(":1HC PRIVMSG "+argv[0]+" :"+" ".join(argv[2:]))
- elif cmd == "join":
- send(":1HC000000 FJOIN "+argv[0]+" "+str(math.floor(time.time()))+" + :,1HC000000")
- config["channels"][argv[0]] = True # actual value doesn't matter
- save()
- elif cmd == "part":
- send(":1HC000000 PART "+resp)
- del config["channels"][resp]
- save()
- elif cmd == "op":
- if chan:
- try:
- send(":1HC000000 MODE "+chan+" +o "+argv[0])
- except IndexError:
- send(":1HC000000 MODE "+chan+" +o "+source)
-
- if args[1] == "nggyu":
- if args[0][0] == "#":
- resp = args[0]
- else:
- resp = source
-
- for line in rickroll.split("\n"):
- send(":1HC000000 PRIVMSG "+resp+" :"+line)
-
- except KeyError:
- pass
-
-except Exception as e:
- config_file.close()
- raise e
-
diff --git a/commands.lua b/commands.lua
index bf38ff1..b758812 100644
--- a/commands.lua
+++ b/commands.lua
@@ -316,7 +316,11 @@ commands = {
local fd = io.popen(command)
local message = fd:read("*a")
for line in message:gmatch("[^\n]*") do
- con:send(":1HC000000 PRIVMSG "..resp.." :"..line.."\n")
+ if line == "" then
+ con:send(":1HC000000 PRIVMSG "..resp.." : \n")
+ else
+ con:send(":1HC000000 PRIVMSG "..resp.." :"..line:gsub("\t", (" "):rep(8)).."\n")
+ end
end
fd:close()
bash_command = nil