From 2c01a0b7cb1d792f9eb686218b8e21ebe3c2a33e Mon Sep 17 00:00:00 2001 From: Context 77 <126421199+ctx77@users.noreply.github.com> Date: Sat, 3 Aug 2024 00:46:13 +0200 Subject: [PATCH] Add "template" support for first-greet to put the nickname into the greeting instead of only at the end --- FaustBot/Modules/First_Greeter.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/FaustBot/Modules/First_Greeter.py b/FaustBot/Modules/First_Greeter.py index b1d9f6c..80a2b94 100644 --- a/FaustBot/Modules/First_Greeter.py +++ b/FaustBot/Modules/First_Greeter.py @@ -2,6 +2,8 @@ from FaustBot.Communication.Connection import Connection from FaustBot.Modules.JoinObserverPrototype import JoinObserverPrototype from FaustBot.Model.UserProvider import UserProvider from time import sleep + + class First_Greeter(JoinObserverPrototype): """ A Class only reacting to pings @@ -20,12 +22,15 @@ class First_Greeter(JoinObserverPrototype): self.first_greeting = greeting def update_on_join(self, data, connection: Connection): - if data['channel'] == connection.details.get_channel(): - if data['nick'].find("Guest") != -1: + if data["channel"] == connection.details.get_channel(): + new_nick = data["nick"] + if ( + new_nick.startswith("Guest") + or UserProvider().get_characters(new_nick) < 100 + ): sleep(20) - connection.send_back(self.first_greeting + " " + data['nick'], data) - return - UProvider= UserProvider() - if(UProvider.get_characters(data['nick'])) < 100: - sleep(20) - connection.send_back(self.first_greeting + " " + data['nick'], data) \ No newline at end of file + if "{NICK}" in self.first_greeting: + greeting = self.first_greeting.replace("{NICK}", new_nick) + else: + greeting = f"{self.first_greeting} {new_nick}" + connection.send_back(greeting, data)