Jump to content

Recommended Posts

On 05/01/2017 at 11:49 PM, LinkOut said:

it's 100% safe and secure,

Curl may be, but Telegram itself is not. Using it for secure communications without two-factor authentication leaves a security hole you can drive a truck through, see for example here, here, here, and here.

Link to comment
Share on other sites

I created an issue at your repository :)

Quote

"AutoIT" used instead of "AutoIt"

The correct capitalisation is AutoIt (pronounced Aww - Toe - It). Not Auto - I.T 😜

 

 

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

On 12/1/2017 at 8:18 AM, bambus1980 said:

its cool, but, what about using proxy server, ntlm proxy? if I use curl it will be: curl -s -k -U : --proxy-ntlm --proxy server:port https://google.com -o index.htm

how make that UDF working with proxy?

If you want to use proxy with cURL, download the older version of the UDF and add your commands to the $query that start curl with arguments.
 

On 12/1/2017 at 10:14 AM, RTFC said:

Curl may be, but Telegram itself is not. Using it for secure communications without two-factor authentication leaves a security hole you can drive a truck through, see for example here, here, here, and here.

I think that if you use THIS udf for secure communications... it's not the right thing.

On 12/1/2017 at 11:32 AM, TheDcoder said:

I created an issue at your repository :)

 

 
I saw! Thanks^_^
Link to comment
Share on other sites

  • 1 month later...

Many thanks for your script, I am seeking for this for a long time other than python one.

I had a few issues and not sure is it should related to this UDF and ask here.

1. Proxy issue also, it can't detect my computer setting for the proxy set inside IE.

2. How to convert the non english text received as unicode code point to readable string e.g. \u5514\u7dca\u8981 ?

3. How to send emoji using sendmessage?

Link to comment
Share on other sites

On 16/2/2017 at 9:30 AM, mintea said:

Many thanks for your script, I am seeking for this for a long time other than python one.

I had a few issues and not sure is it should related to this UDF and ask here.

1. Proxy issue also, it can't detect my computer setting for the proxy set inside IE.

2. How to convert the non english text received as unicode code point to readable string e.g. \u5514\u7dca\u8981 ?

3. How to send emoji using sendmessage?

1. I don't really know how to use a proxy with the WinHttp udf that the script use. You can search for a different library that allow direct connection between a proxy, and use this to send http request to Telegram server;

2. \u5514\u7dca\u8981 <- this is the Unicode of an Emoji. You canconvert this to another encoding format but...

3. You can find ready-made UDFs that manage Emoji and can convert encoding to another and send them to Telegram. Or, better, SciTE (or Notepad++) support UTF-8 encoding and you can just copy emojis from telegram or emojipedia and paste directly into source code, and done!

 
Link to comment
Share on other sites

  • 2 weeks later...
On 4/3/2017 at 0:55 AM, sakamoto said:

Thanks a lot for UDF. Someone else can give an example of inline_keyboard?

Thank you for using it! To use inline_keyboard first you have to create an array of array of button (sound bad, I know) and then add this (encoded in json format) to the query. I'm working on it but only in php for the moment. If this can help you:

$keyboard = array("inline_keyboard" => array(array(array("text" => "ButtonText", "callback_data" => "CallbackText"),array("text" => "ButtonText2", "callback_data" => "CallbackText2"))));
$keyboard = json_encode($keyboard, true);

And after send it as:

http://api.telegram.org/bot<TOKEN>/sendMessage?chat_id=12345678&text=test&reply_markup=$keyboard

 

Link to comment
Share on other sites

LinkOut, thanks for the answer.

I figured out the buttons, but get an error when receiving callback_data.

Other methods "url" "switch_inline_query" work out well.

#include "Telegram UDF.au3"
$ikeyb = '{"inline_keyboard":[[{"text":"Button 1","callback_data":"data 1"}]]}'
_InitBot("xxxIDxxx","xxxTOKENxxx")

While 1
    $msgData = _Polling()
    If $msgData <> '' Then ConsoleWrite($msgData[0]&'|'&$msgData[1]&'|'&$msgData[2]&'|'&$msgData[3]&@LF)
    Switch $msgData[3]
        Case '777'
            _SendMsg($msgData[2], 'Message', Default, $ikeyb)
    EndSwitch
WEnd
Telegram UDF.au3" (481)

$dataArray[2] = $tmpChatID[3]
$dataArray[2] = ^ ERROR

 

Edited by sakamoto
Link to comment
Share on other sites

My post above are no longer relevant.
I modified _JSONDecode function to return more variables:

     $msgData[4] = Callback query ID
     $msgData[5] = Callback data
     $msgData[6] = MessageID

And add new functions to respond to callback query:


     _answerCallbackQuery($ChatID, $Text, $Alert = True, $Cache_time = '5')
     _editMessageReplyMarkup($ChatID, $message_id, $reply_markup)
     _editMessageText($ChatID, $message_id, $Text, $reply_markup)

This for my bot is still enough.

Func _JSONDecode($JSONMsg)
   Local $firstSplit = StringSplit($JSONMsg,"update_id",1)
   Local $secondSplit = StringSplit($firstSplit[2], ",")
   Local $dataArray[7]
   For $i=1 to $secondSplit[0]
      Local $data = $secondSplit[$i]
      If StringLeft($data,2) = '":' Then $dataArray[0] = StringTrimLeft($data,2)
      If StringInStr($data,'username') Then
         $tmpUsername = StringSplit($data,':')
         $tmpUsername[2] = StringTrimLeft($tmpUsername[2],1)
         $tmpUsername[2] = StringTrimRight($tmpUsername[2],1)
         $dataArray[1] = $tmpUsername[2]
      EndIf
      If StringInStr($data,'"chat"') Then
         $tmpChatID = StringSplit($data,':')
         $dataArray[2] = $tmpChatID[3]
      EndIf
      If StringInStr($data,'text') Then
         $tmpText = StringSplit($data,':')
         If StringInStr($tmpText[2],'"}}]}') Then
            $tmpText[2] = StringTrimLeft($tmpText[2],1)
            $tmpText[2] = StringTrimRight($tmpText[2],5)
            $dataArray[3] = $tmpText[2]
         ElseIf StringInStr($tmpText[2],'"}}') Then
            $tmpText[2] = StringTrimLeft($tmpText[2],1)
            $tmpText[2] = StringTrimRight($tmpText[2],3)
            $dataArray[3] = $tmpText[2]
         ElseIf StringInStr($tmpText[2],'"}') Then
            $tmpText[2] = StringTrimLeft($tmpText[2],1)
            $tmpText[2] = StringTrimRight($tmpText[2],2)
            $dataArray[3] = $tmpText[2]
         ElseIf StringRight($tmpText[2],1) = '"' Then
            $tmpText[2] = StringTrimLeft($tmpText[2],1)
            $tmpText[2] = StringTrimRight($tmpText[2],1)
            $dataArray[3] = $tmpText[2]
         EndIf
      EndIf
      If StringInStr($data,'callback_query') Then
         $tmpCallBQ = StringSplit($data,':')
         $tmpCallBQ[3] = StringTrimLeft($tmpCallBQ[3],1)
         $tmpCallBQ[3] = StringTrimRight($tmpCallBQ[3],1)
         $dataArray[4] = $tmpCallBQ[3]
     EndIf
      If StringInStr($data,'data') Then
         $tmpCallBData = StringSplit($data,':')
         If StringInStr($tmpCallBData[2],'"}}]}') Then
            $tmpCallBData[2] = StringTrimLeft($tmpCallBData[2],1)
            $tmpCallBData[2] = StringTrimRight($tmpCallBData[2],5)
            $tmpCallBData[2] = $tmpCallBData[2]
            $dataArray[5] = $tmpCallBData[2]
         ElseIf StringInStr($tmpCallBData[2],'"}}') Then
            $tmpCallBData[2] = StringTrimLeft($tmpCallBData[2],1)
            $tmpCallBData[2] = StringTrimRight($tmpCallBData[2],3)
            $dataArray[5] = $tmpCallBData[2]
         ElseIf StringInStr($tmpCallBData[2],'"}') Then
            $tmpCallBData[2] = StringTrimLeft($tmpCallBData[2],1)
            $tmpCallBData[2] = StringTrimRight($tmpCallBData[2],2)
            $dataArray[5] = $tmpCallBData[2]
         ElseIf StringRight($tmpCallBData[2],1) = '"' Then
            $tmpCallBData[2] = StringTrimLeft($tmpCallBData[2],1)
            $tmpCallBData[2] = StringTrimRight($tmpCallBData[2],1)
            $dataArray[5] = $tmpCallBData[2]
        EndIf
     EndIf
    If StringInStr($data,'message_id') Then
         $tmpMsgID = StringSplit($data,':')
         $dataArray[6] = $tmpMsgID[3]
     EndIf
   Next
   If $dataArray[1] = '' Then
      For $i=1 to $secondSplit[0]
         If StringInStr($secondSplit[$i],'first_name') Then
            $tmpUsername = StringSplit($secondSplit[$i],':')
            $tmpUsername[2] = StringTrimLeft($tmpUsername[2],1)
            $tmpUsername[2] = StringTrimRight($tmpUsername[2],1)
            $dataArray[1] = $tmpUsername[2]
         EndIf
      Next
   EndIf
   Return $dataArray
EndFunc ;==> _JSONDecode



Func _answerCallbackQuery($ChatID, $Text, $Alert = True, $Cache_time = '5')
   Local $Query = $URL & "/answerCallbackQuery?callback_query_id=" & $ChatID &"&text=" & $Text & "&show_alert=" & $Alert & "&cache_time=" & $Cache_time
   Local $Response = HttpPost($Query)
   ;Return $Response
   Return True
EndFunc ;==> _answerCallbackQuery

Func _editMessageReplyMarkup($ChatID, $Message_id, $Reply_markup)
   Local $Query = $URL & "/editMessageReplyMarkup?chat_id=" & $ChatID  &"&message_id=" & $Message_id & "&reply_markup=" & $Reply_markup
   Local $Response = HttpPost($Query)
   ;Return $Response
   Return True
EndFunc ;==> _editMessageReplyMarkup

Func _editMessageText($ChatID, $Message_id, $Text, $Reply_markup)
   Local $Query = $URL & "/editMessageText?chat_id=" & $ChatID  &"&message_id=" & $Message_id & "&text=" & $Text & "&reply_markup=" & $Reply_markup
   Local $Response = HttpPost($Query)
   ;Return $Response
   Return True
EndFunc ;==> _editMessageText

 

Edited by sakamoto
Link to comment
Share on other sites

21 hours ago, sakamoto said:

<snip>

<snip>

 

Wow, awesome work. Thank you for share. I'm trying to find an easy way to split the message like json_decode function in PHP to make easier this process.

Edited by Melba23
Removed huge unecessary quote
Link to comment
Share on other sites

  • Moderators

LinkOut,

When you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - responders know what they wrote and it just pads the thread unnecessarily.

volond,

Welcome to the AutoIt forums. But as this is an English speaking forum, it would have helped more if you had translated the link.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 1 month later...
  • Developers

CHATID is the id of the person the BOT receives/sends the messages to, so simply send an messages from your personal telegram account to the BOTID you have created and then  read that message with the BOT's account information. You will find the CHATID in the returned JSON information.

Jos 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 4 months later...
  • 4 weeks later...
  • Developers

Try this version:

$msreply= "Wellcome To 'Zoo World'.%0AYou can control by sending these commands: ......"
_SendMsg($msgData[2],$msreply )

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I'm somewhere lost in this.
I made a bot and have a token, botname and a username.
How can I send a message to a telegram account from a AutoIt script?
 
#include "Telegram UDF.au3"

$ChatID = "Your_Chat_ID_For_Test"
_InitBot("Bot_ID","Bot_Token")

ConsoleWrite("Test _GetUpdates   -> "  & @TAB & _GetUpdates() & @CRLF)
ConsoleWrite("Test _GetMe        -> "  & @TAB & _GetMe() & @CRLF)

ConsoleWrite("Test _SendMsg      -> "  & @TAB & _SendMsg($ChatID,"Test _SendMsg") & @CRLF)
ConsoleWrite("Test _ForwardMsg   -> "  & @TAB & _ForwardMsg($ChatID,$ChatID,'MsgID') & @CRLF)

ConsoleWrite("Test _SendPhoto    -> "  & @TAB & _SendPhoto($ChatID,"C:\image.jpg","Test _SendPhoto") & @CRLF)
ConsoleWrite("Test _SendVideo    -> "  & @TAB & _SendVideo($ChatID,"C:\video.mp4","Test _SendVideo") & @CRLF)
ConsoleWrite("Test _SendAudio    -> "  & @TAB & _SendAudio($ChatID,"C:\audio.mp3","Test _SendAudio") & @CRLF)
ConsoleWrite("Test _SendDocument -> "  & @TAB & _SendDocument($ChatID,"C:\document.txt","Test _SendDocument") & @CRLF)
ConsoleWrite("Test _SendVoice    -> "  & @TAB & _SendVoice($ChatID,"C:\voice.ogg","Test _SendVoice") & @CRLF)
ConsoleWrite("Test _SendSticker  -> "  & @TAB & _SendSticker($ChatID,"C:\sticker.webp") & @CRLF)
ConsoleWrite("Test _SendLocation -> "  & @TAB & _SendLocation($ChatID,"74.808889","-42.275391") & @CRLF)
ConsoleWrite("Test _SendContact  -> "  & @TAB & _SendContact($ChatID,"0123456789","Josh") & @CRLF)
ConsoleWrite("Test _SendChatAction -> " & @TAB & _SendChatAction($ChatID,"typing") & @CRLF)

ConsoleWrite("Test _GetUserProfilePhotos -> " & @TAB & _GetUserProfilePhotos($ChatID) & @CRLF)
ConsoleWrite("Test _GetChat              -> " & @TAB & _GetChat($ChatID) & @CRLF)

While 1
   $msgData = _Polling()
   _SendMsg($msgData[2],$msgData[3])
WEnd

 

I use this test script and bot token is clear but what do I insert at Bot_id, is this the botname or the username?
And how do I receive the chat_id so that I can send some text to a other telegram account?
 
What ever I try to insert at the bot_id I just can get it to work.
Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...