mirror of
https://github.com/rangermix/TwitchDropsMiner.git
synced 2026-06-08 13:24:35 +00:00
Implement tray drop claim notifications
This commit is contained in:
15
gui.py
15
gui.py
@@ -727,6 +727,17 @@ class TrayIcon:
|
||||
self.stop()
|
||||
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:
|
||||
def __init__(self, twitch: Twitch):
|
||||
@@ -942,6 +953,10 @@ if __name__ == "__main__":
|
||||
gui.channels.set_watching(channel)
|
||||
gui._root.update()
|
||||
gui.channels.get_selection()
|
||||
# Tray
|
||||
# gui.tray.minimize()
|
||||
# await asyncio.sleep(1)
|
||||
# gui.tray.notify("Bounty Coins (3/7)", "Mined Drop")
|
||||
# Drop progress
|
||||
drop = create_drop("Wardrobe Cleaning", "Fancy Pants", 2, 7, 239, 240)
|
||||
gui.progress.display(drop)
|
||||
|
||||
@@ -434,10 +434,12 @@ class Twitch:
|
||||
campaign = drop.campaign
|
||||
mined = await drop.claim()
|
||||
if mined:
|
||||
self.gui.print(
|
||||
f"Claimed drop: {drop.rewards_text()} "
|
||||
claim_text = (
|
||||
f"{drop.rewards_text()} "
|
||||
f"({campaign.claimed_drops}/{campaign.total_drops})"
|
||||
)
|
||||
self.gui.print(f"Claimed drop: {claim_text}")
|
||||
self.gui.tray.notify(claim_text, "Mined Drop")
|
||||
else:
|
||||
logger.error(f"Drop claim failed! Drop ID: {drop_id}")
|
||||
if not mined or campaign.remaining_drops == 0:
|
||||
|
||||
Reference in New Issue
Block a user