diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..aa02907 --- /dev/null +++ b/config.yml @@ -0,0 +1,7 @@ +# IRCat Configuration + +# Used as the server/network's display name. +name: foo + +# The hostname the server should go by, such as ircserver1.example.com +host: 127.0.0.1 \ No newline at end of file diff --git a/server.py b/server.py index c1a72c0..775dea6 100644 --- a/server.py +++ b/server.py @@ -2,15 +2,23 @@ __version__ = 0 print(f"INTERNET RELAY CAT v{__version__}") print("Welcome! /ᐠ ˵> ⩊ <˵マ") -import socket, time, threading, traceback, sys, os +import socket, time, threading, traceback, sys, os, yaml from requests import get if not len(sys.argv) == 2: print("IRCat requires the following arguments: config.yml") + sys.exit(1) +server = "127.0.0.1" +displayname = "foo" +with open(sys.argv[1], 'r') as file: + data = yaml.safe_load(file) + try: server = data["host"] + except: print("using fallback server address") + try: displayname = data["name"] + except: print("using fallback display name") + file.close() ip = get('https://api.ipify.org').content.decode('utf8') tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) tcp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) -server = "127.0.0.1" -displayname = "SWEE.codes" server_address = ('0.0.0.0', 6667) tcp_socket.bind(server_address) tcp_socket.listen(1)