فهرست منبع

Adding a configurable 2 second delay before command execution

Kirk Trombley 6 سال پیش
والد
کامیت
3eed57be05
3فایلهای تغییر یافته به همراه6 افزوده شده و 2 حذف شده
  1. 1 0
      config/config.toml
  2. 3 1
      src/app.py
  3. 2 1
      src/config.py

+ 1 - 0
config/config.toml

@@ -1,4 +1,5 @@
 database = "/tmp/rollbot.sqlite"
+sleep_time = 2.0
 
 [plugins]
 simple = [ "info", "isadmin", "debug", "echo", "thanks", "guess", "meme", "unmeme", "greet", "console" ]

+ 3 - 1
src/app.py

@@ -5,7 +5,7 @@ from threading import Thread
 
 from flask import Flask, request, render_template
 
-from config import BOTS_LOOKUP
+from config import BOTS_LOOKUP, SLEEP_TIME
 from command_system import RollbotMessage, RollbotResponse, RollbotFailure
 from rollbot import Rollbot
 from util import post_message
@@ -76,6 +76,8 @@ def execute():
 
     def run_command_and_respond():
         app.logger.info(f"Entering command thread for {msg.message_id}")
+        app.logger.info(f"Sleeping for {SLEEP_TIME:.3f}s before executing command")
+        time.sleep(SLEEP_TIME)
         t = time.time()
         try:
             response = rollbot.run_command(msg)

+ 2 - 1
src/config.py

@@ -32,4 +32,5 @@ GROUP_ADMINS = get_secret("auths.group")
 PLUGINS = get_config("plugins")
 ALIASES = get_config("aliases")
 API_KEY = get_secret("api_key")
-DB_FILE = os.path.abspath(get_config("database"))
+DB_FILE = os.path.abspath(get_config("database"))
+SLEEP_TIME = float(get_config("sleep_time"))