From 7113b9d6c7d25f55a58f9ad914d2302cb71175a0 Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Mon, 2 May 2022 11:04:06 +0200 Subject: [PATCH 01/15] Another change on identification --- FaustBot/Communication/Connection.py | 1 - FaustBot/Modules/HelpObserver.py | 1 - FaustBot/Modules/WordRunObserver.py | 6 +++--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/FaustBot/Communication/Connection.py b/FaustBot/Communication/Connection.py index 214995b..2598cf0 100644 --- a/FaustBot/Communication/Connection.py +++ b/FaustBot/Communication/Connection.py @@ -143,7 +143,6 @@ class Connection(object): self.irc.send("USER botty botty botty :Botty \n".encode()) if (self.details.get_pwd() != ''): self.send_to_user("NICKSERV", "identify " + self.details.get_nick() + " " + self.details.get_pwd() + ' ') - time.sleep(3) self.irc.send("JOIN ".encode() + self.details.get_channel().encode() + '\r\n'.encode()) self.irc.send("WHO ".encode() + self.details.get_channel().encode() + '\r\n'.encode()) self.irc.send("MODE ".encode()+self.details.get_nick().encode()+" -R".encode()+'\r\n'.encode()) diff --git a/FaustBot/Modules/HelpObserver.py b/FaustBot/Modules/HelpObserver.py index a5a5470..40aff26 100644 --- a/FaustBot/Modules/HelpObserver.py +++ b/FaustBot/Modules/HelpObserver.py @@ -1,4 +1,3 @@ -from types import NoneType from FaustBot.Communication import Connection from FaustBot.Modules.PrivMsgObserverPrototype import PrivMsgObserverPrototype diff --git a/FaustBot/Modules/WordRunObserver.py b/FaustBot/Modules/WordRunObserver.py index 25fe502..f7d6e6f 100644 --- a/FaustBot/Modules/WordRunObserver.py +++ b/FaustBot/Modules/WordRunObserver.py @@ -28,11 +28,11 @@ class WordRunObserver(PrivMsgObserverPrototype): def update_on_priv_msg(self, data, connection: Connection): if data['message'].startswith('.a ') or data['message'].startswith('.add '): self.add(data, connection) - if data['message'].startswith('.begin '): + if data['message'].startswith('.begin '): self.begin_word(data, connection) - if data['message'].startswith('.end '): + if data['message'].startswith('.end '): self.end_word(data, connection) - if data['message'].startswith('.wordrun'): + if data['message'].startswith('.wordrun'): self.rules(data, connection) def add(self, data, connection): From c22b1a10cbee1146c214308515b34b5bd30a847f Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Thu, 2 Jun 2022 09:02:21 +0200 Subject: [PATCH 02/15] added a few things --- essen.py | 2 +- getraenke.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/essen.py b/essen.py index c5732e2..1cfb0a5 100644 --- a/essen.py +++ b/essen.py @@ -28,7 +28,7 @@ essen = ['einen Wirsingeintopf', 'einen Lahmacun', 'eine Portion Kartoffelbrei', 'eine Waffel mit Puderzucker', 'Grießbrei mit Amarena Kirschen', 'einen Kaiserschmarrn mit Apfelmus', 'Palatschinken mit Marillenmarmelade und Staubzucker', 'eine Tüte Maiswaffeln','eine Packung Schoko Keksi','einen Handkäs mit Musik', - 'eine Schale Grießbrei mit Nutella' + 'eine Schale Grießbrei mit Nutella','ein Gefäß mit Wan Tan' ] diff --git a/getraenke.py b/getraenke.py index b66b37e..d8135e0 100644 --- a/getraenke.py +++ b/getraenke.py @@ -45,5 +45,6 @@ getraenke = ['einen Kaffee','eine Limonade','einen Kakao','einen Tee', 'ein Glas fairtrade Limonade','eine Cola Light', 'ein Glas Fanta light', 'ein Glas Sprite light', 'ein Glas Spezi light','eine dampfende Tasse Winterpunsch-Tee', 'eine bunte Tasse Rooibos Schoko-Chai','eine Tasse Rooibos Chai', - 'eine Tasse Fencheltee mit Honig' + 'eine Tasse Fencheltee mit Honig','eine dampfende Tasse Zimtschneckentee', + 'eine dampfende Tasse gebrannte Mandel Tee' ] From 6621b5faf7fd17e6fc94d5a72448dc794ac7c0b3 Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Fri, 17 Jun 2022 10:06:34 +0200 Subject: [PATCH 03/15] Made Enten permanENTEn --- FaustBot/Model/DuckProvider.py | 36 +++++++++++++++++++++++ FaustBot/Modules/DuckObserver.py | 50 ++++++++++++++++++++++++++------ 2 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 FaustBot/Model/DuckProvider.py diff --git a/FaustBot/Model/DuckProvider.py b/FaustBot/Model/DuckProvider.py new file mode 100644 index 0000000..46c53ec --- /dev/null +++ b/FaustBot/Model/DuckProvider.py @@ -0,0 +1,36 @@ +import sqlite3 + + +class DucksProvider(object): + _CREATE_TABLE = 'CREATE TABLE IF NOT EXISTS ducks (id INTEGER PRIMARY KEY, \ + user TEXT, friends INTEGER, dead INTEGER)' + _GET_DUCKS = 'SELECT id, friends, dead FROM ducks WHERE user = ?' + _SAVE_OR_OVERWRITE = 'REPLACE INTO ducks (id, user, friends, dead) VALUES (?, ?, ?,?)' + _DELETE_DUCKS = 'DELETE FROM ducks WHERE user = ?' + + def __init__(self): + self._database_connection = sqlite3.connect('faust_bot.db') + cursor = self._database_connection.cursor() + cursor.execute(DucksProvider._CREATE_TABLE) + self._database_connection.commit() + + def get_ducks(self, user: str): + cursor = self._database_connection.cursor() + cursor.execute(DucksProvider._GET_DUCKS, (user.lower(),)) + return cursor.fetchone() + + def save_or_replace(self, user: str, friends: int, dead: int): + existing = self.get_ducks(user) + _id = existing[0] if existing is not None else None + data = (_id, user.lower(), friends, dead) + cursor = self._database_connection.cursor() + cursor.execute(DucksProvider._SAVE_OR_OVERWRITE, data) + self._database_connection.commit() + + def delete_score(self, user: str): + cursor = self._database_connection.cursor() + cursor.execute(DucksProvider._DELETE_DUCKS, (user.lower(),)) + self._database_connection.commit() + + def __exit__(self): + self._database_connection.close() diff --git a/FaustBot/Modules/DuckObserver.py b/FaustBot/Modules/DuckObserver.py index 0809ddb..f240dd2 100644 --- a/FaustBot/Modules/DuckObserver.py +++ b/FaustBot/Modules/DuckObserver.py @@ -3,7 +3,7 @@ from FaustBot.Communication.Connection import Connection from FaustBot.Modules.PrivMsgObserverPrototype import PrivMsgObserverPrototype from FaustBot.Modules.PingObserverPrototype import PingObserverPrototype from random import randint -from collections import defaultdict +from FaustBot.Model.DuckProvider import DucksProvider class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): @staticmethod @@ -22,8 +22,6 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): super().__init__() self.active = 0 self.duck_alive = 0 - self.ducks_hunt = defaultdict(int) - self.ducks_befriend = defaultdict(int) def update_on_priv_msg(self, data, connection: Connection): if data['message'].find('.starthunt') != -1: @@ -43,7 +41,7 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): connection.send_channel("Jagd beendet") return if data['message'].find('.ducks') != -1: - connection.send_channel(data['nick'] + " hat schon " + str(self.ducks_befriend[data['nick']]) + " befreundete Enten und " + str(self.ducks_hunt[data['nick']]) + " getötete Enten.") + connection.send_channel(self.build_duck_string(data['nick'])) if data['message'].find('.freunde') != -1: self.befriend(data, connection) if data['message'].find('.schiessen') != -1: @@ -55,8 +53,8 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): connection.send_channel(data['nick'] + " probiert eine Ente zu befreunden aber sie will nicht.") else: self.duck_alive = 0 - self.ducks_befriend[data['nick']] += 1 - connection.send_channel(data['nick'] + " hat schon " + str(self.ducks_befriend[data['nick']]) + " befreundete Enten und " + str(self.ducks_hunt[data['nick']]) + " getötete Enten.") + self.addLivingDuck(data['nick']) + connection.send_channel(self.build_duck_string(data['nick'])) return if (self.duck_alive == 0 and self.active == 1): connection.send_channel(data['nick']+ " probiert eine nicht existente Ente zu befreunden.") @@ -68,8 +66,8 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): connection.send_channel(data['nick'] + " trifft daneben.") else: self.duck_alive = 0 - self.ducks_hunt[data['nick']] += 1 - connection.send_channel(data['nick'] + " hat schon " + str(self.ducks_befriend[data['nick']]) + " befreundete Enten und " + str(self.ducks_hunt[data['nick']]) + " getötete Enten.") + self.addDeadDuck(data['nick']) + connection.send_channel(self.build_duck_string(data['nick'])) return if (self.duck_alive == 0 and self.active == 1): connection.send_channel(data['nick']+ " schießt ins Nichts.") @@ -79,10 +77,44 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): def update_on_ping(self, data, connection: Connection): if self.active == 0: return - if 1 == randint(1,11): + if 1 == randint(1,1): if self.duck_alive == 0: connection.send_channel("*. *. *. * < *. *. * Quack!") self.duck_alive = 1 def _is_idented_mod(self, data: dict, connection: Connection): return data['nick'] in self._config.mods and connection.is_idented(data['nick']) + + def getLiving(self, nick: str): + duck_provider = DucksProvider() + duck = duck_provider.get_ducks(nick) + if duck is not None: + return duck[1] + else: + return 0 + + def getDead(self, nick: str): + duck_provider = DucksProvider() + duck = duck_provider.get_ducks(nick) + if duck is not None: + return duck[2] + else: + return 0 + + def addDeadDuck(self, nick:str): + self.writeDucks(nick, self.getLiving(nick), self.getDead(nick)+1) + + def addLivingDuck(self,nick:str): + self.writeDucks(nick, self.getLiving(nick)+1, self.getDead(nick)) + + def writeDucks(self, nick: str, living: int, dead: int): + ducks_provider = DucksProvider() + ducks_provider.save_or_replace(nick, living, dead) + + def build_duck_string(self, nick: str): + return nick + " hat schon " +str(self.getLiving(nick))+ " befreundete "+self.pluralEnte(self.getLiving(nick))+" und " + str(self.getDead(nick)) + " getötete "+self.pluralEnte(self.getDead(nick)) + + def pluralEnte(self, enten:int): + if enten == 1: + return "Ente" + return "Enten" \ No newline at end of file From 5fc98e574e8f9a044456d22fe65f8d421bb68b67 Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Fri, 17 Jun 2022 10:09:28 +0200 Subject: [PATCH 04/15] corrected minor mistake in chance to get a duck --- FaustBot/Modules/DuckObserver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FaustBot/Modules/DuckObserver.py b/FaustBot/Modules/DuckObserver.py index f240dd2..1a7db73 100644 --- a/FaustBot/Modules/DuckObserver.py +++ b/FaustBot/Modules/DuckObserver.py @@ -77,7 +77,7 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): def update_on_ping(self, data, connection: Connection): if self.active == 0: return - if 1 == randint(1,1): + if 1 == randint(1,11): if self.duck_alive == 0: connection.send_channel("*. *. *. * < *. *. * Quack!") self.duck_alive = 1 From 8e665cd64f57929126ed672982f824469ecf2eba Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Mon, 20 Jun 2022 09:29:06 +0200 Subject: [PATCH 05/15] Changed numbers 0 and 1 to be represented in textform in order to improve readability --- FaustBot/Modules/DuckObserver.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/FaustBot/Modules/DuckObserver.py b/FaustBot/Modules/DuckObserver.py index 1a7db73..adb811e 100644 --- a/FaustBot/Modules/DuckObserver.py +++ b/FaustBot/Modules/DuckObserver.py @@ -77,7 +77,7 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): def update_on_ping(self, data, connection: Connection): if self.active == 0: return - if 1 == randint(1,11): + if 1 == randint(1,1): if self.duck_alive == 0: connection.send_channel("*. *. *. * < *. *. * Quack!") self.duck_alive = 1 @@ -112,9 +112,19 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): ducks_provider.save_or_replace(nick, living, dead) def build_duck_string(self, nick: str): - return nick + " hat schon " +str(self.getLiving(nick))+ " befreundete "+self.pluralEnte(self.getLiving(nick))+" und " + str(self.getDead(nick)) + " getötete "+self.pluralEnte(self.getDead(nick)) - - def pluralEnte(self, enten:int): - if enten == 1: - return "Ente" - return "Enten" \ No newline at end of file + duckstring = "" + livingDucks = self.getLiving(nick) + deadDucks = self.getDead(nick) + if livingDucks > 1: + duckstring = duckstring + nick + " hat schon " +str(livingDucks)+ " befreundete Enten und " + elif livingDucks == 1: + duckstring = duckstring + nick + " hat schon eine befreunde Ente und " + elif livingDucks == 0: + duckstring = duckstring + nick + " hat noch keine befreundeten Enten und " + if deadDucks > 1: + duckstring = duckstring + str(deadDucks) + " getötete Enten" + elif deadDucks == 1: + duckstring = duckstring +"eine getötete Ente" + elif deadDucks == 0: + duckstring = duckstring+"keine getöteten Enten" + return duckstring From 6a2547ec3f2f64b0e0616d2cdb1821f2b4b12f8b Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Mon, 20 Jun 2022 09:31:25 +0200 Subject: [PATCH 06/15] minor error correction --- FaustBot/Modules/DuckObserver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FaustBot/Modules/DuckObserver.py b/FaustBot/Modules/DuckObserver.py index adb811e..3d8618c 100644 --- a/FaustBot/Modules/DuckObserver.py +++ b/FaustBot/Modules/DuckObserver.py @@ -77,7 +77,7 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): def update_on_ping(self, data, connection: Connection): if self.active == 0: return - if 1 == randint(1,1): + if 1 == randint(1,15): if self.duck_alive == 0: connection.send_channel("*. *. *. * < *. *. * Quack!") self.duck_alive = 1 From 2978d48712a182de14f21ee1fc4cd086437822e1 Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Sat, 25 Jun 2022 10:13:18 +0200 Subject: [PATCH 07/15] added Duckhunt achievements --- FaustBot/Modules/DuckObserver.py | 41 +++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/FaustBot/Modules/DuckObserver.py b/FaustBot/Modules/DuckObserver.py index 3d8618c..cde8ce9 100644 --- a/FaustBot/Modules/DuckObserver.py +++ b/FaustBot/Modules/DuckObserver.py @@ -55,6 +55,7 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): self.duck_alive = 0 self.addLivingDuck(data['nick']) connection.send_channel(self.build_duck_string(data['nick'])) + self.duckAchievments(data['nick'], connection) return if (self.duck_alive == 0 and self.active == 1): connection.send_channel(data['nick']+ " probiert eine nicht existente Ente zu befreunden.") @@ -68,6 +69,7 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): self.duck_alive = 0 self.addDeadDuck(data['nick']) connection.send_channel(self.build_duck_string(data['nick'])) + self.duckAchievments(data['nick'], connection) return if (self.duck_alive == 0 and self.active == 1): connection.send_channel(data['nick']+ " schießt ins Nichts.") @@ -118,7 +120,7 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): if livingDucks > 1: duckstring = duckstring + nick + " hat schon " +str(livingDucks)+ " befreundete Enten und " elif livingDucks == 1: - duckstring = duckstring + nick + " hat schon eine befreunde Ente und " + duckstring = duckstring + nick + " hat schon eine befreundete Ente und " elif livingDucks == 0: duckstring = duckstring + nick + " hat noch keine befreundeten Enten und " if deadDucks > 1: @@ -128,3 +130,40 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): elif deadDucks == 0: duckstring = duckstring+"keine getöteten Enten" return duckstring + + def duckAchievments(self, nick, connection): + if getDead(nick) == 0: + if getLiving(nick) == 5: + connection.send_channel(nick + " hat den Titel 'kleiner Entenfreund' erreicht") + elif getLiving(nick) == 66: + connection.send_channel(nick + " hat den Titel 'Entenfreund' erreicht") + elif getLiving(nick) == 111: + connection.send_channel(nick + " hat den Titel 'großer Entenfreund' erreicht") + elif getLiving(nick) == 555: + connection.send_channel(nick + " hat den Titel 'Kleiner Entenmonarch' erreicht") + elif getLiving(nick) == 1111: + connection.send_channel(nick + " hat den Titel 'Entenmonarch' erreicht") + + if getLiving(nick) == 0: + if getDead(nick) == 5: + connection.send_channel(nick + " hat den Titel 'kleiner Entenmörder' erreicht") + elif getDead(nick) == 66: + connection.send_channel(nick + " hat den Titel 'Entenmörder' erreicht") + elif getDead(nick) == 111: + connection.send_channel(nick + " hat den Titel 'großer Entenmörder' erreicht") + elif getDead(nick) == 555: + connection.send_channel(nick + " hat den Titel 'kleiner Entenmassenmörder' erreicht") + elif getDead(nick) == 1111: + connection.send_channel(nick + " hat den Titel 'Entenmassenmörder' erreicht") + + if getDead(nick) > 0 and getLiving(nick) > 0: + if getLiving(nick) + getDead(nick) == 5: + connection.send_channel(nick + " hat den Titel 'Enten könnten Angst vor dir haben' erreicht") + elif getLiving(nick) + getDead(nick) == 66: + connection.send_channel(nick + " hat den Titel 'Enten, Enten. So viele Enten' erreicht") + elif getLiving(nick) + getDead(nick) == 111: + connection.send_channel(nick + " hat den Titel 'Ich liebe Enten' erreicht") + elif getLiving(nick) + getDead(nick) == 555: + connection.send_channel(nick + " hat den Titel 'Auf dem Grill und als Freund. Enten sind mein Leben' erreicht") + elif getLiving(nick) + getDead(nick) == 1111: + connection.send_channel(nick + " hat den Titel 'Durchgespielt' erreicht") From 77b60b5fa98ec2250a4554d9c951c1c23b03ffa2 Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Sat, 25 Jun 2022 18:22:25 +0200 Subject: [PATCH 08/15] corrected Duck Achievements --- FaustBot/Modules/DuckObserver.py | 38 +++++++++++++++++--------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/FaustBot/Modules/DuckObserver.py b/FaustBot/Modules/DuckObserver.py index cde8ce9..e71ce04 100644 --- a/FaustBot/Modules/DuckObserver.py +++ b/FaustBot/Modules/DuckObserver.py @@ -132,38 +132,40 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): return duckstring def duckAchievments(self, nick, connection): - if getDead(nick) == 0: - if getLiving(nick) == 5: + dead = self.getDead(nick) + living = self.getLiving(nick) + if dead == 0: + if living == 5: connection.send_channel(nick + " hat den Titel 'kleiner Entenfreund' erreicht") - elif getLiving(nick) == 66: + elif living == 66: connection.send_channel(nick + " hat den Titel 'Entenfreund' erreicht") - elif getLiving(nick) == 111: + elif living == 111: connection.send_channel(nick + " hat den Titel 'großer Entenfreund' erreicht") - elif getLiving(nick) == 555: + elif living == 555: connection.send_channel(nick + " hat den Titel 'Kleiner Entenmonarch' erreicht") - elif getLiving(nick) == 1111: + elif living == 1111: connection.send_channel(nick + " hat den Titel 'Entenmonarch' erreicht") - if getLiving(nick) == 0: - if getDead(nick) == 5: + if living == 0: + if dead == 5: connection.send_channel(nick + " hat den Titel 'kleiner Entenmörder' erreicht") - elif getDead(nick) == 66: + elif dead == 66: connection.send_channel(nick + " hat den Titel 'Entenmörder' erreicht") - elif getDead(nick) == 111: + elif dead == 111: connection.send_channel(nick + " hat den Titel 'großer Entenmörder' erreicht") - elif getDead(nick) == 555: + elif dead == 555: connection.send_channel(nick + " hat den Titel 'kleiner Entenmassenmörder' erreicht") - elif getDead(nick) == 1111: + elif dead == 1111: connection.send_channel(nick + " hat den Titel 'Entenmassenmörder' erreicht") - if getDead(nick) > 0 and getLiving(nick) > 0: - if getLiving(nick) + getDead(nick) == 5: + if dead > 0 and living > 0: + if living + dead == 5: connection.send_channel(nick + " hat den Titel 'Enten könnten Angst vor dir haben' erreicht") - elif getLiving(nick) + getDead(nick) == 66: + elif living+ dead == 66: connection.send_channel(nick + " hat den Titel 'Enten, Enten. So viele Enten' erreicht") - elif getLiving(nick) + getDead(nick) == 111: + elif living + dead == 111: connection.send_channel(nick + " hat den Titel 'Ich liebe Enten' erreicht") - elif getLiving(nick) + getDead(nick) == 555: + elif living + dead == 555: connection.send_channel(nick + " hat den Titel 'Auf dem Grill und als Freund. Enten sind mein Leben' erreicht") - elif getLiving(nick) + getDead(nick) == 1111: + elif living + dead == 1111: connection.send_channel(nick + " hat den Titel 'Durchgespielt' erreicht") From bdd00c803c4d05821c142b844d5252961bf4cf52 Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Mon, 4 Jul 2022 08:53:52 +0200 Subject: [PATCH 09/15] added streaks to duckhunt --- FaustBot/Modules/DuckObserver.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/FaustBot/Modules/DuckObserver.py b/FaustBot/Modules/DuckObserver.py index e71ce04..07633ba 100644 --- a/FaustBot/Modules/DuckObserver.py +++ b/FaustBot/Modules/DuckObserver.py @@ -22,6 +22,8 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): super().__init__() self.active = 0 self.duck_alive = 0 + self.streak = 0 + self.streakname = "" def update_on_priv_msg(self, data, connection: Connection): if data['message'].find('.starthunt') != -1: @@ -169,3 +171,15 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): connection.send_channel(nick + " hat den Titel 'Auf dem Grill und als Freund. Enten sind mein Leben' erreicht") elif living + dead == 1111: connection.send_channel(nick + " hat den Titel 'Durchgespielt' erreicht") + + if nick == self.streakname: + self.streak+=1 + else: + self.streak = 0 + + if self.streak == 3: + connection.send_channel(nick + " hat einen Lauf") + elif self.streak == 5: + connection.send_channel(nick + " ist nicht aufhaltbar") + elif self.streak == 15: + connection.send_channel(nick + " spielt wohl allein") From 2777010b2e35843d68015bc7bb2327973a6abde2 Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Mon, 4 Jul 2022 10:57:03 +0200 Subject: [PATCH 10/15] Minor Error Correction in Duck Observr --- FaustBot/Modules/DuckObserver.py | 1 + 1 file changed, 1 insertion(+) diff --git a/FaustBot/Modules/DuckObserver.py b/FaustBot/Modules/DuckObserver.py index 07633ba..307f17f 100644 --- a/FaustBot/Modules/DuckObserver.py +++ b/FaustBot/Modules/DuckObserver.py @@ -176,6 +176,7 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): self.streak+=1 else: self.streak = 0 + self.streakname = nick if self.streak == 3: connection.send_channel(nick + " hat einen Lauf") From cd9cb5dc5d8dfc3d346f1d6239a21cb3fe7cd6c8 Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Fri, 15 Jul 2022 08:57:42 +0200 Subject: [PATCH 11/15] added the possibility to individualize greetings --- FaustBot/FaustBot.py | 2 +- FaustBot/Model/Config.py | 9 +++++++-- FaustBot/Modules/DuckObserver.py | 2 +- FaustBot/Modules/Greeter.py | 5 +++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/FaustBot/FaustBot.py b/FaustBot/FaustBot.py index 34b3275..65e1be8 100644 --- a/FaustBot/FaustBot.py +++ b/FaustBot/FaustBot.py @@ -53,7 +53,7 @@ class FaustBot(object): self.add_module(WordRunObserver.WordRunObserver()) self.add_module(GiveIceObserver.GiveIceObserver()) self.add_module(GiveDrinkToObserver.GiveDrinkToObserver()) - self.add_module(Greeter.Greeter()) + self.add_module(Greeter.Greeter(self.config.greeting)) self.add_module(MathRunObserver.MathRunObserver()) self.add_module(PartyObserver.PartyObserver()) self.add_module(PrideObserver.PrideObserver()) diff --git a/FaustBot/Model/Config.py b/FaustBot/Model/Config.py index dfb1490..0ade699 100644 --- a/FaustBot/Model/Config.py +++ b/FaustBot/Model/Config.py @@ -44,7 +44,8 @@ class Config(object): self._config_dict['blacklist'] = [] for module in blacklist: self._config_dict['blacklist'].append(module.strip()) - + if 'greeting' not in self._config_dict: + self._config_dict['greeting'] = "Hallo " @property def lang(self): return self._config_dict["lang"] @@ -75,4 +76,8 @@ class Config(object): @property def pwd(self): - return self._config_dict['pwd'] \ No newline at end of file + return self._config_dict['pwd'] + + @property + def greeting(self): + return self._config_dict['greeting'] \ No newline at end of file diff --git a/FaustBot/Modules/DuckObserver.py b/FaustBot/Modules/DuckObserver.py index 307f17f..7ee1369 100644 --- a/FaustBot/Modules/DuckObserver.py +++ b/FaustBot/Modules/DuckObserver.py @@ -175,7 +175,7 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): if nick == self.streakname: self.streak+=1 else: - self.streak = 0 + self.streak = 1 self.streakname = nick if self.streak == 3: diff --git a/FaustBot/Modules/Greeter.py b/FaustBot/Modules/Greeter.py index f781793..d5d2655 100644 --- a/FaustBot/Modules/Greeter.py +++ b/FaustBot/Modules/Greeter.py @@ -16,9 +16,10 @@ class Greeter(JoinObserverPrototype): def help(): return None - def __init__(self): + def __init__(self, greeting): super().__init__() self.names = defaultdict(int) + self.greeting = greeting def update_on_join(self, data, connection: Connection): if data['channel'] == connection.details.get_channel(): @@ -27,5 +28,5 @@ class Greeter(JoinObserverPrototype): connection.send_back("Herzlich Willkommen bei uns "+data['nick'],data) self.names[data['nick']] = int(time.time()) return - connection.send_back("Hallo " + data['nick'], data) + connection.send_back(self.greeting+" " + data['nick'], data) self.names[data['nick']] = int(time.time()) \ No newline at end of file From 710b670c32e90bbe3b7c60c084d7a36fe9b62b62 Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Sun, 24 Jul 2022 09:07:35 +0200 Subject: [PATCH 12/15] Minor correction of an excess backspace --- FaustBot/Model/Config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FaustBot/Model/Config.py b/FaustBot/Model/Config.py index 0ade699..481abf1 100644 --- a/FaustBot/Model/Config.py +++ b/FaustBot/Model/Config.py @@ -45,7 +45,7 @@ class Config(object): for module in blacklist: self._config_dict['blacklist'].append(module.strip()) if 'greeting' not in self._config_dict: - self._config_dict['greeting'] = "Hallo " + self._config_dict['greeting'] = "Hallo" @property def lang(self): return self._config_dict["lang"] From a7c71cf2907231b6a242982c035600c9642b4626 Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Fri, 5 Aug 2022 08:40:38 +0200 Subject: [PATCH 13/15] Added new achievements in duckhunt --- FaustBot/Modules/DuckObserver.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/FaustBot/Modules/DuckObserver.py b/FaustBot/Modules/DuckObserver.py index 7ee1369..3e7cd24 100644 --- a/FaustBot/Modules/DuckObserver.py +++ b/FaustBot/Modules/DuckObserver.py @@ -147,6 +147,10 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): connection.send_channel(nick + " hat den Titel 'Kleiner Entenmonarch' erreicht") elif living == 1111: connection.send_channel(nick + " hat den Titel 'Entenmonarch' erreicht") + elif living == 2222: + connection.send_channel(nick + " hat den Titel 'großer Entenmonarch' erreicht") + elif living == 3333: + connection.send_channel(nick + " hat den Titel 'Enten veehren dich als ihre Gottheit!' erreicht") if living == 0: if dead == 5: @@ -159,7 +163,10 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): connection.send_channel(nick + " hat den Titel 'kleiner Entenmassenmörder' erreicht") elif dead == 1111: connection.send_channel(nick + " hat den Titel 'Entenmassenmörder' erreicht") - + elif dead == 2222: + connection.send_channel(nick + " hat den Titel 'großer Entenmassenmörder' erreicht") + elif dead == 3333: + connection.send_channel(nick + " hat den Titel 'du musst Enten wirklich hassen' erreicht") if dead > 0 and living > 0: if living + dead == 5: connection.send_channel(nick + " hat den Titel 'Enten könnten Angst vor dir haben' erreicht") @@ -171,6 +178,10 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): connection.send_channel(nick + " hat den Titel 'Auf dem Grill und als Freund. Enten sind mein Leben' erreicht") elif living + dead == 1111: connection.send_channel(nick + " hat den Titel 'Durchgespielt' erreicht") + elif living + dead == 2222: + connection.send_channel(nick + " hat den Titel 'Immernoch im Spiel' erreicht") + elif living + dead == 3333: + connection.send_channel(nick + " hat den Titel 'Alter!' erreicht") if nick == self.streakname: self.streak+=1 From 3485441228039b1f36f0cbc44c50b1940c127859 Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Fri, 5 Aug 2022 08:41:43 +0200 Subject: [PATCH 14/15] minor spelling mistake correction --- FaustBot/Modules/DuckObserver.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FaustBot/Modules/DuckObserver.py b/FaustBot/Modules/DuckObserver.py index 3e7cd24..cb517b2 100644 --- a/FaustBot/Modules/DuckObserver.py +++ b/FaustBot/Modules/DuckObserver.py @@ -150,7 +150,7 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): elif living == 2222: connection.send_channel(nick + " hat den Titel 'großer Entenmonarch' erreicht") elif living == 3333: - connection.send_channel(nick + " hat den Titel 'Enten veehren dich als ihre Gottheit!' erreicht") + connection.send_channel(nick + " hat den Titel 'Enten verehren dich als ihre Gottheit!' erreicht") if living == 0: if dead == 5: @@ -167,6 +167,7 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype): connection.send_channel(nick + " hat den Titel 'großer Entenmassenmörder' erreicht") elif dead == 3333: connection.send_channel(nick + " hat den Titel 'du musst Enten wirklich hassen' erreicht") + if dead > 0 and living > 0: if living + dead == 5: connection.send_channel(nick + " hat den Titel 'Enten könnten Angst vor dir haben' erreicht") From 55855b9c209226431adfd6dc88feb525896a3077 Mon Sep 17 00:00:00 2001 From: BaerbelBox Date: Fri, 12 Aug 2022 10:41:11 +0200 Subject: [PATCH 15/15] removed legacy i18n --- FaustBot/Modules/AllSeenObserver.py | 1 - FaustBot/Modules/BlockObserver.py | 5 ----- FaustBot/Modules/SeenObserver.py | 2 -- FaustBot/Modules/WikiObserver.py | 10 +++------- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/FaustBot/Modules/AllSeenObserver.py b/FaustBot/Modules/AllSeenObserver.py index 035e972..b23b77b 100644 --- a/FaustBot/Modules/AllSeenObserver.py +++ b/FaustBot/Modules/AllSeenObserver.py @@ -4,7 +4,6 @@ from collections import defaultdict from FaustBot.Communication.Connection import Connection from FaustBot.Model.UserProvider import UserProvider from FaustBot.Modules.PrivMsgObserverPrototype import PrivMsgObserverPrototype -from ..Model.i18n import i18n from FaustBot.Modules.UserList import UserList class AllSeenObserver(PrivMsgObserverPrototype): diff --git a/FaustBot/Modules/BlockObserver.py b/FaustBot/Modules/BlockObserver.py index 163b61c..6c503da 100644 --- a/FaustBot/Modules/BlockObserver.py +++ b/FaustBot/Modules/BlockObserver.py @@ -1,10 +1,5 @@ -import datetime -import time - from FaustBot.Communication.Connection import Connection -from FaustBot.Model.UserProvider import UserProvider from FaustBot.Modules.PrivMsgObserverPrototype import PrivMsgObserverPrototype -from ..Model.i18n import i18n from FaustBot.Model.BlockedUsers import BlockProvider class BlockObserver(PrivMsgObserverPrototype): diff --git a/FaustBot/Modules/SeenObserver.py b/FaustBot/Modules/SeenObserver.py index ca489cb..da7b501 100644 --- a/FaustBot/Modules/SeenObserver.py +++ b/FaustBot/Modules/SeenObserver.py @@ -1,10 +1,8 @@ import datetime -import time from FaustBot.Communication.Connection import Connection from FaustBot.Model.UserProvider import UserProvider from FaustBot.Modules.PrivMsgObserverPrototype import PrivMsgObserverPrototype -from ..Model.i18n import i18n class SeenObserver(PrivMsgObserverPrototype): diff --git a/FaustBot/Modules/WikiObserver.py b/FaustBot/Modules/WikiObserver.py index 080e337..0a3132b 100644 --- a/FaustBot/Modules/WikiObserver.py +++ b/FaustBot/Modules/WikiObserver.py @@ -1,6 +1,4 @@ from wikipedia import wikipedia - -from FaustBot.Model.i18n import i18n from FaustBot.Modules.PrivMsgObserverPrototype import PrivMsgObserverPrototype @@ -17,18 +15,16 @@ class WikiObserver(PrivMsgObserverPrototype): if data['message'].find('.w ') == -1: return - i18n_server = i18n() - w = wikipedia.set_lang(i18n_server.get_text('wiki_lang', lang=self.config.lang)) + w = wikipedia.set_lang('de') q = data['message'].split(' ') query = '' for word in q: if word.strip() != '.w': query += word + ' ' w = wikipedia.search(query) - if w.__len__() == 0: # TODO BUG BELOW, ERROR MESSAGE NOT SHOWN! + if w.__len__() == 0: connection.send_back(data['nick'] + ', ' + - i18n_server.get_text('wiki_fail', - lang=self.config.lang), + 'ich habe dazu keinen eintrag gefunden!', data) return try: