Răsfoiți Sursa

Adding configuration to adjust the delay between MAL requests

Penta 5 ani în urmă
părinte
comite
3c471bbbb0
3 a modificat fișierele cu 6 adăugiri și 2 ștergeri
  1. 3 0
      myanimebot.example.conf
  2. 2 2
      myanimebot.py
  3. 1 0
      myanimebot/globals.py

+ 3 - 0
myanimebot.example.conf

@@ -22,6 +22,9 @@ secondMax = 7200
 # How much time should the bot need to wait between fetches
 anilist_seconds_between_fetches = 60
 
+# Delay (in seconds) between each requests on MAL website (increase this value in case of timeout)
+delayMAL = 2
+
 # Discord Token
 token = 123456789ABCDEF987654321FEDCBA
 

+ 2 - 2
myanimebot.py

@@ -141,14 +141,14 @@ async def background_check_feed(asyncioloop):
 										data_channel = db_srv.fetchone()
 					if feed_type == 1:
 						feed_type = 0
-						await asyncio.sleep(1)
+						await asyncio.sleep(int(globals.delayMAL))
 					else:
 						stop_boucle = 1
 					
 			except Exception as e:
 				globals.logger.exception("Error when parsing RSS for '" + user.name + "': \n")
 			
-			await asyncio.sleep(1)
+			await asyncio.sleep(int(globals.delayMAL))
 
 			data_user = db_user.fetchone()
 

+ 1 - 0
myanimebot/globals.py

@@ -54,6 +54,7 @@ timezone=pytz.timezone(CONFIG.get("timezone", "utc"))
 secondMax=CONFIG.getint("secondMax", 7200)
 token=CONFIG.get("token")
 prefix=CONFIG.get("prefix", "!malbot")
+delayMAL=CONFIG.get("delayMAL", "2")
 iconBot=CONFIG.get("iconBot", "http://myanimebot.pentou.eu/rsc/bot_avatar.jpg")
 ANILIST_SECONDS_BETWEEN_FETCHES=CONFIG.getint("anilist_seconds_between_fetches", 60)
 MAL_ICON_URL=CONFIG.get("iconMAL", "https://cdn.myanimelist.net/img/sp/icon/apple-touch-icon-256.png")