Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoTrayIcon
- Loop
- {
- Sleep 500
- if (WinExist("Error","&Yes"))
- {
- FileAppend,
- (
- %A_DD%.%A_MM%.%A_YYYY% %A_Hour%:%A_Min%:%A_Sec% - "Нет связи с сервером ХХ секунд! Перезагрузите компьютер!" `n
- ), C:\Users\administrator\Desktop\testahk.txt
- WinClose
- TrayTip, ПЦН - окно с ошибкой было закрыто автоматически!,
- (
- ПРОИЗОШЛА ОШИБКА на ПЦН:
- "Нет связи с сервером ХХ секунд! Перезагрузите компьютер!"
- Окно было закрыто автоматически, но рекомендую проверить ПЦН вручную!
- Администратор оповещен!
- ),3600, 2
- Telegram_MsgBox(48,1,"PCN6 - Error! Net svyazi s serverom XX secund!")
- }
- }
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- RandomVariable = sting with variable: %A_OSType%
- Telegram_MsgBox(Option,EmojiPosition,Text)
- {
- TelegramBotToken = YOUR_BOT_TOKEN
- TelegramBotChatID = CHAT_ID
- if TelegramBotChatID =
- Telegram_FirstCFG()
- if TelegramBotChatID =
- Telegram_FirstCFG()
- if Option=16
- TelegramIconString := "%E2%9D%8C"
- if Option=32
- TelegramIconString := "%E2%9D%94"
- if Option=48
- TelegramIconString := "%E2%9A%A0%EF%B8%8F"
- if Option=64
- TelegramIconString := "%E2%84%B9%EF%B8%8F"
- IfInString, Option, `%
- TelegramIconString := Option
- IfLessOrEqual, EmojiPosition, 1
- Text = %TelegramIconString% %Text%
- IfGreaterOrEqual, EmojiPosition, 2
- Text = %Text% %TelegramIconString%
- loop 3
- {
- UrlDownloadToFile https://api.telegram.org/bot%TelegramBotToken%/sendmessage?chat_id=%TelegramBotChatID%&text=%Text%, %A_ScriptDir%\check.rups
- sleep 1000
- ifexist %A_ScriptDir%\check.rups
- {
- break
- }
- if A_index = 3
- {
- MsgBox, 16,, something went wrong with sending
- }
- }
- ;filedelete %A_ScriptDir%\check.rups
- }
- Telegram_FirstCFG()
- {
- msgbox open telegram and open a new Chat with @botfater`nif yout dont know how you do that, search in your default serach engine for "Telegram Botfather first bot"`n`nyou need to choose a unique name (you cant change it)
- loop
- {
- InputBox, BotToken, enter the in telegram indicated bot token,
- MsgBox, 4, , Bot Token correct?:`n%BotToken%
- IfMsgBox Yes
- break
- }
- Random, SecurityCode, 1000, 9999
- msgbox now open a new chat with your new created bot (search for @*yourbotname* and start a new chat) and enter this number %SecurityCode% and send it via telegram`n press OK, when done.
- UrlDownloadToFile https://api.telegram.org/bot%BotToken%/getupdates , %A_ScriptDir%\findChatID.txt
- sleep 2000
- run %A_ScriptDir%\findChatID.txt
- msgbox now search for the number %SecurityCode% and on the same line there should be something like: "chat":{"id":782163891`n`nfound it? press ok
- InputBox ChatID, enter the number after "chat":{"id": here:
- FileAppend, Telegram Bot Token = %BotToken%`n, %A_ScriptDir%\TokenAndID.txt
- FileAppend, Telegram Chat ID = %ChatID%, %A_ScriptDir%\TokenAndID.txt
- run %A_ScriptDir%\TokenAndID.txt
- msgbox here you go. copy and past the values to the variables TelegramBotToken & TelegramChatID in the sourcecode.`n`n(you can delte all the .txt files)
- exitapp
- }
Advertisement
Add Comment
Please, Sign In to add comment