From da2b773bf6e669b3ec50bbd6af73e1d80bb0b5a5 Mon Sep 17 00:00:00 2001 From: Thor77 Date: Sun, 23 Jul 2017 17:44:16 +0200 Subject: [PATCH] Add tsstats/event.py for easy event-initialization --- tsstats/events.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tsstats/events.py diff --git a/tsstats/events.py b/tsstats/events.py new file mode 100644 index 0000000..b2372bb --- /dev/null +++ b/tsstats/events.py @@ -0,0 +1,33 @@ +from collections import namedtuple + +Event = namedtuple( + 'Event', ['timestamp', 'identifier', 'action', 'arg', 'arg_is_client'] +) + + +def nick(timestamp, identifier, nick): + return Event(timestamp, identifier, 'set_nick', nick, arg_is_client=False) + + +def connect(timestamp, identifier): + return Event( + timestamp, identifier, 'connect', arg=timestamp, arg_is_client=False + ) + + +def disconnect(timestamp, identifier): + return Event( + timestamp, identifier, 'disconnect', arg=timestamp, arg_is_client=False + ) + + +def kick(timestamp, identifier, target_identifier): + return Event( + timestamp, identifier, 'kick', target_identifier, arg_is_client=True + ) + + +def ban(timestamp, identifier, target_identifier): + return Event( + timestamp, identifier, 'ban', target_identifier, arg_is_client=True + )