User Tools

Site Tools


current_alerts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
current_alerts [2022/01/04 10:25] – [GetCurrentAlerts()] emozolyakcurrent_alerts [2022/07/04 12:35] (current) – [GetCurrentAlerts()] emozolyak
Line 66: Line 66:
     Telegram      Telegram 
 --]]  --]] 
-TELEGRAM_BOT_ID = "229345xxxxx" +TELEGRAM_BOT_ID = "229345xxxxx"                -- your telegram chat bot id  
-active_alerts = 0 +active_alerts = 0                              -- global counter for current alerts
  
 function main (userId) function main (userId)
Line 73: Line 73:
   local alerts = GetCurrentAlerts()   local alerts = GetCurrentAlerts()
      
-  if (#alerts > active_alerts) then            -- number has increased +  if (#alerts > active_alerts) then            -- number has increased, # - means count table elements
       local a_names = {}                       DEBUG("Alert count has increased!")       local a_names = {}                       DEBUG("Alert count has increased!")
  
Line 80: Line 80:
           table.insert(a_names, a.title)           table.insert(a_names, a.title)
       end        end 
-      a_names = table.concat(a_names, ', ') +      SendTelegramMessage(TELEGRAM_BOT_ID,  
-      SendTelegramMessage(TELEGRAM_BOT_ID, "Current alerts are: " .. a_names)+                          "Current alerts are: " .. table.concat(a_names, ', '))
   end    end 
      
current_alerts.1641291920.txt.gz · Last modified: 2022/01/04 10:25 by emozolyak

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki