paritybot

A fun IRC bot.
git clone https://git.sr.ht/~jbauer/paritybot
Log | Files | Refs | README | LICENSE

commit a70f990691a7566982d5000bfed8c9a0fb779070
parent 4c8e6eea4d32d12aab30feff1c1a3efeba467325
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Sat, 21 Nov 2020 02:48:12 -0500

Revert breaking change

Diffstat:
Mbot.py | 22+++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/bot.py b/bot.py @@ -25,7 +25,7 @@ import requests from datetime import datetime from pytz import timezone -VERSION = "v0.4.2" +VERSION = "v0.4.3" AUTHOR = "Jake Bauer" server = "irc.paritybit.ca" port = 6697 @@ -67,40 +67,40 @@ def main(): ircmsg = ircmsg.strip('\n\r') print(ircmsg) - if ircmsg.find(":,tbhelp ") != -1: + if ircmsg.find(":,tbhelp") != -1: message = "PRIVMSG "+ get_channel(ircmsg) +" :Available commands: ,tbhelp ,tbversion ,tbwhereami ,tbquote ,tbtime ,tbdiceroll ,tbweather\n" send_msg(message) - elif ircmsg.find(":,tbwhereami ") != -1: + elif ircmsg.find(":,tbversion") != -1: + message = "PRIVMSG " + get_channel(ircmsg) + " :" + botnick + "version " + VERSION + " by " + AUTHOR + ".\n" + send_msg(message) + + elif ircmsg.find(":,tbwhereami") != -1: message = "PRIVMSG "+ get_channel(ircmsg) +" :You are currently in " + get_channel(ircmsg) + ".\n" send_msg(message) - elif ircmsg.find(":,tbquote ") != -1: + elif ircmsg.find(":,tbquote") != -1: with open(quotesfile, "r") as f: lines = f.read().splitlines() selectedLine = random.choice(lines) message = "PRIVMSG " + get_channel(ircmsg) + " :" + selectedLine + "\n" send_msg(message) - elif ircmsg.find(":,tbversion ") != -1: - message = "PRIVMSG " + get_channel(ircmsg) + " :" + botnick + "version " + VERSION + " by " + AUTHOR + ".\n" - send_msg(message) - - elif ircmsg.find(":,tbtime ") != -1: + elif ircmsg.find(":,tbtime") != -1: try: message = "PRIVMSG " + get_channel(ircmsg) + " :" + datetime.now(timezone(ircmsg.split(' ')[4])).strftime('%Y-%m-%d %H:%M:%S') + "\n" except Exception as e: message = "PRIVMSG " + get_channel(ircmsg) + " :Please specify a valid timezone (e.g. ,tbtime America/Toronto).\n" send_msg(message) - elif ircmsg.find(":,tbdiceroll ") != -1: + elif ircmsg.find(":,tbdiceroll") != -1: try: message = "PRIVMSG " + get_channel(ircmsg) + " :" + str(random.randint(1, int(ircmsg.split(' ')[4]))) + "\n" except Exception as e: message = "PRIVMSG " + get_channel(ircmsg) + " :Please specify a maximum number (e.g. ,tbdiceroll 20).\n" send_msg(message) - elif ircmsg.find(":,tbweather ") != -1: + elif ircmsg.find(":,tbweather") != -1: try: city = ircmsg.split(' ')[4] url = "https://wttr.in/" + city + "?format=3"