aboutsummaryrefslogtreecommitdiffstats
path: root/local/utility.py
diff options
context:
space:
mode:
authorkongr45gpen <electrovesta@gmail.com>2016-09-16 14:14:41 +0300
committerkongr45gpen <electrovesta@gmail.com>2016-09-16 14:29:53 +0300
commit97483dc403c2ac89f9647bfb5f4982c7f1e83259 (patch)
treefdef8d0566452a52cb66b89ca5d08d0b7e926a67 /local/utility.py
parent3902f3b980c0e2a885b965b4f2503244c3e68782 (diff)
downloadsupybot_github-97483dc403c2ac89f9647bfb5f4982c7f1e83259.tar.gz
supybot_github-97483dc403c2ac89f9647bfb5f4982c7f1e83259.tar.bz2
supybot_github-97483dc403c2ac89f9647bfb5f4982c7f1e83259.zip
Don't send the issue name if it appears too often
Diffstat (limited to 'local/utility.py')
-rw-r--r--local/utility.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/local/utility.py b/local/utility.py
index 065be0f..9120104 100644
--- a/local/utility.py
+++ b/local/utility.py
@@ -3,6 +3,7 @@ import math
import random
import string
import urllib2
+from datetime import datetime, timedelta
import supybot.conf as conf
import supybot.world as world
@@ -163,6 +164,24 @@ def getChannelSecret(channel):
except KeyError:
return None
+def showIssueName(repoId, issueId):
+ """Returns whether we should show the issue name for a repo issue"""
+ now = datetime.now()
+
+ if not repoId in globals.shownIssues:
+ globals.shownIssues[repoId] = {}
+
+ # Clean up old issues
+ remove = [k for k in globals.shownIssues[repoId] if now - globals.shownIssues[repoId][k] > timedelta(seconds = 15)]
+ for k in remove: del globals.shownIssues[repoId][k]
+
+ exists = issueId in globals.shownIssues[repoId]
+
+ # Add our issue to the list
+ globals.shownIssues[repoId][issueId] = now
+
+ return not exists
+
def hexToMirc(hash):
colors = {
'white': (255, 255, 255),

© 2014-2024 Faster IT GmbH | imprint | privacy policy