From 10a31387bed1f8ed00c8854299a7ae90f08a959d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 7 Nov 2022 13:03:32 +0100 Subject: fix formatting syntax --- logbot.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/logbot.py b/logbot.py index 9196f4e..6420dd7 100755 --- a/logbot.py +++ b/logbot.py @@ -252,8 +252,6 @@ class Logbot(SingleServerIRCBot): def format_event(self, name, event, params): msg = self.format[name] - for key, val in params.items(): - msg = msg.format(key = val) try: user_message = event.arguments()[0] @@ -269,14 +267,15 @@ class Logbot(SingleServerIRCBot): host = event.source(), channel = event.target(), color = self.color(nm_to_n(event.source())), - message = html_color(user_message)) + message = html_color(user_message), + **params) return msg def write_event(self, name, event, params={}): # Format the event properly if name == 'nick' or name == 'quit': - chans = params["{chan}"] + chans = params["chan"] else: chans = event.target() msg = self.format_event(name, event, params) @@ -403,17 +402,17 @@ class Logbot(SingleServerIRCBot): def on_kick(self, c, e): self.write_event("kick", e, - {"{kicker}" : e.source(), - "{channel}" : e.target(), - "{user}" : e.arguments()[0], - "{reason}" : e.arguments()[1], + {"kicker" : e.source(), + "channel" : e.target(), + "user" : e.arguments()[0], + "reason" : e.arguments()[1], }) def on_mode(self, c, e): self.write_event("mode", e, - {"{modes}" : e.arguments()[0], - "{person}" : e.arguments()[1] if len(e.arguments()) > 1 else e.target(), - "{giver}" : nm_to_n(e.source()), + {"modes" : e.arguments()[0], + "person" : e.arguments()[1] if len(e.arguments()) > 1 else e.target(), + "giver" : nm_to_n(e.source()), }) def on_nick(self, c, e): @@ -422,9 +421,9 @@ class Logbot(SingleServerIRCBot): for chan in self.channels: if old_nick in [x.lstrip('~%&@+') for x in self.channels[chan].users()]: self.write_event("nick", e, - {"{old}" : old_nick, - "{new}" : e.target(), - "{chan}": chan, + {"old" : old_nick, + "new" : e.target(), + "chan": chan, }) def on_part(self, c, e): @@ -447,7 +446,7 @@ class Logbot(SingleServerIRCBot): # Only write the event on channels that actually had the user in the channel for chan in self.channels: if nick in [x.lstrip('~%&@+') for x in self.channels[chan].users()]: - self.write_event("quit", e, {"{chan}" : chan}) + self.write_event("quit", e, {"chan" : chan}) def on_topic(self, c, e): self.write_event("topic", e) -- cgit v1.2.3-70-g09d2