self-serve-foods with startswith and f-strings

This commit is contained in:
Context 77
2024-08-03 01:35:26 +02:00
parent 5b5eb2b7ea
commit 31a0ef5153
3 changed files with 15 additions and 9 deletions

View File

@@ -15,6 +15,8 @@ class GiveFoodObserver(PrivMsgObserverPrototype):
return ".food - gibt etwas zu essen aus"
def update_on_priv_msg(self, data: dict, connection: Connection):
if data['message'].find('.food') == -1:
return
connection.send_back('\001ACTION tischt ' + data['nick'] + ' ' + random.choice(essen) + ' auf.\001', data)
if data["message"].startswith(".food"):
connection.send_back(
f"\001ACTION tischt {data['nick']} {random.choice(essen)} auf.\001",
data,
)