diff options
Diffstat (limited to 'gitnoti.py')
-rwxr-xr-x | gitnoti.py | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -11,6 +11,7 @@ parser.add_option('-s', '--host') parser.add_option('-n', '--nick', default = 'git') parser.add_option('-d', '--dir') parser.add_option('-c', '--channel') +parser.add_option('-i', '--interval', type = 'int', default = 30) (options, args) = parser.parse_args() @@ -44,8 +45,14 @@ def check_repos(bot): else: old_paths = [os.path.basename(x[0].path) for x in repos] new_paths = [x for x in repo_paths if not x in old_paths] - for n in new_paths: - repos.append([git.Repo('%s/%s' % (root, x)), None]) + del_paths = [x for x in old_paths if not x in repo_paths] + del_repos = [x for x in repos if os.path.basename(x[0].path) in del_paths] + if del_repos: + bot.gitmsg('Removed repo%s: %s' % ('' if len(del_paths) == 1 else '', ', '.join([os.path.splitext(x)[0] for x in del_paths]))) + for i in del_repos: + repos.remove(i) + for i in new_paths: + repos.append([git.Repo('%s/%s' % (root, i)), None]) if new_paths: bot.gitmsg('New repo%s: %s' % ('' if len(new_paths) == 1 else 's', ', '.join([os.path.splitext(x)[0] for x in new_paths]))) @@ -70,7 +77,7 @@ class Bot(irc.IRCClient): def signedOn(self): self.join(options.channel) self.repeater = LoopingCall(check_repos, self) - self.repeater.start(5) + self.repeater.start(options.interval) def privmsg(self, user, channel, message): private = channel == self.nickname |