Compare commits
3 Commits
34badf17eb
...
e7a9466092
Author | SHA1 | Date | |
---|---|---|---|
e7a9466092 | |||
dd97d9b1f9 | |||
cd23c8e350 |
14
README.md
14
README.md
@ -1,3 +1,15 @@
|
|||||||
# wow-token-app-bot
|
# wow-token-app-bot
|
||||||
|
|
||||||
An interactions.py Discord bot for getting and alerting on the WoW Token Price
|
An interactions.py Discord bot for getting and alerting on the WoW Token Price
|
||||||
|
|
||||||
|
|
||||||
|
# Help
|
||||||
|
If you are a user of this bot and are looking for help on how to use it, you can find a small tutorial [here](https://blog.emily.sh/token-bot/)
|
||||||
|
|
||||||
|
|
||||||
|
# Contributing
|
||||||
|
1. Clone the project
|
||||||
|
2. Install the requirements `pip install -r requirements.txt`
|
||||||
|
3. Install pre-commit hooks `pre-commit install`
|
||||||
|
4. To run this application you will need to have created DynamoDB tables and have a discord app token to use
|
||||||
|
- You will need to specify at least ALERTS_TABLE, USERS_TABLE, DISCORD_TOKEN, and AWS_REGION
|
||||||
|
@ -15,6 +15,7 @@ httpcore==1.0.5
|
|||||||
httpx==0.27.0
|
httpx==0.27.0
|
||||||
idna==3.7
|
idna==3.7
|
||||||
multidict==6.0.5
|
multidict==6.0.5
|
||||||
|
pre-commit==4.0.1
|
||||||
python-dateutil==2.9.0.post0
|
python-dateutil==2.9.0.post0
|
||||||
python-dotenv==1.0.1
|
python-dotenv==1.0.1
|
||||||
pytz==2024.1
|
pytz==2024.1
|
||||||
|
@ -15,13 +15,13 @@ class Alert:
|
|||||||
self, alert: pdb.AlertType, flavor: Flavor, region: Region, price: int = 0
|
self, alert: pdb.AlertType, flavor: Flavor, region: Region, price: int = 0
|
||||||
) -> None:
|
) -> None:
|
||||||
# AlertType is the Primary Key
|
# AlertType is the Primary Key
|
||||||
self.alert_type: pdb.AlertType = alert
|
self._alert_type: pdb.AlertType = alert
|
||||||
# Flavor (Retail, Classic) is the Sort Key
|
# Flavor (Retail, Classic) is the Sort Key
|
||||||
self.flavor: Flavor = flavor
|
self._flavor: Flavor = flavor
|
||||||
self.region: Region = region
|
self._region: Region = region
|
||||||
self.price: int = price
|
self._price: int = price
|
||||||
self._loaded: bool = False
|
self._loaded: bool = False
|
||||||
self.users: List[pdb.User] = []
|
self._users: List[pdb.User] = []
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_item(cls, primary_key: int, sort_key: str, users: List[int]) -> "Alert":
|
def from_item(cls, primary_key: int, sort_key: str, users: List[int]) -> "Alert":
|
||||||
@ -66,6 +66,26 @@ class Alert:
|
|||||||
self.sort_key_name: self.sort_key,
|
self.sort_key_name: self.sort_key,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property
|
||||||
|
def alert_type(self) -> pdb.AlertType:
|
||||||
|
return self._alert_type
|
||||||
|
|
||||||
|
@property
|
||||||
|
def flavor(self) -> Flavor:
|
||||||
|
return self._flavor
|
||||||
|
|
||||||
|
@property
|
||||||
|
def region(self) -> Region:
|
||||||
|
return self._region
|
||||||
|
|
||||||
|
@property
|
||||||
|
def price(self) -> int:
|
||||||
|
return self._price
|
||||||
|
|
||||||
|
@property
|
||||||
|
def users(self) -> List[pdb.User]:
|
||||||
|
return self._users
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.alert_type.value}-{self.flavor.value}-{self.region.value}-{self.price}"
|
return f"{self.alert_type.value}-{self.flavor.value}-{self.region.value}-{self.price}"
|
||||||
|
|
||||||
@ -110,7 +130,7 @@ class Alert:
|
|||||||
response = await table.get_item(key=self.key, consistent_read=consistent)
|
response = await table.get_item(key=self.key, consistent_read=consistent)
|
||||||
except ItemNotFound:
|
except ItemNotFound:
|
||||||
return False
|
return False
|
||||||
self.users = [pdb.User(int(user_id)) for user_id in response["users"]]
|
self._users = [pdb.User(int(user_id)) for user_id in response["users"]]
|
||||||
self._loaded = True
|
self._loaded = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -456,6 +456,7 @@ class Tracker(Extension):
|
|||||||
alert_str = (
|
alert_str = (
|
||||||
f"Last Alerting Price Value: {format(trigger.last_alerting[1], ",")}\n"
|
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"
|
f"Last Alerting Time: {trigger.last_alerting[0].strftime('%Y-%m-%d %H:%M:%S UTC')}\n"
|
||||||
|
f"[Link to this Chart]({self._render_token_url(alert)})"
|
||||||
)
|
)
|
||||||
if user is not None and user.user_id == 265678699435655169:
|
if user is not None and user.user_id == 265678699435655169:
|
||||||
alert_str += (
|
alert_str += (
|
||||||
@ -486,3 +487,24 @@ class Tracker(Extension):
|
|||||||
fields=fields,
|
fields=fields,
|
||||||
)
|
)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
def _render_token_url(self, alert: Alert) -> str:
|
||||||
|
match alert.flavor:
|
||||||
|
case Flavor.CLASSIC:
|
||||||
|
url = "https://classic.wowtoken.app/?"
|
||||||
|
case Flavor.RETAIL:
|
||||||
|
url = "https://wowtoken.app/?"
|
||||||
|
case _:
|
||||||
|
raise NotImplementedError
|
||||||
|
url += f"region={alert.region.value}&"
|
||||||
|
match alert.alert_type:
|
||||||
|
case AlertType.WEEKLY_LOW | AlertType.WEEKLY_HIGH:
|
||||||
|
url += "time=168h&"
|
||||||
|
case AlertType.MONTHLY_LOW | AlertType.MONTHLY_HIGH:
|
||||||
|
url += "time=720h&"
|
||||||
|
case AlertType.YEARLY_LOW | AlertType.YEARLY_HIGH:
|
||||||
|
url += "time=1y&"
|
||||||
|
case AlertType.ALL_TIME_LOW | AlertType.ALL_TIME_HIGH:
|
||||||
|
url += "time=all&"
|
||||||
|
|
||||||
|
return url
|
||||||
|
Loading…
Reference in New Issue
Block a user