fix some stuff
This commit is contained in:
parent
eda932ec06
commit
26ed6b7f09
|
@ -58,3 +58,5 @@ docs/_build/
|
|||
# PyBuilder
|
||||
target/
|
||||
|
||||
tildeteam.json
|
||||
tildeverse.json
|
||||
|
|
15
tooter.py
15
tooter.py
|
@ -9,7 +9,7 @@ import sys
|
|||
from mastodon import Mastodon
|
||||
|
||||
server = ("127.0.0.1", 6667)
|
||||
channels = ["#bots", "#meta", "#team"]
|
||||
channels = []
|
||||
if len(sys.argv) > 1:
|
||||
for c in sys.argv[1:]:
|
||||
channels.append("#" + c)
|
||||
|
@ -53,12 +53,14 @@ def eventloop(chan, nick, msg):
|
|||
words = re.split("[ \t\s]+", msg)
|
||||
if len(words) > 0 and nick != "tooter":
|
||||
if words[0] == "!toot":
|
||||
status = emoji.emojize(words[2:], use_aliases=True)
|
||||
status = emoji.emojize("".join(words[1:]), use_aliases=True)
|
||||
print(f"{status} posted by {nick}")
|
||||
if chan == "#team":
|
||||
res = tildeteam.toot(status)
|
||||
else:
|
||||
res = tildeverse.toot(status)
|
||||
send(chan, f"tooted! {res.url}")
|
||||
print(res)
|
||||
send(chan, "tooted! {}".format(res["url"]))
|
||||
elif words[0] == "!source":
|
||||
send(chan, "https://tildegit.org/ben/tooter")
|
||||
elif words[0] == "!botlist" or words[0] == "!toothelp":
|
||||
|
@ -94,8 +96,5 @@ if __name__ == "__main__":
|
|||
m = re.match(":(?P<nick>[^ ]+)!.*PRIVMSG #(?P<chan>\w+) :(?P<msg>.*)", msg)
|
||||
if m and m.groupdict():
|
||||
m = m.groupdict()
|
||||
try:
|
||||
eventloop(m["chan"], m["nick"], m["msg"])
|
||||
except Exception as e:
|
||||
print("ERROR" + str(m))
|
||||
print(e)
|
||||
eventloop(m["chan"], m["nick"], m["msg"])
|
||||
|
||||
|
|
Loading…
Reference in New Issue