snippetutil.py 667 B

123456789101112131415161718192021
  1. from util import commands
  2. from util import parse_line
  3. import sys
  4. from logger import Logger
  5. import inspect
  6. @commands(".snippet", ".snippets")
  7. def reload(bot, message, channel):
  8. logger = bot.logger
  9. parsed = parse_line(message)
  10. if parsed.startswith(".snippets reload"):
  11. try:
  12. bot.load_snippets()
  13. bot.set_snippets()
  14. bot.brain.notice(channel, "snippets reloaded")
  15. except:
  16. e = sys.exc_info()[0]
  17. logger.write(Logger.WARNING, bot.getName() + ": failed to reload snippets", bot.NICK)
  18. logger.write(Logger.WARNING, bot.getName() + ": error was:", bot.NICK)
  19. logger.write(Logger.WARNING, bot.getName() + ": " + e, bot.NICK)