code: def do_reload(bot, target, cmdargs, server_send=None):
      
  
      def send(msg):
          if server_send is not None:
              server_send("%s\n" % msg)
          else:
              do_log(bot.connection, bot.get_target(target), msg)
  
      confdir = bot.handler.confdir
  
      if cmdargs == 'pull':
          # Permission checks.
          if isinstance(target, irc.client.Event) and target.source.nick != bot.config['auth']['owner']:
              bot.connection.privmsg(bot.get_target(target), "Nope, not gonna do it.")
              return
          if exists(join(confdir, '.git')):
              send(misc.do_pull(srcdir=confdir))
          else:
              send(misc.do_pull(repo=bot.config['api']['githubrepo']))
      # Reload config
      importlib.reload(config)
      bot.config = config.load_config(join(confdir, 'config.cfg'), send)
      # Reimport helpers
      errored_helpers = modutils.scan_and_reimport('helpers')
      if errored_helpers:
          send("Failed to load some helpers.")
          for error in errored_helpers:
              send("%s: %s" % error)
          return False
      if not load_modules(bot.config, confdir, send):
          return False
  
      # preserve data
      data = bot.handler.get_data()
      bot.shutdown_mp()
      bot.handler = handler.BotHandler(bot.config, bot.connection, bot.channels, confdir)
      bot.handler.set_data(data)
      bot.handler.connection = bot.connection
      bot.handler.channels = bot.channels
      return True
docs: The reloading magic.
  
      - First, reload handler.py.
      - Then make copies of all the handler data we want to keep.
      - Create a new handler and restore all the data.