about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--config.json.example7
-rwxr-xr-xtooter.py19
-rw-r--r--tooter.service2
4 files changed, 19 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index 0b9039b..d318a30 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,3 +60,4 @@ target/
 
 tildeteam.json
 tildeverse.json
+config.json
diff --git a/config.json.example b/config.json.example
new file mode 100644
index 0000000..a980886
--- /dev/null
+++ b/config.json.example
@@ -0,0 +1,7 @@
+{
+    "channels": [],
+    "address": "127.0.0.1",
+    "port": 6667,
+    "botnick", "tooter"
+}
+
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")
 
diff --git a/tooter.service b/tooter.service
index 6d208d6..c347b41 100644
--- a/tooter.service
+++ b/tooter.service
@@ -5,7 +5,7 @@ After=tooter.service
 [Service]
 Type=simple
 WorkingDirectory=/home/ben/workspace/tooter
-ExecStart=/home/ben/workspace/tracer/tooter.py
+ExecStart=/home/ben/workspace/tooter/tooter.py
 Restart=always
 RestartSec=5
 StartLimitInterval=60s