Fix connection error to coingecko breaking the loop
This commit is contained in:
+1
-1
@@ -27,7 +27,7 @@ def annoy(self, invkr_id, parameter):
|
||||
|
||||
"""
|
||||
|
||||
if not parameter:
|
||||
if not len(parameter) != 1:
|
||||
err = "Please use the command like this: .annoy TARGET MESSAGE"
|
||||
self.bot.sendtextmessage(targetmode=1, target=invkr_id, msg=err)
|
||||
return
|
||||
|
||||
+9
-3
@@ -3,12 +3,13 @@ TBD
|
||||
"""
|
||||
|
||||
__author__ = "Lukas Mahler"
|
||||
__version__ = "0.0.0"
|
||||
__date__ = "27.09.2021"
|
||||
__version__ = "0.0.1"
|
||||
__date__ = "04.02.2022"
|
||||
__email__ = "m@hler.eu"
|
||||
__status__ = "Development"
|
||||
|
||||
# Imports
|
||||
from datetime import datetime
|
||||
from pycoingecko import CoinGeckoAPI
|
||||
|
||||
|
||||
@@ -44,7 +45,12 @@ class GeckoAPI:
|
||||
|
||||
matching = [x for x in self.coinlist if x["id"] == symbol_id.lower()]
|
||||
if len(matching) == 1:
|
||||
resp_dict = self.api.get_price(ids=matching[0]["id"], vs_currencies=curr.lower())
|
||||
try:
|
||||
resp_dict = self.api.get_price(ids=matching[0]["id"], vs_currencies=curr.lower())
|
||||
except Exception as e:
|
||||
with open("gecko_error.log", 'a+') as log:
|
||||
log.write(f"{datetime.now():%Y-%m-%d %H:%M} | {e}\n")
|
||||
return "Error"
|
||||
price = resp_dict[matching[0]["id"]][curr.lower()]
|
||||
if isinstance(price, int):
|
||||
price = float(price) # Convert to always have floats
|
||||
|
||||
Reference in New Issue
Block a user