add author to toots
also bumps deps and some various cleanups
This commit is contained in:
parent
7f687d23f7
commit
195e9015a8
|
@ -1,3 +1,3 @@
|
|||
Mastodon.py==1.5.0
|
||||
emoji==0.5.4
|
||||
ircrobots==0.3.7
|
||||
Mastodon.py==1.5.1
|
||||
emoji==1.7.0
|
||||
ircrobots==0.6.1
|
||||
|
|
34
tooter.py
34
tooter.py
|
@ -12,7 +12,7 @@ import json
|
|||
import os
|
||||
import sys
|
||||
|
||||
HELPTEXT = "helo i can send toots from irc: @tildeverse@tilde.zone - from @tildeteam from the #team channel)"
|
||||
HELP_TEXT = "helo i can send toots from irc: @tildeverse@tilde.zone - from @tildeteam from the #team channel)"
|
||||
|
||||
masto = {}
|
||||
assigned_channels = {}
|
||||
|
@ -48,22 +48,23 @@ if len(sys.argv) > 1:
|
|||
|
||||
def think(line):
|
||||
chan = line.params[0]
|
||||
words = line.params[1].split(" ")
|
||||
cmd = words[0].lower()
|
||||
cmd, *words = line.params[1].split(" ")
|
||||
cmd = cmd.lower()[1:]
|
||||
|
||||
if cmd == "!source":
|
||||
if cmd == "source":
|
||||
return "https://tildegit.org/ben/tooter"
|
||||
elif cmd in ["!botlist", "!toothelp"]:
|
||||
return HELPTEXT
|
||||
elif cmd == "!toot":
|
||||
elif cmd in ["botlist", "toothelp"]:
|
||||
return HELP_TEXT
|
||||
elif cmd == "toot":
|
||||
if len(words) >= 2:
|
||||
status = emoji.emojize(" ".join(words[1:]), use_aliases=True)
|
||||
author = line.tags.get("account", line.hostmask.nickname)
|
||||
res = masto[
|
||||
assigned_channels[chan] if chan in assigned_channels else "tildeverse"
|
||||
].toot(status)
|
||||
].toot(f"{status}\n~{author}")
|
||||
return "tooted! {}".format(res["url"])
|
||||
else:
|
||||
return HELPTEXT
|
||||
return HELP_TEXT
|
||||
|
||||
|
||||
class Server(BaseServer):
|
||||
|
@ -80,13 +81,14 @@ class Server(BaseServer):
|
|||
await self.send(build("JOIN", line.params[1:]))
|
||||
|
||||
if (
|
||||
line.command == "PRIVMSG"
|
||||
and self.has_channel(line.params[0])
|
||||
and self.has_user(line.hostmask.nickname)
|
||||
and len(line.params[1].split(" ")) > 0
|
||||
and not line.hostmask is None
|
||||
and not self.casefold(line.hostmask.nickname) == self.nickname_lower
|
||||
and not ("batch" in line.tags and line.tags["batch"] == "1")
|
||||
line.command == "PRIVMSG"
|
||||
and self.has_channel(line.params[0])
|
||||
and self.has_user(line.hostmask.nickname)
|
||||
and len(line.params[1].split(" ")) > 0
|
||||
and line.hostmask is not None
|
||||
and not self.casefold(line.hostmask.nickname) == self.nickname_lower
|
||||
and not ("batch" in line.tags and line.tags["batch"] == "1")
|
||||
and line.params[1].startswith("!")
|
||||
):
|
||||
response = think(line)
|
||||
if response is not None:
|
||||
|
|
|
@ -5,7 +5,7 @@ After=tooter.service
|
|||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/home/ben/workspace/tooter
|
||||
ExecStart=/usr/bin/python3 -u tooter.py
|
||||
ExecStart=/home/ben/workspace/tooter/venv/bin/python3 -u tooter.py
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
StartLimitInterval=60s
|
||||
|
|
Loading…
Reference in New Issue