From 40acd68a38e3446be3e280f3a3034e7714dfd21d Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sun, 25 Jan 2015 09:17:39 -0800 Subject: Adding a repository field to each application. --- deployerbot.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/deployerbot.py b/deployerbot.py index f579e95..2ce5b0b 100644 --- a/deployerbot.py +++ b/deployerbot.py @@ -11,7 +11,7 @@ bot's nick. It will respond to the follow commands: * deploy * list webhooks - * add webhook for with url and secret + * add webhook for with url and secret * remove webhook for """ class DeployerBot: @@ -20,7 +20,11 @@ class DeployerBot: self.__version__ = "0.0.1" self.deploy_pattern = re.compile(r"deploy (?:(?:the )?application )?(\S+)", re.IGNORECASE) self.list_pattern = re.compile(r"list (?:.* )?webhooks", re.IGNORECASE); - self.add_pattern = re.compile(r"add (?:.* )?webhook (?:(?:.* )?(?:application|for) )?(\S+) (?:(?:.* )?(?:url|address) )?(\S+) (?:(?:.* )secret )?(\S+)", re.IGNORECASE) + self.add_pattern = re.compile(r"add (?:.* )?webhook " \ + r"(?:(?:.* )?(?:application|for|named) )?(\S+) " \ + r"(?:(?:.* )?repo(?:sitory)? )?(\S+) " \ + r"(?:(?:.* )?(?:url|address) )?(\S+) " \ + r"(?:(?:.* )?secret )?(\S+)", re.IGNORECASE) self.applications = dict() @@ -52,8 +56,8 @@ class DeployerBot: matches = self.add_pattern.findall(msg) if matches is not None: - for application, url, secret in matches: - self.addApplication(IRC, sender, dest, application, url, secret) + for application, repo, url, secret in matches: + self.addApplication(IRC, sender, dest, application, repo, url, secret) return def deploy(self, IRC, sender, dest, application): @@ -62,15 +66,16 @@ class DeployerBot: def listWebHooks(self, IRC, sender, dest): if self.applications: - msg = "I know the following applications: " + ", ".join([app for (app, url, key) in self.applications.values()]) + msg = "I know the following applications: " \ + ", ".join([app for (app, repo, url, key) in self.applications.values()]) dest.msg(msg) else: dest.msg("I don't have any hooks :(") - def addApplication(self, IRC, sender, dest, application, url, secret): + def addApplication(self, IRC, sender, dest, application, repo, url, secret): key = application.lower() if key in self.applications: dest.msg("I already have an application called %s" % application) else: - self.applications[key] = (application, url, secret) + self.applications[key] = (application, repo, url, secret) dest.msg("I've added application %s" % application) -- cgit v1.2.3