def join_command(who, target, replyto, words):
'''Join a channel (join #etherboot)'''
- index = words.index('join') + 1
- if index < len(words):
- channel = words[index]
- return 'CMD', ('JOIN %s' % (channel.startswith('#') and channel or '#' + channel),)
+ if len(words) != 2:
+ return
+ channel = words[1]
+ return 'CMD', ('JOIN %s' % (channel.startswith('#') and channel or '#' + channel),)
op_commands['join'] = join_command
def part_command(who, target, replyto, words):
'''Leave a channel (part #etherboot)'''
- index = words.index('part') + 1
- if index < len(words):
- channel = words[index]
- return 'CMD', ('PART %s' % (channel.startswith('#') and channel or '#' + channel),)
+ if len(words) != 2:
+ return
+ channel = words[1]
+ return 'CMD', ('PART %s' % (channel.startswith('#') and channel or '#' + channel),)
op_commands['part'] = part_command
def privmsg_command(who, target, replyto, words):