check for channel with is_channel in a couple places where it's relevant

This commit is contained in:
Brian S. Stephan 2010-07-25 07:58:52 -05:00
parent f170743837
commit 934e8e3fe8
1 changed files with 16 additions and 12 deletions

View File

@ -15,8 +15,9 @@ import irclib
def sub_join_channel(connection, event, nick, userhost, replypath, what, admin_unlocked):
if what.split(' ')[0] == 'join' and admin_unlocked:
channel = what.split(' ')[1]
connection.join(channel)
connection.privmsg(replypath, 'joined ' + channel + '.')
if irclib.is_channel(channel):
connection.join(channel)
connection.privmsg(replypath, 'joined ' + channel + '.')
#####
# sub_part_channel
@ -27,8 +28,9 @@ def sub_join_channel(connection, event, nick, userhost, replypath, what, admin_u
def sub_part_channel(connection, event, nick, userhost, replypath, what, admin_unlocked):
if what.split(' ')[0] == 'part' and admin_unlocked:
channel = what.split(' ')[1]
connection.part(channel, ' '.join(what.split(' ')[2:]))
connection.privmsg(replypath, 'parted ' + channel + '.')
if irclib.is_channel(channel):
connection.part(channel, ' '.join(what.split(' ')[2:]))
connection.privmsg(replypath, 'parted ' + channel + '.')
#####
# sub_quit_channel
@ -55,19 +57,21 @@ def sub_autojoin_manipulate(connection, event, nick, userhost, replypath, what,
try:
# get existing list
channel = what.split(' ')[2]
channelset = set(config.get('channels', 'autojoin').split(','))
channelset.add(channel)
config.set('channels', 'autojoin', ','.join(channelset))
connection.privmsg(replypath, 'added ' + channel + ' to autojoin')
if irclib.is_channel(channel):
channelset = set(config.get('channels', 'autojoin').split(','))
channelset.add(channel)
config.set('channels', 'autojoin', ','.join(channelset))
connection.privmsg(replypath, 'added ' + channel + ' to autojoin')
except NoOptionError: pass
elif what.split(' ')[1] == 'remove':
try:
# get existing list
channel = what.split(' ')[2]
channelset = set(config.get('channels', 'autojoin').split(','))
channelset.discard(channel)
config.set('channels', 'autojoin', ','.join(channelset))
connection.privmsg(replypath, 'removed ' + channel + ' from autojoin')
if irclib.is_channel(channel):
channelset = set(config.get('channels', 'autojoin').split(','))
channelset.discard(channel)
config.set('channels', 'autojoin', ','.join(channelset))
connection.privmsg(replypath, 'removed ' + channel + ' from autojoin')
except NoOptionError: pass
#####