diff --git a/irc_bot.py b/irc_bot.py index 6b1572e..1e54ba8 100755 --- a/irc_bot.py +++ b/irc_bot.py @@ -8,12 +8,8 @@ Keeping a log and reading incoming material. """ -from collections import deque -from datetime import datetime -import json import logging import os -import re import shutil import socket @@ -34,8 +30,6 @@ def __init__(self): "nick": "marvin", "realname": "Marvin The All Mighty dbwebb-bot", "ident": None, - "irclogfile": "irclog.txt", - "irclogmax": 20, "dirIncoming": "incoming", "dirDone": "done", "lastfm": None, @@ -44,10 +38,6 @@ def __init__(self): # Socket for IRC server self.SOCKET = None - # Keep a log of the latest messages - self.IRCLOG = None - - def connectToServer(self): """Connect to the IRC Server""" @@ -92,7 +82,6 @@ def connectToServer(self): def sendPrivMsg(self, message, channel): """Send and log a PRIV message""" if channel == self.CONFIG["channel"]: - self.ircLogAppend(user=self.CONFIG["nick"].ljust(8), message=message) self.MSG_LOG.debug("%s <%s> %s", channel, self.CONFIG["nick"], message) msg = "PRIVMSG {CHANNEL} :{MSG}\r\n".format(CHANNEL=channel, MSG=message) @@ -143,25 +132,6 @@ def receive(self): return lines - def ircLogAppend(self, line=None, user=None, message=None): - """Read incoming message and guess encoding""" - if not user: - user = re.search(r"(?<=:)\w+", line[0]).group(0) - - if not message: - message = ' '.join(line[3:]).lstrip(':') - - self.IRCLOG.append({ - 'time': datetime.now().strftime("%H:%M").rjust(5), - 'user': user, - 'msg': message - }) - - def ircLogWriteToFile(self): - """Write IRClog to file""" - with open(self.CONFIG["irclogfile"], 'w', encoding="UTF-8") as f: - json.dump(list(self.IRCLOG), f, indent=2) - def readincoming(self): """ Read all files in the directory incoming, send them as a message if @@ -187,12 +157,7 @@ def readincoming(self): def mainLoop(self): """For ever, listen and answer to incoming chats""" - self.IRCLOG = deque([], self.CONFIG["irclogmax"]) - while 1: - # Write irclog - self.ircLogWriteToFile() - # Check in any in the incoming directory self.readincoming() @@ -229,7 +194,6 @@ def checkMarvinActions(self, words): words[2], words[0].split(":")[1].split("!")[0], " ".join(words[3:])) - self.ircLogAppend(words) if words[1] == 'PRIVMSG': raw = ' '.join(words[3:]) diff --git a/marvin_actions.py b/marvin_actions.py index a68ac19..c4eb2f3 100644 --- a/marvin_actions.py +++ b/marvin_actions.py @@ -32,7 +32,6 @@ def getAllActions(): marvinBudord, marvinQuote, marvinStats, - marvinIrcLog, marvinWeather, marvinSun, marvinSayHi, @@ -233,17 +232,6 @@ def marvinStats(row): return msg -def marvinIrcLog(row): - """ - Provide a link to the irclog - """ - msg = None - if any(r in row for r in ["irc", "irclog", "log", "irclogg", "logg", "historik"]): - msg = getString("irclog") - - return msg - - def marvinSayHi(row): """ Say hi with a nice message. diff --git a/marvin_strings.json b/marvin_strings.json index 05aaf39..35a2e19 100644 --- a/marvin_strings.json +++ b/marvin_strings.json @@ -3,12 +3,10 @@ "whois": "Jag är en tjänstvillig själ som gillar webbprogrammering. Jag bor på GitHub https://github.com/mosbth/irc2phpbb och du kan diskutera mig i forumet http://dbwebb.se/t/20", - "menu": "[ vem är | lyssna | le | lunch [var] | citat | budord 1 - 5 | source | väder | solen | dagens video | nöje/paus/strip/comic [slump] | grill | birthday/födelsedag | nameday/namnsdag | stats | irclog | google/googla | explain/förklara | uptime | stream | princip | skämt/joke | hjälp ]", + "menu": "[ vem är | lyssna | le | lunch [var] | citat | budord 1 - 5 | source | väder | solen | dagens video | nöje/paus/strip/comic [slump] | grill | birthday/födelsedag | nameday/namnsdag | stats | google/googla | explain/förklara | uptime | stream | princip | skämt/joke | hjälp ]", "ircstats": "Statistik för kanalen finns här: http://dbwebb.se/irssistats/db-o-webb.html", - "irclog": "Loggen över de senaste 100 inläggen i kanalen finns här: https://dbwebb.se/irclog", - "google": [ "Googla {}", "LMGTFY {}", diff --git a/test_marvin_actions.py b/test_marvin_actions.py index 08aa02a..8475623 100644 --- a/test_marvin_actions.py +++ b/test_marvin_actions.py @@ -185,11 +185,6 @@ def testStats(self): self.assertStringsOutput(marvin_actions.marvinStats, "stats", "ircstats") self.assertActionSilent(marvin_actions.marvinStats, "statistics") - def testIRCLog(self): - """Test that marvin can provide a link to the IRC log""" - self.assertStringsOutput(marvin_actions.marvinIrcLog, "irc", "irclog") - self.assertActionSilent(marvin_actions.marvinIrcLog, "ircstats") - def testSayHi(self): """Test that marvin responds to greetings""" with mock.patch("marvin_actions.random") as r: