'timeout' -> 'cooldown'. closes #60

This commit is contained in:
jesopo 2019-06-16 17:05:40 +01:00
parent 002e1333a4
commit 4b61f837fb

View file

@ -113,7 +113,7 @@ CHECK_RUN_FAILURES = ["failure", "cancelled", "timed_out", "action_required"]
@utils.export("channelset", {"setting": "auto-github", @utils.export("channelset", {"setting": "auto-github",
"help": "Enable/disable automatically getting github issue/PR info", "help": "Enable/disable automatically getting github issue/PR info",
"validate": utils.bool_or_none, "example": "on"}) "validate": utils.bool_or_none, "example": "on"})
@utils.export("channelset", {"setting": "auto-github-timeout", @utils.export("channelset", {"setting": "auto-github-cooldown",
"help": "Set amount of seconds between auto-github duplicates", "help": "Set amount of seconds between auto-github duplicates",
"validate": utils.int_or_none, "example": "300"}) "validate": utils.int_or_none, "example": "300"})
class Module(ModuleManager.BaseModule): class Module(ModuleManager.BaseModule):
@ -240,12 +240,12 @@ class Module(ModuleManager.BaseModule):
def _cache_ref(self, ref): def _cache_ref(self, ref):
return "auto-github-%s" % ref.lower() return "auto-github-%s" % ref.lower()
def _auto_github_timeout(self, channel, ref): def _auto_github_cooldown(self, channel, ref):
timeout = channel.get_setting("auto-github-timeout", None) cooldown = channel.get_setting("auto-github-cooldown", None)
if not timeout == None: if not cooldown == None:
cache = self._cache_ref(ref) cache = self._cache_ref(ref)
if not self.bot.cache.has_item(cache): if not self.bot.cache.has_item(cache):
self.bot.cache.temporary_cache(cache, timeout) self.bot.cache.temporary_cache(cache, cooldown)
return True return True
else: else:
return False return False
@ -262,7 +262,7 @@ class Module(ModuleManager.BaseModule):
event.eat() event.eat()
ref = "%s/%s#%s" % (event["match"].group(1), ref = "%s/%s#%s" % (event["match"].group(1),
event["match"].group(2), event["match"].group(4)) event["match"].group(2), event["match"].group(4))
if self._auto_github_timeout(event["target"], ref): if self._auto_github_cooldown(event["target"], ref):
try: try:
result = self._get_info(event["target"], ref) result = self._get_info(event["target"], ref)
except utils.EventError: except utils.EventError:
@ -281,7 +281,7 @@ class Module(ModuleManager.BaseModule):
if event["target"].get_setting("auto-github", False): if event["target"].get_setting("auto-github", False):
event.eat() event.eat()
ref = event["match"].group(0) ref = event["match"].group(0)
if self._auto_github_timeout(event["target"], ref): if self._auto_github_cooldown(event["target"], ref):
try: try:
result = self._get_info(event["target"], result = self._get_info(event["target"],
event["match"].group(0)) event["match"].group(0))