├── .gitignore ├── chia.ico ├── requirements.txt ├── README.md └── chiaWallet.py /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.bak 3 | -------------------------------------------------------------------------------- /chia.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wolfrage76/chiaWalletMonitor/HEAD/chia.ico -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | wheel 2 | playsound==1.2.2 3 | requests==2.25.1 4 | discord_notify==1.0.0 5 | pushbullet.py==0.9.1 6 | infi.systray==0.1.12 7 | plyer==2.0.0 8 | infi==0.0.1 9 | python-pushover==0.4 10 | dbus-python -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # chiaWalletMonitor 2 | Get notifications when you get Chia XCH -- Reach me at chia@ifhya.com 3 | 4 | 5 | When your wallet gets XCH, you can get a notification via Popup, Push notice through Pushover, Discord, Slack or a custom sound file. 6 | 7 | ## Usage 8 | 9 | First create a virtual env and install de dependencies: 10 | ```cli 11 | python3 -m venv --system-site-packages venv 12 | . ./venv/bin/activate 13 | pip install -r requirements.txt 14 | ``` 15 | 16 | Start the application with: 17 | `python ./chiaWallet.py` 18 | 19 | Run on windows with `pythonw` instead of `python` to run it in the background on windows. Linux users have their own ways. 20 | 21 | ## Notifications supported 22 | 23 | Currently notification support is: `toast, audio file, Pushover push notifications, Slack, Discord, PushBullet` - Let me know any others you'd like integrated! 24 | -------------------------------------------------------------------------------- /chiaWallet.py: -------------------------------------------------------------------------------- 1 | import datetime #for reading present date 2 | import time 3 | import os 4 | import requests #for retreiving coronavirus data from web 5 | from plyer import notification #for getting notification on your PC 6 | 7 | enableSysTray = False 8 | if os.name == 'nt': 9 | from infi.systray import SysTrayIcon 10 | enableSysTray = True 11 | 12 | walletaddress = 'xch1XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' 13 | 14 | sendDiscord = False 15 | discordWebhook = r'https://discord.com/api/webhooks/0000000000000000/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 16 | 17 | #Send push notification over Pushover? 18 | sendPushover = False 19 | pushoverUserKey = 'xxxxxxxxxx' 20 | pushoverAPIKey = 'xxxxxxxxxxxxxxxx' 21 | 22 | #Play a custom sound file? 23 | playSound = False 24 | song = 'audio.mp3' 25 | 26 | #Send a slack notification? 27 | sendSlack = False 28 | slack_token = 'xoxb-my-bot-token' 29 | slack_channel = '#my-channel' 30 | slack_icon_url = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTuGqps7ZafuzUsViFGIremEL2a3NR0KO0s0RTCMXmzmREJd5m4MA&s' 31 | slack_user_name = 'Chia Wallet Monitor' 32 | 33 | 34 | #SendPushBullet notification? 35 | sendPushBullet = False 36 | pbAPIKey = 'XXXXXXXXXXXXXXXXXXXXX' 37 | 38 | def on_quit_callback(systray): 39 | print("QUIT!") 40 | if systray: 41 | systray.shutdown() 42 | 43 | 44 | def checkWallet(systray): 45 | print("Wallet check") 46 | 47 | menu_options = (("Check Wallet", None, checkWallet),) 48 | if enableSysTray: 49 | systray = SysTrayIcon("chia.ico", "ChiaWalletMonitor", menu_options, on_quit=on_quit_callback) 50 | 51 | 52 | 53 | #BEGIN 54 | 55 | #let there is no data initially 56 | chiWallet = None 57 | currXCH = 0 58 | netBalance = -1 59 | firstRun = True 60 | if enableSysTray: 61 | systray.start() 62 | 63 | headers = requests.utils.default_headers() 64 | print(headers) 65 | headers.update({"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36;"}) 66 | 67 | while(True): 68 | 69 | try: 70 | 71 | chiaWallet = requests.get("https://api2.chiaexplorer.com/address/" + walletaddress, headers=headers) 72 | except: 73 | print("Please! Check your internet connection") 74 | 75 | if (chiaWallet != None): 76 | data = chiaWallet.json() 77 | netBalance = data['netBalance']/1000000000000 78 | 79 | if (firstRun == True): 80 | shouldPrint = True 81 | msgTitle = "Your wallet as of {}".format(datetime.date.today()) 82 | msgTxt = "You have a total of {} XCH, Farmer!".format(netBalance) 83 | 84 | else: 85 | if currXCH != netBalance: 86 | shouldPrint = True 87 | msgTxt = "Your Chia balance has changed, for a total of {netBalance} XCH, Chia Pet!".format(netBalance = data['netBalance']/1000000000000) 88 | msgTitle = 'Congrats, Chia Farmer!' 89 | 90 | 91 | if sendDiscord == True: 92 | import discord_notify as dn 93 | discord_info = msgTxt 94 | notifier = dn.Notifier(discordWebhook) 95 | notifier.send(discord_info, print_message=False) 96 | 97 | if sendPushover == True: 98 | from pushover import init, Client 99 | client = Client(pushoverUserKey, api_token=pushoverAPIKey) 100 | client.send_message(msgTxt, title=msgTitle) #pip install python-pushover 101 | 102 | if playSound == True: 103 | from playsound import playsound #pip install playsound 104 | playsound(song) 105 | 106 | if sendSlack == True: 107 | post_message_to_slack(msgTxt) 108 | 109 | if sendPushBullet == True: 110 | from pushbullet import Pushbullet 111 | pb = Pushbullet(pbAPIKey) 112 | push = pb.push_note(msgTitle, msgTxt) 113 | 114 | if shouldPrint == True: 115 | print(msgTxt) 116 | notification.notify( 117 | title = msgTitle, 118 | message = msgTxt , 119 | app_icon = os.path.join(os.path.dirname(os.path.realpath(__file__)), "chia.ico"), 120 | app_name = "Chia Wallet Monitor", 121 | timeout = 50 122 | ) 123 | 124 | shouldPrint = False 125 | firstRun = False 126 | currXCH = netBalance 127 | time.sleep(10*3) 128 | --------------------------------------------------------------------------------