properly call admin functions within do.
before this, recursion type stuff wasn't responded to properly because do wasn't returning the methods' text
This commit is contained in:
parent
8c1c10a4bc
commit
053c3f0ae6
@ -59,19 +59,26 @@ class IrcAdmin(Module):
|
||||
except NoOptionError: pass
|
||||
|
||||
def do(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||
# this could be more sophisticated, but i'm too lazy to do a real port
|
||||
# right now.
|
||||
"""Try all the admin methods."""
|
||||
|
||||
# TODO: sophisticate. also, document all of these
|
||||
self.sub_join_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||
self.sub_part_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||
self.sub_quit_irc(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||
self.sub_autojoin_manipulate(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||
self.sub_save_config(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||
self.sub_change_nick(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||
|
||||
whats = what.split(' ')
|
||||
|
||||
if whats[0] == 'join' and admin_unlocked and len(whats) >= 2:
|
||||
return self.sub_join_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||
elif whats[0] == 'part' and admin_unlocked and len(whats) >= 2:
|
||||
return self.sub_part_channel(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||
elif whats[0] == 'quit' and admin_unlocked:
|
||||
return self.sub_quit_irc(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||
elif whats[0] == 'autojoin' and admin_unlocked and len(whats) >= 3:
|
||||
return self.sub_autojoin_manipulate(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||
elif whats[0] == 'config' and whats[1] == 'save' and admin_unlocked:
|
||||
return self.sub_save_config(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||
elif whats[0] == 'nick' and admin_unlocked and len(whats) >= 2:
|
||||
return self.sub_change_nick(connection, event, nick, userhost, replypath, what, admin_unlocked)
|
||||
|
||||
def sub_join_channel(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||
whats = what.split(' ')
|
||||
if whats[0] == 'join' and admin_unlocked and len(whats) >= 2:
|
||||
channel = whats[1]
|
||||
if irclib.is_channel(channel):
|
||||
connection.join(channel)
|
||||
@ -79,8 +86,6 @@ class IrcAdmin(Module):
|
||||
return self.reply(connection, replypath, replystr)
|
||||
|
||||
def sub_part_channel(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||
whats = what.split(' ')
|
||||
if whats[0] == 'part' and admin_unlocked and len(whats) >= 2:
|
||||
channel = whats[1]
|
||||
if irclib.is_channel(channel):
|
||||
connection.part(channel, ' '.join(whats[2:]))
|
||||
@ -88,8 +93,6 @@ class IrcAdmin(Module):
|
||||
return self.reply(connection, replypath, replystr)
|
||||
|
||||
def sub_quit_irc(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||
whats = what.split(' ')
|
||||
if whats[0] == 'quit' and admin_unlocked:
|
||||
if replypath is not None:
|
||||
connection.privmsg(replypath, 'quitting')
|
||||
connection.quit(' '.join(whats[1:]))
|
||||
@ -97,8 +100,6 @@ class IrcAdmin(Module):
|
||||
sys.exit()
|
||||
|
||||
def sub_autojoin_manipulate(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||
whats = what.split(' ')
|
||||
if whats[0] == 'autojoin' and admin_unlocked and len(whats) >= 3:
|
||||
if whats[1] == 'add':
|
||||
try:
|
||||
# get existing list
|
||||
@ -123,16 +124,12 @@ class IrcAdmin(Module):
|
||||
except NoOptionError: pass
|
||||
|
||||
def sub_save_config(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||
whats = what.split(' ')
|
||||
if whats[0] == 'config' and whats[1] == 'save' and admin_unlocked:
|
||||
with open('dr.botzo.cfg', 'w') as cfg:
|
||||
self.config.write(cfg)
|
||||
replystr = 'saved config file'
|
||||
return self.reply(connection, replypath, replystr)
|
||||
|
||||
def sub_change_nick(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
|
||||
whats = what.split(' ')
|
||||
if whats[0] == 'nick' and admin_unlocked and len(whats) >= 2:
|
||||
newnick = whats[1]
|
||||
connection.nick(newnick)
|
||||
self.config.set('dr.botzo', 'nick', newnick)
|
||||
|
Loading…
Reference in New Issue
Block a user