From 7ee1f9a7aa62cddf9897e5f64d54723383e2ab84 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 7 May 2020 14:39:27 -0400 Subject: fix crash on empty toot --- tooter.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'tooter.py') diff --git a/tooter.py b/tooter.py index 4e98182..117185f 100644 --- a/tooter.py +++ b/tooter.py @@ -9,6 +9,7 @@ import re import socket import sys +HELPTEXT = "helo i can send toots from irc: @tildeverse@tilde.zone - from @tildeteam from the #team channel)" def masto_from_json(conf): conf = json.load(conf) @@ -38,20 +39,20 @@ def think(line): if len(words) > 0 and line.hostmask.nickname != config["botnick"]: cmd = words[0].lower() if cmd == "!toot": - status = emoji.emojize(" ".join(words[1:]), use_aliases=True) - if chan == "#team": - res = tildeteam.toot(status) + if len(words) >= 2: + status = emoji.emojize(" ".join(words[1:]), use_aliases=True) + if chan == "#team": + res = tildeteam.toot(status) + else: + res = tildeverse.toot(status) + print(res) + send(chan, "tooted! {}".format(res["url"])) else: - res = tildeverse.toot(status) - print(res) - send(chan, "tooted! {}".format(res["url"])) + send(chan, HELPTEXT) elif cmd == "!source": send(chan, "https://tildegit.org/ben/tooter") elif cmd in ["!botlist", "!toothelp"]: - send( - chan, - "helo i can send toots from irc: @tildeverse@tilde.zone - from @tildeteam from the #team channel)", - ) + send(chan, HELPTEXT) # do setup -- cgit 1.4.1