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.

Share this post


Link to post
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 😜

 

 


A cross-platform implementation of the AutoIt language

My contributions to the AutoIt Community ##AutoIt at freenode, real-time chat

3fHNZJ.gif

Spoiler

If I have hurt or offended you in anyway, Please accept my apologies, I never (regardless of the situation) intend to do that to anybody.

Share this post


Link to post
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^_^

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
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!

 

Share this post


Link to post
Share on other sites
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

 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

can someone please help me where to find CHATID and BOTID ?

@BotFather only gives me token of the bot.

 

Thanks.

Share this post


Link to post
Share on other sites

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.
  :)

Share this post


Link to post
Share on other sites

I can't make the send file working such as photo, same result to run with the test file by changing the path.

Console write Send photo error 4

Test _SendPhoto    ->     0

Share this post


Link to post
Share on other sites

can any body tell me, how use line break or new line  . i try using @CR , @LF  and @CRLF but not working. 

$msreply= "Wellcome To 'Zoo World'." & @CRLF & " You can control by sending these commands: ......"
 
 _SendMsg($msgData[2],$msreply )

 

Share this post


Link to post
Share on other sites

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.
  :)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Colduction
      Hi AutoIt Members and Programmers, i have a problem with Telegram UDF that does not work on some of my servers, Telegram is not restricted in these machines, here is console output in Windows 7 (Server):
      >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\.NetFramework\Desktop\telegram-udf-autoit-master\tests\Test.au3" /UserParams +>20:20:40 Starting AutoIt3Wrapper (19.1127.1402.0} from:SciTE.exe (4.2.0.0) Keyboard:00000429 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\.NetFramework\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\.NetFramework\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.5) from:C:\Program Files (x86)\AutoIt3 input:C:\Users\.NetFramework\Desktop\telegram-udf-autoit-master\tests\Test.au3 +>20:20:40 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\.NetFramework\Desktop\telegram-udf-autoit-master\tests\Test.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. Test file for Telegram UDF (https://github.com/xLinkOut/telegram-udf-autoit). This file need a valid ChatID of a Telegram user who has already sent at least a message to the bot, and a valid token given by @BotFather. Insert this data in the source code. "C:\Users\.NetFramework\Desktop\telegram-udf-autoit-master\src\Telegram.au3" (1098) : ==> The requested action with this object has failed.: $oHTTP.Send() $oHTTP^ ERROR ->20:20:41 AutoIt3.exe ended.rc:1 +>20:20:41 AutoIt3Wrapper Finished. >Exit code: 1 Time: 1.56 It's really annoying problem in WinHTTP
    • By Colduction
      Hi guys, i'm using Telegram UDF by @LinkOut from github with latest update, but this UDF has not any parse_mode ability in SendDocument and other send file's functions to make texts bold, italic or underline and i can't send Emojis via these functions too. i've tried to change HTML section of multipart/form-data but i did not get correct results.

      For example, i can't get correct results by sending a document with this URL Encoded caption: %F0%9F%93%84%20*Test*%20%F0%9F%93%84

      I will be happy to help me in this section. Thanks!
    • By pat4005
      A tiny UDF that can shoot magic packets at your computers to wake them the heck up. All credits to Olish.
      The only parameter it needs to be specified – is your machine's MAC-address (ip address (the second parameter), at which you will be sending magic packet is generating automatically from @IPAddress1 macro)
      Example:
      _WoL_WakeDevice('001CC0CAED7A') ; the second parameter (if necessery) must be a broadcast address of your local network segment (i.e. 192.168.0.255 for a network 192.168.0.0)  
      _WakeOnLan.au3
    • By MrCreatoR
      This UDF allows to create formatted label using pseudo element RichLabel (RichEdit actually). Formating is set by using special modificator similar to <font> tag in Html.
      Notes: This UDF is a transformation-continuation of related UDF


      Example:
      Download:
      GUIRichLabel_1.2.zip
      Small syntax related fix: GUIRichLabel_1.1.zip
      GUIRichLabel_1.1.zip
       
      History version:
×
×
  • Create New...