Implement config variable to require voice to use all commands and code in functions.

This commit is contained in:
spline 2013-05-26 15:35:54 -04:00
parent 026ca36ec7
commit 2312fe4199
2 changed files with 13 additions and 0 deletions

View File

@ -28,5 +28,6 @@ conf.registerChannelValue(Tweety,'defaultResults',registry.Integer(1, """Default
conf.registerChannelValue(Tweety,'maxResults',registry.Integer(10, """Maximum number of results to return on timelines."""))
conf.registerChannelValue(Tweety,'outputColorTweets',registry.Boolean(False, """When outputting Tweets, display them with some color."""))
conf.registerChannelValue(Tweety,'hideHashtagsTrends',registry.Boolean(False, """When displaying trends, should we display #hashtags? Default is no."""))
conf.registerChannelValue(Tweety,'requireVoiceOrAbove',registry.Boolean(False, """Only allows a user with voice or above on a channel to use commands."""))
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=250:

View File

@ -334,6 +334,10 @@ class Tweety(callbacks.Plugin):
Use --exclude to not include #hashtags in trends data.
"""
# enforce +voice or above to use command?
if self.registryValue('requireVoiceOrAbove', msg.args[0]) and not irc.state.channels[msg.args[0]].isVoicePlus(msg.nick):
irc.error("ERROR: You have to be at least voiced to use this command.")
# before we do anything, make sure we have a twitterApi object.
if not self.twitterApi:
irc.reply("ERROR: Twitter is not authorized. Please check logs before running this command.")
@ -378,6 +382,10 @@ class Tweety(callbacks.Plugin):
searchtype being recent, popular or mixed. Popular is the default.
"""
# enforce +voice or above to use command?
if self.registryValue('requireVoiceOrAbove', msg.args[0]) and not irc.state.channels[msg.args[0]].isVoicePlus(msg.nick):
irc.error("ERROR: You have to be at least voiced to use this command.")
# before we do anything, make sure we have a twitterApi object.
if not self.twitterApi:
irc.reply("ERROR: Twitter is not authorized. Please check logs before running this command.")
@ -431,6 +439,10 @@ class Tweety(callbacks.Plugin):
Or returns information on user with --info 'name'.
"""
# enforce +voice or above to use command?
if self.registryValue('requireVoiceOrAbove', msg.args[0]) and not irc.state.channels[msg.args[0]].isVoicePlus(msg.nick):
irc.error("ERROR: You have to be at least voiced to use this command.")
# before we do anything, make sure we have a twitterApi object.
if not self.twitterApi:
irc.reply("ERROR: Twitter is not authorized. Please check logs before running this command.")