From 10bc184c774485d96bc43d25725da53f7a4938f7 Mon Sep 17 00:00:00 2001 From: khuxkm fbexl Date: Fri, 2 Jul 2021 03:28:55 +0000 Subject: [PATCH 1/2] Add module for beat time --- modules/beat.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 modules/beat.py diff --git a/modules/beat.py b/modules/beat.py new file mode 100644 index 00000000..b7b9e2d1 --- /dev/null +++ b/modules/beat.py @@ -0,0 +1,15 @@ +from src import ModuleManager, utils +import datetime + +class Module(ModuleManager.BaseModule): + _name = "beat" + + @utils.hook("received.command.beat") + @utils.kwarg("help","Gives the current Swatch Internet Time (aka .beat time)") + def beat(self, event): + now = datetime.datetime.utcnow() + hour = (now.hour+1)%24 + minutes = now.minute + seconds = now.second + beat_time = ((hours*3600)+(minutes*60)+seconds)/86.4 + event["stdout"].write("The current time is @%0.2f." % (beat_time)) From b1699a8c5e41048b7c3814355a6b6468faa6649e Mon Sep 17 00:00:00 2001 From: khuxkm fbexl Date: Fri, 2 Jul 2021 03:32:51 +0000 Subject: [PATCH 2/2] Update modules/beat.py to follow PEP8 style --- modules/beat.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/beat.py b/modules/beat.py index b7b9e2d1..bb9e61a5 100644 --- a/modules/beat.py +++ b/modules/beat.py @@ -2,14 +2,15 @@ import datetime class Module(ModuleManager.BaseModule): - _name = "beat" + _name = "beat" - @utils.hook("received.command.beat") - @utils.kwarg("help","Gives the current Swatch Internet Time (aka .beat time)") - def beat(self, event): - now = datetime.datetime.utcnow() - hour = (now.hour+1)%24 - minutes = now.minute - seconds = now.second - beat_time = ((hours*3600)+(minutes*60)+seconds)/86.4 - event["stdout"].write("The current time is @%0.2f." % (beat_time)) + + @utils.hook("received.command.beat") + @utils.kwarg("help","Gives the current .beat time") + def beat(self, event): + now = datetime.datetime.utcnow() + hour = (now.hour+1)%24 + minutes = now.minute + seconds = now.second + beat_time = ((hours*3600)+(minutes*60)+seconds)/86.4 + event["stdout"].write("The current time is @%0.2f." % (beat_time))