Skip to content

Commit

Permalink
admin: update set/unset responses to be more informative
Browse files Browse the repository at this point in the history
Previously, there was no feedback from the bot on successful
`set`/`unset`. This led to some confusion during testing. Now, the bot
will `say` "OK... " upon successful setting/unsetting of an option.
Additionally, viewing an option will also show the value `type` to
avoid issues like differentiating between `= None (NoneType)` and `=
None (str)`, where one may have intentionally set `None` as a `str`, or
accidentally set `None` while trying to clear/unset an option.
  • Loading branch information
HumorBaby committed Sep 3, 2019
1 parent a86d944 commit 01bcf40
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sopel/modules/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def set_config(bot, trigger):
value = "(password censored)"
else:
value = getattr(section, option)
bot.reply("%s.%s = %s" % (section_name, option, value))
bot.reply("%s.%s = %s (%s)" % (section_name, option, value, type(value).__name__))
return

# Owner-related settings cannot be modified interactively. Any changes to these
Expand All @@ -356,6 +356,7 @@ def set_config(bot, trigger):
bot.say("Can't set attribute: " + str(exc))
return
setattr(section, option, value)
bot.say("OK. Set '{}.{}' successfully.".format(section_name, option))


@sopel.module.require_privmsg("This command only works as a private message.")
Expand Down Expand Up @@ -388,6 +389,7 @@ def unset_config(bot, trigger):

try:
setattr(section, option, None)
bot.say("OK. Unset '{}.{}' successfully.".format(section_name, option))
except ValueError:
bot.reply('Cannot unset {}.{}; it is a required option.'.format(section_name, option))

Expand Down

0 comments on commit 01bcf40

Please sign in to comment.