Thanks for your reply,
mikeyww!
Saving in UTF-8 with BOM signature didn't help
URLDownloadToFile function to work with cyrilic letters. With Latin letters everything is ok.
Telegram returns this message:
{"ok":false,"error_code":400,"description":"Bad Request: poll options must be encoded in UTF-8"}
But there is one working way with
WinHttp.WinHttpRequest.5.1:
Code: Select all
SomeVariable = test test
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
myurl1 := "https://api.telegram.org/bot<here is bot token>/sendPoll?chat_id=-<here is chat id>&question=Will we live on Mars?`%0A(" . SomeVariable . ")&options=[""Yeah!"",""Nope"",""Blah blah blah""]&is_anonymous=false"
whr.Open("POST", myurl1, true)
; whr.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
whr.Send("")
whr.WaitForResponse()
MsgBox % whr.ResponseText
But if I need to do several actions (for example, create a poll, pin it, delete the message about pining) I have to use this Open() method each time. Could you help me to understand, how can I use this whr.Send('something') instead and using Open() only once?
If I use
whr.Open("POST", "https://api.telegram.org/bot<here is bot token>/", true) and then
whr.Send("sendMessage?chat_id=-<here is chat id>&text=blahblah") Telegram is angry:
{"ok":false,"error_code":404,"description":"Not Found"}
Even with including
whr.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
Here is a bot for testing if someone needs it (I've created it just now):
@TestAutohotkeybot (t.me/TestAutohotkeybot)
Its token: 2086365146:AAGWZOvm0yFQYU7Dh_wM1pgwrWDC7dsvlK4
https://api.telegram.org/bot2086365146:AAGWZOvm0yFQYU7Dh_wM1pgwrWDC7dsvlK4/
Just create new test group and add this bot to it. To know chat.id it is convinient to add @RawDataBot to the group and it will send the message with "chat": {
"id": -<here is chat id>, ("-" is important).