.character f-string + startswith

This commit is contained in:
Context 77
2024-08-03 00:04:23 +02:00
parent b2cef2da94
commit 3e289134f9

View File

@@ -1,5 +1,3 @@
import datetime
from FaustBot.Communication.Connection import Connection
from FaustBot.Model.UserProvider import UserProvider
from FaustBot.Modules.PrivMsgObserverPrototype import PrivMsgObserverPrototype
@@ -15,8 +13,7 @@ class CharactersCountObserver(PrivMsgObserverPrototype):
return ".characters - um abzufragen wieviel du bisher geschrieben hast."
def update_on_priv_msg(self, data, connection: Connection):
if data['message'].find('.characters') == -1:
return
user_provider = UserProvider()
output = data['nick']+": du hast "+str(user_provider.get_characters(data['nick']))+ " Zeichen geschrieben."
connection.send_back(output, data)
if data["message"].startswith(".characters"):
user_provider = UserProvider()
output = f"{data['nick']}: du hast {str(user_provider.get_characters(data['nick']))} Zeichen geschrieben."
connection.send_back(output, data)