old_contents: import sys
  import os
  import configparser
  import importlib
  
  # Make sure we're using the right python. Assume we're running out of the venv.
  INTERP = os.path.join(os.getcwd(), 'bin', 'python')
  if sys.executable != INTERP:
      os.execl(INTERP, INTERP, *sys.argv)
      sys.path.append(os.getcwd())
  
  config = configparser.ConfigParser()
  config.read("config.ini")
  
  bots = {}
  for bot in config.sections():
      if "webhook" not in config[bot]:
          continue
      if "repo_name" not in config[bot]:
          raise RuntimeError("Cannot find repo for bot {0}".format(bot))
      bot_path = os.path.join(os.getcwd(), config[bot]["repo_name"])
      if not os.path.isdir(bot_path):
          raise RuntimeError("Cannot find path {0} for bot {1}".format(bot_path,
                                                                       bot))
      sys.path.append(bot_path)
      # Assume the bot module is the same as the config file
      if "module_name" not in config[bot]:
          raise RuntimeError("Cannot find module for bot {0}".format(bot))
      module = config[bot]["module_name"]
      importlib.import_module(module)
      bots[config[bot]["token"]] = getattr(sys.modules[module],
                                           "create_bot")(config[bot])
  
  from flask import Flask, request
  import telegram
  
  application = Flask(__name__)
  
  
  @application.route('/')
  def hello():
      return ""
  
  
  @application.route('/telegram/<token>', methods=['POST'])
  def webhook(token):
      update = telegram.update.Update.de_json(request.get_json(force=True))
      if token not in bots.keys():
          return 'OK'
      bots[token].update_queue.put(update)
      return 'OK'
  
  
  if __name__ == "__main__":
      application.run()
  
new_contents: import sys
  import os
  
  # Make sure we're using the right python. Assume we're running out of the venv.
  INTERP = os.path.join(os.getcwd(), 'bin', 'python')
  if sys.executable != INTERP:
      os.execl(INTERP, INTERP, *sys.argv)
      sys.path.append(os.getcwd())
  
  import configparser
  import importlib
  
  config = configparser.ConfigParser()
  config.read("config.ini")
  
  bots = {}
  for bot in config.sections():
      if "webhook" not in config[bot]:
          continue
      if "repo_name" not in config[bot]:
          raise RuntimeError("Cannot find repo for bot {0}".format(bot))
      bot_path = os.path.join(os.getcwd(), config[bot]["repo_name"])
      if not os.path.isdir(bot_path):
          raise RuntimeError("Cannot find path {0} for bot {1}".format(bot_path,
                                                                       bot))
      sys.path.append(bot_path)
      # Assume the bot module is the same as the config file
      if "module_name" not in config[bot]:
          raise RuntimeError("Cannot find module for bot {0}".format(bot))
      module = config[bot]["module_name"]
      importlib.import_module(module)
      bots[config[bot]["token"]] = getattr(sys.modules[module],
                                           "create_bot")(config[bot])
  
  from flask import Flask, request
  import telegram
  
  application = Flask(__name__)
  
  
  @application.route('/')
  def hello():
      return ""
  
  
  @application.route('/telegram/<token>', methods=['POST'])
  def webhook(token):
      update = telegram.update.Update.de_json(request.get_json(force=True))
      if token not in bots.keys():
          return 'OK'
      bots[token].update_queue.put(update)
      return 'OK'
  
  
  if __name__ == "__main__":
      application.run()
  
subject: Move imports after venv change