make use of a config.yml
This commit is contained in:
parent
ca1c13c543
commit
97062c2297
2 changed files with 18 additions and 3 deletions
7
config.yml
Normal file
7
config.yml
Normal file
|
@ -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
|
14
server.py
14
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)
|
||||
|
|
Loading…
Reference in a new issue