Implement tray drop claim notifications
This commit is contained in:
1 parent
1aba5984d2
commit
9f7c865abb
2 files changed
+19
-2
No files matched your search
@@ -727,6 +727,17 @@ class TrayIcon:
|
|||||||
self.stop()
|
self.stop()
|
||||||
self._manager._root.deiconify()
|
self._manager._root.deiconify()
|
||||||
|
|
||||||
|
def notify(self, message: str, title: Optional[str] = None, duration: float = 10):
|
||||||
|
if self._icon is not None:
|
||||||
|
icon = self._icon
|
||||||
|
|
||||||
|
async def notifier():
|
||||||
|
icon.notify(message, title)
|
||||||
|
await asyncio.sleep(duration)
|
||||||
|
icon.remove_notification()
|
||||||
|
|
||||||
|
asyncio.create_task(notifier())
|
||||||
|
|
||||||
|
|
||||||
class GUIManager:
|
class GUIManager:
|
||||||
def __init__(self, twitch: Twitch):
|
def __init__(self, twitch: Twitch):
|
||||||
@@ -942,6 +953,10 @@ if __name__ == "__main__":
|
|||||||
gui.channels.set_watching(channel)
|
gui.channels.set_watching(channel)
|
||||||
gui._root.update()
|
gui._root.update()
|
||||||
gui.channels.get_selection()
|
gui.channels.get_selection()
|
||||||
|
# Tray
|
||||||
|
# gui.tray.minimize()
|
||||||
|
# await asyncio.sleep(1)
|
||||||
|
# gui.tray.notify("Bounty Coins (3/7)", "Mined Drop")
|
||||||
# Drop progress
|
# Drop progress
|
||||||
drop = create_drop("Wardrobe Cleaning", "Fancy Pants", 2, 7, 239, 240)
|
drop = create_drop("Wardrobe Cleaning", "Fancy Pants", 2, 7, 239, 240)
|
||||||
gui.progress.display(drop)
|
gui.progress.display(drop)
|
||||||
|
|||||||
@@ -434,10 +434,12 @@ class Twitch:
|
|||||||
campaign = drop.campaign
|
campaign = drop.campaign
|
||||||
mined = await drop.claim()
|
mined = await drop.claim()
|
||||||
if mined:
|
if mined:
|
||||||
self.gui.print(
|
claim_text = (
|
||||||
f"Claimed drop: {drop.rewards_text()} "
|
f"{drop.rewards_text()} "
|
||||||
f"({campaign.claimed_drops}/{campaign.total_drops})"
|
f"({campaign.claimed_drops}/{campaign.total_drops})"
|
||||||
)
|
)
|
||||||
|
self.gui.print(f"Claimed drop: {claim_text}")
|
||||||
|
self.gui.tray.notify(claim_text, "Mined Drop")
|
||||||
else:
|
else:
|
||||||
logger.error(f"Drop claim failed! Drop ID: {drop_id}")
|
logger.error(f"Drop claim failed! Drop ID: {drop_id}")
|
||||||
if not mined or campaign.remaining_drops == 0:
|
if not mined or campaign.remaining_drops == 0:
|
||||||
|
|||||||
Reference in new issue
Block a user