mmueller / supybot-git

A Git plugin for Supybot (a Python IRC bot)
45 stars 24 forks source link

Don't print commits to lobotomized channels. #18

Open ShadowNinja opened 11 years ago

ShadowNinja commented 11 years ago

I added this with only one or two lines in one function.

Edit: Here is a diff:

diff --git a/plugin.py b/plugin.py
index b85389b..742f205 100644
--- a/plugin.py
+++ b/plugin.py
@@ -29,6 +29,7 @@ from supybot.commands import *
 import supybot.plugins as plugins
 import supybot.ircmsgs as ircmsgs
 import supybot.ircutils as ircutils
+import supybot.ircdb as ircdb
 import supybot.callbacks as callbacks
 import supybot.schedule as schedule
 import supybot.log as log
@@ -389,6 +390,8 @@ class Git(callbacks.PluginRegexp):

     def _display_commits(self, irc, channel, repository, commits):
         "Display a nicely-formatted list of commits in a channel."
+       if ircdb.channels.getChannel(channel).lobotomized:
+               return
         commits = list(commits)
         commits_at_once = self.registryValue('maxCommitsAtOnce')
         if len(commits) > commits_at_once:
mmueller commented 10 years ago

Hah, I didn't know about this feature. Why are plugins obligated to respect the setting? Seems like the bot should be capable of enforcing the silence with or without plugins' cooperation.

ShadowNinja commented 10 years ago

There are cases where you want the message to get through even in lobotomized channels though, such as when the owner triggers a command (the owner is never to be ignored). The bot does handle chat commands automatically; but this is triggered externally, so it doesn't know if it should be blocked.