forked from ben/tooter
move configs to json
This commit is contained in:
parent
26ed6b7f09
commit
0d5a6b0106
|
@ -60,3 +60,4 @@ target/
|
|||
|
||||
tildeteam.json
|
||||
tildeverse.json
|
||||
config.json
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"channels": [],
|
||||
"address": "127.0.0.1",
|
||||
"port": 6667,
|
||||
"botnick", "tooter"
|
||||
}
|
||||
|
19
tooter.py
19
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")
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue