-
Notifications
You must be signed in to change notification settings - Fork 4
/
AHNotifier.ps1
381 lines (301 loc) · 25 KB
/
AHNotifier.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
######################################################################
# Name: AHNotifier #
# Desc: Notifies you of prices for WoW Auction House Items #
# Author: Ninthwalker #
# Instructions: https://github.com/ninthwalker/AHNotifier #
# Date: 28AUG2020 #
# Version: 1.3 #
######################################################################
############################ CHANGE LOG ##############################
## 1.0 #
# Initial App version only supports one server per script for now #
## 1.1 #
# Added Settings file instead of having to edit this script directly #
## 1.2 #
# Added Windows Toast Notification Option #
## 1.3 #
# Additional Toast options w/ Item Icons and Buttons #
# Added bulkmode option to check more items per hour if wanting #
######################################################################
### setup environment ###
if ($MyInvocation.MyCommand.CommandType -eq "ExternalScript") {
$ScriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
}
else {
$ScriptPath = Split-Path -Parent -Path ([Environment]::GetCommandLineArgs()[0])
if (!$ScriptPath) {
$ScriptPath = "."
}
}
# Set-Location $PSScriptRoot
Set-Location $ScriptPath
# Import settings
Function Get-Settings ([string]$fileName) {
$ini = @{}
switch -regex -file $fileName {
"^\[(.+)\]$" { # recognize a section
$section = $matches[1]
$ini[$section] = @{}
}
"^\s*([^#]+?)\s*=\s*(.*)" { # recognize a property
$name,$value = $matches[1..2]
if (!(Test-path variable:\section)) {
$section = "-unknown-"
$ini[$section] = @{}
}
$ini[$section][$name] = $value.trim()
}
}
$ini
}
$settings = Get-Settings .\settings.txt
# wow AH Alert logo
$base64Img = "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAACHDwAAjA8AAP1SAACBQAAAfXkAAOmLAAA85QAAGcxzPIV3AAAKL2lDQ1BJQ0MgUHJvZmlsZQAASMedlndUVNcWh8+9d3qhzTACUobeu8AA0nuTXkVhmBlgKAMOMzSxIaICEUVEmiJIUMSA0VAkVkSxEBRUsAckCCgxGEVULG9G1ouurLz38vL746xv7bP3ufvsvc9aFwCSpy+XlwZLAZDKE/CDPJzpEZFRdOwAgAEeYIApAExWRrpfsHsIEMnLzYWeIXICXwQB8HpYvAJw09AzgE4H/5+kWel8geiYABGbszkZLBEXiDglS5Auts+KmBqXLGYYJWa+KEERy4k5YZENPvsssqOY2ak8tojFOaezU9li7hXxtkwhR8SIr4gLM7mcLBHfErFGijCVK+I34thUDjMDABRJbBdwWIkiNhExiR8S5CLi5QDgSAlfcdxXLOBkC8SXcklLz+FzExIFdB2WLt3U2ppB9+Rk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rDRFE4PEIjFJbBJjM+vfiio2xGVBSffwuqLOQfc7tve4H611uNfKWO9ugVb2dn4XGXM767BlqAETW+uSaa+HspUp5hYOIue7NuV9a3thgKMn9vZuOAhjnBUeqEQtcXd0EmnSAn/hKh62AtzKmOAgQwYNsuX48UJevhjF6ztd+P2cP0um2b61kuvfjdY63pMYJBaJSWKTGP9E/XuRqpuT0GChEc0aKTRNmLw40kP2dEYHGZ+U6rN9bEu+n23E+mJdRiTrkOJlgKeLEXb2ZpjL5VjLzbEVTaGjjZ0oPjY4iuB0U7QgOFCf3FwDPvzQmRMnCnjxYjxvnvTi19PBnN3QgvbJJk90dWSLpTWb1/4PDolJYvtLBf5/FT2hUu9RJDfRqW6n1Xk9s0iPBaVGomAZcmaRCVe3m/LtspasXWjCzGnGjBplQOUwfSorWzBmTAvmz7dk82alyC7BPGrM5s2Lbry+l8IfPwVya5+jKFJGr23kTV+zFjavJa35bxXJ7/75RbfcRHY6PVD2amiGAfOLjFjZ14ivp1pw6XMl944F8LRGwfM6B36rD+bFnQR+qYvmeW0cz89reX7Cg19PqTmxwZbK7oavFHb6Unvwb/ui+78S6eFSKW/6qYGermyrwkpWnxWk97IyvxUzerRk60RLDs6z5dRSUejmG3JyqZzvFluye54FG6dYMKqX5ctwP6N6MVVJXeX/2E8N/lWkxSR/lI5b6s2bfuwhWt3t5sayaoWNXo1GoXfFU6iro0GNpZludfMY+L/+Y4+/EwlAmo6kEe/vfm4jfXrw3/BzG5ns/wCKx1DmztXZlAAAAABJRU5ErkJggg=="
If (!(Test-Path $env:TEMP\AHNotifier_ToastImg.png)) {
$imageFile = "$env:TEMP\AHNotifier_ToastImg.png"
[byte[]]$Bytes = [convert]::FromBase64String($Base64Img)
[System.IO.File]::WriteAllBytes($ImageFile,$Bytes)
}
### Server and TSM Settings ###
$region = $settings.'server settings'.region
$server = $settings.'server settings'.server
$apiKey = $settings.'server settings'.apikey
if ($settings.'Server Settings'.BulkMode -eq "Enabled") {$bulkMode = $True} else {$bulkMode = $False}
# notification types
if ($settings.'Notification Types'.Discord -eq "Enabled") {$discord = $True} else {$discord = $False}
if ($settings.'Notification Types'.Telegram -eq "Enabled") {$telegram = $True} else {$telegram = $False}
if ($settings.'Notification Types'.Pushover -eq "Enabled") {$pushover = $True} else {$pushover = $False}
if ($settings.'Notification Types'.TextMsg -eq "Enabled") {$textMsg = $True} else {$textMsg = $False}
if ($settings.'Notification Types'.Alexa -eq "Enabled") {$alexa = $True} else {$alexa = $False}
if ($settings.'Notification Types'.HASS -eq "Enabled") {$hass = $True} else {$hass = $False}
if ($settings.'Notification Types'.Toast -eq "Enabled") {$toast = $True} else {$toast = $False}
### AUCTION HOUSE SETTINGS ###
$items = @()
$settings.GetEnumerator() | ForEach-Object {
if ($_.key -like "AHITem*") {
$items += [PSCustomObject]@{
Description = $settings[$_.key]['description']
itemID = $settings[$_.key]['itemID']
price = $settings[$_.key]['price']
check = $settings[$_.key]['check']
}
}
}
### Windows Toast Notification ###
#set App ID
$wow = Get-StartApps | ? {$_.Name -eq "World of Warcraft"}
if ($wow) {
$app = $wow.AppID
}
else {
$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
}
function New-Toast {
# Get Icon
$iconSearch = Invoke-Restmethod https://www.wowhead.com/item=$($details.Id) -UseBasicParsing
$end = '"'
If($iconSearch -match "https://wow.zamimg.com/images/wow/icons/.+(?=$end)") {
$icon = $Matches[0]
# icon filetype
$iconFileType = $icon.Substring($icon.Length - 3)
# get the icon
try {
Invoke-WebRequest -Uri $icon -OutFile "$env:TEMP\AHNotifier_Icon.$iconFileType"
$iconImg = "$env:TEMP\AHNotifier_Icon.$iconFileType"
}
Catch {
$iconImg = $imageFile
}
}
else {
$iconImg = $imageFile
}
# Start toast
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
$Template = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText01
#Gets the Template XML so we can manipulate the values
[xml]$ToastTemplate = ([Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($Template).GetXml())
# removed some words and updated part from the original msg
$toast_msg = $msg.TrimStart("AH Alert: ")
$toast_msg = $toast_msg -replace ".{29}$"
if (Test-Path Registry::HKEY_CLASSES_ROOT\AHNotifier\shell\open\command) {
$openWOW = '<action activationType="protocol" arguments="AHNotifier:" content="Open WoW"/>'
}
else {
$openWOW = ""
}
# Don't use this for now. Mosty people won't have the latest win ver for it.
# $timeStamp = $updatedAt | Get-Date -Format s
[xml]$ToastTemplate = @"
<toast activationType="protocol" launch="$($details.url)" duration="long">
<visual>
<binding template="ToastGeneric">
<text>Auction House Alert</text>
<text>$toast_msg</text>
<text>$updatedAt</text>
<image placement="appLogoOverride" src="$iconImg"/>
<text placement="attribution">AH Notifier</text>
</binding>
</visual>
<actions>
$openWOW
<action activationType="protocol" arguments="$($details.url)" content="Details"/>
<action activationType="system" arguments="dismiss" content=""/>
</actions>
</toast>
"@
$ToastXml = New-Object -TypeName Windows.Data.Xml.Dom.XmlDocument
$ToastXml.LoadXml($ToastTemplate.OuterXml)
$notify = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app)
$notify.Show($ToastXml)
}
# Extra options to use if wanted some day
#<image src="$img"/>
#<image placement="hero" src="$img"/>
#<image id="1" placement="appLogoOverride" hint-crop="circle" src="$img"/>
#<toast duration=”long” displayTimestamp="$timeStamp">
### NOTIFICATION SETTINGS ###
# Force tls1.2 - mainly for telegram since they recently changed this in FEB2020
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# If using text method, convert password into secure credential object
if ($textMsg) {
[SecureString]$secureEmailPass = $settings.textmsg.emailPass | ConvertTo-SecureString -AsPlainText -Force
[PSCredential]$emailCreds = New-Object System.Management.Automation.PSCredential -ArgumentList $settings.textmsg.emailUser, $secureEmailPass
}
# Notification Function
function AHNotifier {
# msg Discord
if ($discord) {
$discordHeaders = @{
"Content-Type" = "application/json"
}
$discordBody = @{
content = $msg
} | convertto-json
Invoke-RestMethod -Uri $settings.discord.discordWebHook -Method POST -Headers $discordHeaders -Body $discordBody
}
# msg Telegram
if ($telegram) {
Invoke-RestMethod -Uri "https://api.telegram.org/bot$($settings.telegram.telegramBotToken)/sendMessage?chat_id=$($settings.telegram.telegramChatID)&text=$($msg)"
}
# msg Pushover
if ($pushover) {
$data = @{
token = $settings.pushover.pushoverAppToken
user = $settings.pushover.pushoverUserToken
message = $msg
}
if ($settings.pushover.device) { $data.Add("device", $settings.pushover.device) }
if ($settings.pushover.title) { $data.Add("title", $settings.pushover.title) }
if ($settings.pushover.priority) { $data.Add("priority", $settings.pushover.priority) }
if ($settings.pushover.sound) { $data.Add("sound", $settings.pushover.sound) }
Invoke-RestMethod "https://api.pushover.net/1/messages.json" -Method POST -Body $data
}
# text Msg
if ($textMsg) {
Send-MailMessage -SmtpServer $settings.TextMsg.smtpServer -Port $settings.TextMsg.smtpPort -UseSsl -Priority High -from $settings.TextMsg.fromAddress -to $($settings.TextMsg.phoneNumber+$settings.TextMsg.CarrierEmail) -Subject "AH Alert" -Body $msg -Credential $emailCreds
}
# msg Alexa
if ($alexa) {
$alexaBody = @{
notification = $msg
accessCode = $settings.alexa.alexaAccessCode
} | ConvertTo-Json
Invoke-RestMethod https://api.notifymyecho.com/v1/NotifyMe -Method POST -Body $alexaBody
}
# msg HASS
if ($HASS) {
$hassHeaders = @{
"Content-Type" = "application/json"
"Authorization"= "Bearer $($settings.hass.hassToken)"
}
$hassBody = @{
"entity_id" = $settings.hass.entityID
} | convertto-json
Invoke-RestMethod -Uri "$($settings.hass.hassURL)/api/services/script/toggle" -Method POST -Headers $hassHeaders -Body $hassBody
}
if ($toast) {
New-Toast
}
}
# Get AH Data for each item specified
# note on API Limits:
# 50 API calls an hour
# 25 API Calls per 24 hours if using the BulkMode api endpoint (gets all realm AH data. Anywhere from like 2-10Mb depending on server)
# Each Item you check on the AH is 1 API call when NOT using the BulkMode
# If running this 24/7 then only run once per hour if using BulkMode. You can check however many items you want per hour though this way.
# If running this 24/7 then only check for less than 50 items per hour when NOT using BulkMode.
$ahData = @()
if (!($bulkMode)) {
foreach ($item in $items) {
$ahData += Invoke-RestMethod -Uri "https://api.tradeskillmaster.com/v1/item/$region/$server/$($item.itemID)?format=json&apiKey=$apiKey"
}
# Stupid epoch time
$updatedAt = ((Get-Date 01.01.1970).AddSeconds($ahData[0].LastUpdated)).TolocalTime()
}
else {
$ahData = Invoke-RestMethod -Uri "https://api.tradeskillmaster.com/v1/item/$region/$($server)?format=json&apiKey=$apiKey"
$updatedAt = Get-Date
}
# init msg array
# Leave this for later to combine alerts maybe
# $msg = @()
# check items for price and create notification if threshold is met
foreach ($item in $items) {
$details = $ahData | ? {$_.Id -eq $item.itemID}
if ($details.Quantity -ge 1) {
if ($item.check -eq "Above") {
if ([int64]$details.MinBuyout -ge [int64]$item.price) {
# send alert
# maths
if ( [int64]$details.MinBuyout -ge 10000) {
$minBuyout = "$($details.MinBuyout/10000)g" # gold
}
else {
$minBuyout = "$($details.MinBuyout/100)s" # silver
}
if ( [int64]$item.price -ge 10000) {
$setPrice = "$($item.price/10000)g" # gold
}
else {
$setPrice = "$($item.price/100)s" # silver
}
$msg = "AH Alert: $($details.name) is now $($minBuyout). This is above your price of $($setPrice). Updated: $($updatedAt)"
# notify
AHNotifier
}
else {
# Don't send Alert
#write-host "$($details.name) is NOT above your set price of $($item.price) - NO ALERT TRIGGERED" -ForegroundColor Red
}
}
if ($item.check -eq "Below") {
if ([int64]$details.MinBuyout -le [int64]$item.price) {
# send alert
# maths
if ( [int64]$details.MinBuyout -ge 10000) {
$minBuyout = "$($details.MinBuyout/10000)g" # gold
}
else {
$minBuyout = "$($details.MinBuyout/100)s" # silver
}
if ( [int64]$item.price -ge 10000) {
$setPrice = "$($item.price/10000)g" # gold
}
else {
$setPrice = "$($item.price/100)s" # silver
}
$msg = "AH Alert: $($details.name) is now $($minBuyout). This is below your price of $($setPrice). Updated: $($updatedAt)"
# notify
AHNotifier
}
else {
# Don't send alert
#write-host "$($details.name) is NOT below your set price of $($item.price) - NO ALERT TRIGGERED" -ForegroundColor Red
}
}
}
else {
#write-host "Quantity available is less than 1" -ForegroundColor Red
}
}