From 0d5a6b010694be98e2ddbef221588ac007048df0 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 29 May 2019 22:06:45 -0400 Subject: move configs to json --- tooter.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'tooter.py') diff --git a/tooter.py b/tooter.py index fe3f72a..378cac5 100755 --- a/tooter.py +++ b/tooter.py @@ -8,17 +8,19 @@ import socket import sys from mastodon import Mastodon -server = ("127.0.0.1", 6667) -channels = [] +path = os.path.dirname(os.path.abspath(__file__)) + +with open(os.path.join(path, "config.json")) as f: + config = json.load(f) + +botnick = config["botnick"] +channels = config["channels"] if len(sys.argv) > 1: for c in sys.argv[1:]: channels.append("#" + c) -botnick = "tooter" # read masto creds -path = os.path.dirname(os.path.abspath(__file__)) -tildeverse_file = os.path.join(path, "tildeverse.json") -with open(tildeverse_file) as f: +with open(os.path.join(path, "tildeverse.json")) as f: tildeverse_config = json.load(f) tildeverse = Mastodon( @@ -28,8 +30,7 @@ tildeverse = Mastodon( api_base_url=tildeverse_config["base_url"], ) -tildeteam_file = os.path.join(path, "tildeteam.json") -with open(tildeteam_file) as f: +with open(os.path.join(path, "tildeteam.json")) as f: tildeteam_config = json.load(f) tildeteam = Mastodon( @@ -72,7 +73,7 @@ def eventloop(chan, nick, msg): if __name__ == "__main__": ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - ircsock.connect(server) + ircsock.connect((config["address"], config["port"])) rawsend(f"NICK {botnick}") rawsend(f"USER {botnick} 0 * :mastodon tooter") -- cgit 1.4.1