Skip to content

Commit

Permalink
admin: add unset command
Browse files Browse the repository at this point in the history
  • Loading branch information
HumorBaby committed Apr 15, 2019
1 parent ebe644a commit cbf8fb3
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions sopel/modules/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,39 @@ def set_config(bot, trigger):
setattr(section, option, value)


@sopel.module.require_privmsg("This command only works as a private message.")
@sopel.module.require_admin("This command requires admin privileges.")
@sopel.module.commands('unset')
@sopel.module.example('.unset core.owner')
def unset_config(bot, trigger):
"""Unset value of Sopel's config object.
Unsetting a value will reset it to the default specified in the config
defintion.
Trigger args:
arg1 - section and option, in the form "section.option"
If there is no section, section will default to "core".
"""
# Get section and option from first argument.
parsed = parse_section_option_value(bot, trigger)
if parsed is False:
bot.reply('Usage: .unset section.option')
return

if not parsed: # parsed = ()
# Bot already said "Option not found..."
return

(section, section_name, static_sec, option, value) = parsed
if value:
bot.reply('Invalid command; no value should be provided to unset.')
return

setattr(section, option, None)


@sopel.module.require_privmsg
@sopel.module.require_admin
@sopel.module.commands('save')
Expand Down

0 comments on commit cbf8fb3

Please sign in to comment.