Compare commits

...

2 Commits

3 changed files with 24 additions and 5 deletions

View File

@ -1,3 +1,5 @@
import logging
import aiohttp
from interactions import Extension
from interactions import slash_command, listen
@ -16,8 +18,8 @@ class Core(Extension):
@listen(Startup)
async def on_start(self):
print("TokenBot Core ready")
print(f"This is bot version {VERSION}")
self.bot.logger.log(logging.INFO,"TokenBot Core ready")
self.bot.logger.log(logging.INFO,f"This is bot version {VERSION}")
self._tdb = tdb.Database(aiohttp.ClientSession())
@slash_command()

View File

@ -21,9 +21,14 @@ class UpdateTrigger:
def last_trigger(self) -> Tuple[datetime.datetime, int] | None:
return self._last_trigger
@property
def last_alerting(self) -> Tuple[datetime.datetime, int] | None:
return self._last_alerting
@property
def squelched(self):
return self._squelched
def _find_next_trigger(self, comparison_operator: operator, starting_point: datetime.datetime, history: List[Tuple[datetime.datetime, int]]):
candidate_datum : Tuple[datetime.datetime, int] | None = None
for datum in history:
@ -99,4 +104,4 @@ class UpdateTrigger:
return not was_squelched
elif self._squelched:
self._squelched = False
return False
return False

View File

@ -368,8 +368,20 @@ class Tracker(Extension):
history = await self._history_manager.get_history(alert.flavor, alert.region)
trigger = await history.find_update_trigger_from_alert(alert)
if trigger.last_trigger is not None:
alert_str = (f"Last Alerting Price Value: {format(trigger.last_alerting()[1], ",")}\n"
f"Last Alerting Time: {trigger.last_alerting()[0].strftime('%Y-%m-%d %H:%M:%S UTC')}\n")
alert_str = (f"Last Alerting Price Value: {format(trigger.last_alerting[1], ",")}\n"
f"Last Alerting Time: {trigger.last_alerting[0].strftime('%Y-%m-%d %H:%M:%S UTC')}\n")
if is_owner():
alert_str += (f"\nShowing you some internals since you are the bot owner:\n"
f"```history.last_price_datum:\n"
f"\t{history.last_price_datum[0].strftime('%Y-%m-%d %H:%M:%S UTC')}\n"
f"\t{history.last_price_datum[1]}\n"
f"trigger.last_alerting:\n"
f"\t{trigger.last_alerting[0].strftime('%Y-%m-%d %H:%M:%S UTC')}\n"
f"\t{trigger.last_alerting[1]}\n"
f"trigger.last_trigger:\n"
f"\t{trigger.last_trigger[0].strftime('%Y-%m-%d %H:%M:%S UTC')}\n"
f"\t{trigger.last_trigger[1]}\n"
f"trigger.squelched:\n\t{trigger.squelched}```")
else:
alert_str = "You should only be seeing this if the bot has not finished importing history at startup."
fields.append(