aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRahiel Kasim <rahiel@protonmail.ch>2015-12-19 22:07:00 +0100
committerRahiel Kasim <rahiel@protonmail.ch>2015-12-19 22:07:00 +0100
commit37b09cc0d19c950f4b42b7df9dde7bf656de4e6b (patch)
tree908298ad604976aeee00cd765845cd07b0c933f3
parentd74591c7701c2c1c4e49eba7c92eeeba77c628f0 (diff)
print time in logs, refactor quran methods
-rw-r--r--bismillah.py3
-rwxr-xr-xquran.py12
2 files changed, 8 insertions, 7 deletions
diff --git a/bismillah.py b/bismillah.py
index 9a129ed..5dc10a6 100644
--- a/bismillah.py
+++ b/bismillah.py
@@ -19,6 +19,7 @@
import re
from time import sleep
from urllib2 import URLError
+from time import time
import sys
import telegram
@@ -148,7 +149,7 @@ def serve(bot, update_id, data):
else:
s, a, quran_type = 1, 1, "english"
- print("%d: %s" % (chat_id, message))
+ print("%d:%.3f:%s" % (chat_id, time(), message))
if chat_id < 0:
continue # bot should not be in a group
diff --git a/quran.py b/quran.py
index 81df2b5..565baa8 100755
--- a/quran.py
+++ b/quran.py
@@ -109,14 +109,14 @@ class Quran(object):
"""Get range of Ayahs as tuple """
return ' '.join(self.text[surah - 1][a - 1:b]) + " (%d:%d-%d)" % (surah, a, b)
- @classmethod
- def getRandomAyah(cls):
+ @staticmethod
+ def getRandomAyah():
surah = randint(1, 114)
ayah = randint(1, Quran.surah_lengths[surah])
return surah, ayah
- @classmethod
- def getNextAyah(cls, s, a):
+ @staticmethod
+ def getNextAyah(s, a):
length = Quran.surah_lengths[s]
if a == length:
s = s + 1 if s < 114 else 1
@@ -125,8 +125,8 @@ class Quran(object):
a += 1
return s, a
- @classmethod
- def getPreviousAyah(cls, s, a):
+ @staticmethod
+ def getPreviousAyah(s, a):
if a == 1:
s = s - 1 if s > 1 else 114
a = Quran.surah_lengths[s]