fix some stuff

This commit is contained in:
Ben Harris 2019-05-29 21:28:49 -04:00
parent eda932ec06
commit 26ed6b7f09
2 changed files with 9 additions and 8 deletions

2
.gitignore vendored
View File

@ -58,3 +58,5 @@ docs/_build/
# PyBuilder
target/
tildeteam.json
tildeverse.json

View File

@ -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"])