update .seen: f-strings and answer "noch nicht gesehen" instead of 1970.

This commit is contained in:
Context 77
2024-08-03 01:41:25 +02:00
parent 31a0ef5153
commit 5854f28869

View File

@@ -15,18 +15,19 @@ class SeenObserver(PrivMsgObserverPrototype):
return ".seen <nick> - um abzufragen wann <nick> zuletzt hier war"
def update_on_priv_msg(self, data, connection: Connection):
if data['message'].find('.seen ') == -1:
return
if not self._is_idented_mod(data, connection):
return
who = data['message'].split(' ')[1]
user_provider = UserProvider()
activity = user_provider.get_activity(who)
output = data['nick']+": Ich habe "+who+" zuletzt am "+str(datetime.datetime.fromtimestamp(activity).strftime("%d.%m.%Y um %H:%M:%S"))+ ' Uhr gesehen'
if not self._is_idented_mod(data, connection):
connection.send_channel(output)
return
connection.send_back(output, data)
if data["message"].startswith(".seen ") and self._is_idented_mod(
data, connection
):
who = data["message"].split(" ")[1]
user_provider = UserProvider()
activity = user_provider.get_activity(who)
if activity == 0:
output = f"{data['nick']}: Ich habe {who} noch nicht gesehen."
else:
output = f"{data['nick']}: Ich habe {who} zuletzt am {str(datetime.datetime.fromtimestamp(activity).strftime('%d.%m.%Y um %H:%M:%S'))} Uhr gesehen."
connection.send_back(output, data)
def _is_idented_mod(self, data: dict, connection: Connection):
return data['nick'] in self._config.mods and connection.is_idented(data['nick'])
return data["nick"] in self._config.mods and connection.is_idented(data["nick"])