Old Telegram message proof of concept

was originally gonna have it let me know when my break was over, but I stopped caring about that
This commit is contained in:
David Daily 2020-01-22 09:27:10 -06:00
parent 545bdeb506
commit ba54476683
1 changed files with 145 additions and 0 deletions

145
old_versions/T_Msg.ahk Normal file
View File

@ -0,0 +1,145 @@
; Sauce: https://www.autohotkey.com/boards/viewtopic.php?t=24919
T_SendMsg(Option,EmojiPosition,Text)
{
ini = %A_MyDocuments%\D3Ksettings.ini ; Where the ini is
IniRead, TelegramBotToken, %ini%, Info, TBToken, 0
IniRead, TelegramBotChatID, %ini%, Info, TBChatID, 0
if !(TelegramBotToken)
{
Return
}
if (Option = "hand")
{
TelegramIconString := "%E2%9D%8C"
}
if (Option = "question")
{
TelegramIconString := "%E2%9D%94"
}
if (Option = "alert")
{
TelegramIconString := "%E2%9A%A0%EF%B8%8F"
}
if (Option = "info")
{
TelegramIconString := "%E2%84%B9%EF%B8%8F"
}
IfInString, Option, `%
TelegramIconString := Option
Text := StrReplace(Text, "`n", "%0A")
If (EmojiPosition = 1)
{
Text = %TelegramIconString% %Text%
}
If (EmojiPosition = 2)
{
Text = %Text% %TelegramIconString%
}
If (EmojiPosition = 3)
{
Text = %TelegramIconString% %Text% %TelegramIconString%
}
loop 3
{
UrlDownloadToFile https://api.telegram.org/bot%TelegramBotToken%/sendmessage?chat_id=%TelegramBotChatID%&parse_mode=HTML&text=%Text%, %A_ScriptDir%\Tlog
sleep 1000
ifexist %A_ScriptDir%\Tlog
{
break
}
if A_index = 3
{
MsgBox, 16,, Something went wrong with sending the Telegram message.
}
}
}
T_Edit(Option,EmojiPosition,Text)
{
ini = %A_MyDocuments%\D3Ksettings.ini ; Where the ini is
IniRead, TelegramBotToken, %ini%, Info, TBToken, 0
IniRead, TelegramBotChatID, %ini%, Info, TBChatID, 0
if !(TelegramBotToken)
{
Return
}
if (Option = "hand")
{
TelegramIconString := "%E2%9D%8C"
}
if (Option = "question")
{
TelegramIconString := "%E2%9D%94"
}
if (Option = "alert")
{
TelegramIconString := "%E2%9A%A0%EF%B8%8F"
}
if (Option = "info")
{
TelegramIconString := "%E2%84%B9%EF%B8%8F"
}
IfInString, Option, `%
TelegramIconString := Option
Text := StrReplace(Text, "`n", "%0A")
If (EmojiPosition = 1)
{
Text = %TelegramIconString% %Text%
}
If (EmojiPosition = 2)
{
Text = %Text% %TelegramIconString%
}
If (EmojiPosition = 3)
{
Text = %TelegramIconString% %Text% %TelegramIconString%
}
FileRead, Tlog, %A_ScriptDir%/Tlog
RegExMatch(Tlog, "(?<=""ok"":).", success)
If (success = "t") ; Check to see if message editing succeeded
{
RegExMatch(Tlog, "(?<=""message_id"":)...", message_id)
}
If (success = "f") ; Check to see if message editing succeeded
{
RegExMatch(Tlog, "(?<=""description"":"").+(?="")", error_msg)
MsgBox, %error_msg%
Return
}
loop 3
{
UrlDownloadToFile https://api.telegram.org/bot%TelegramBotToken%/editMessageText?chat_id=%TelegramBotChatID%&message_id=%message_id%&parse_mode=HTML&text=%Text%, %A_ScriptDir%\Tlog
sleep 1000
ifexist %A_ScriptDir%\Tlog
{
break
}
if A_index = 3
{
MsgBox, 16,, Something went wrong with updating the Telegram message.
}
}
}