LinkOut

Telegram Bot UDF

34 posts in this topic

#21 ·  Posted

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



#22 ·  Posted

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 😜

 

 


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#23 ·  Posted

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

#24 ·  Posted

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

#25 ·  Posted

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

#26 ·  Posted

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

Share this post


Link to post
Share on other sites

#27 ·  Posted

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

#28 ·  Posted (edited)

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

#29 ·  Posted (edited)

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

#30 ·  Posted (edited)

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

#32 ·  Posted

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

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

#33 ·  Posted

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

#34 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

  • Similar Content

    • pboom
      By pboom
      I am looking for a way to retrieve filtered messages from the ‘system debug channel.' also known as  ‘kernel-mode debug output.'

      AutoIt must do the capture in real time. The following AutoIt UDF almost does what is required but it only captures application level, or Win32 debug output.

      https://www.autoitscript.com/forum/topic/82889-capture-debug-information-udf/#comment-593268

      The utility DebugView by Sysinternals captures the information as required by turning on Capture Kernal and in my case using the Filter include:

      *Incoming connection*

      The use of DebugView to do this is covered in the following tech note;

      https://www.tacticalsoftware.com/support/tech-notes/logging-com-port-activity.htm

      https://technet.microsoft.com/en-us/sysinternals/debugview.aspx

      However to make to make the information from DebugView available to my AutoIt script required DebugView capture to a text file and then my AutoIt script monitor that file for changes. The use of DebugView to capture the system debug channel could be made to work, but it was less than reliable and difficult to get started. The startup wasn’t something that could be easily automated not even with AutoIt.

      If you understood what I am talking about and made it this far, I think an explanation of the application is in order. Lots of details here sorry trying to answer questions in advance.

      I support a large installation of General Electric MUSE application. MUSE is a Windows-based medical application that processes and archives ECGs (electrocardiograms) taken on dedicated hardware (ECG Carts). Several methods exist on the cart to get the ECG from the Carts to the MUSE system; they range from floppies (on old obsolete hardware), memory cards, RS232 serial ports, and hardwired network connections.

      In our installation, we choose not to use the vendor-supplied network solution due to a variety of reasons I won’t get into here.  Instead, we have designed our own connection solution.

      We use a wireless serial server mounted on the ECG carts connecting to a server running a Serial/IP COM Port Redirector. The ECG cart and MUSE application think they are talking to each other via an RS232 port and as far as they are concerned, they are. However, this RS232 cable happens to run through our province (think State) wide Health Care WAN.  The hardware and software used can be seen on these two sites;

      http://www.bb-elec.com/Products/Wireless-Cellular/AirborneM2M-802-11-a-b-g-n-Dual-Band-Wireless/AirborneM2M-Industrial-Dual-Band-Wi-Fi-Router-Brid.aspx

      https://www.tacticalsoftware.com/virtual-serial-port-redirector/serial-ip.htm

      This setup works well we have over 130 ECG carts connecting using this setup. However, the end users are not technical, and there is a lot that can go wrong with wireless connections. So we do get complaints, often after the fact, that the ECG cart would not connect. A log of what ECG carts connected and when would be very helpful.

      The Serial redirector software can be configured to log all activity to the Kernal-mode Debug output. The serial redirector software itself being kernel level software. For configuration of the Wireless modules, we have custom written software (written in AutoIt) that amongst other things can display relevant configuration information for a Wireless module given it’s IP address.

      By extracting messages like the ones below from the Kernal-Mode Debug channel;

      COM56 : ½ Incoming connection from 10.158.188.172:51562

      COM18 : ½ Incoming connection from 10.158.188.200:50896

      COM19 : ½ Incoming connection from 10.158.188.180:59074

      COM68 : ½ Incoming connection from 142.239.15.82:34322

      We can have the module configuration program retrieve the configuration. The retrieved configuration contains more information such as the module ID number and wireless signal strength. This information is then logged to a file which is later loaded into a database. We can then query the database for connections made by a particular module within a specified time frame. The results of these Queries help us determine if the module was connected or is having problems connecting. Problems are usually indicated by poor signal strength and frequent re-connecting.

      So what I am looking for is a way for our module configuration program (written in AutoIt) to retrieve filtered Kernal-Level debug messages directly without using the DebugView application.

      The Forum post listed at the first of this message includes the source code for the DLL. So if you are versed in these matters and Visual Studio this may be an easy task. I looked at what needed to be done but, I was way over my head. If you look up the price of the serial IP redirector software, you can see that there is some money in our project for such things however, I do have a spending limit for purchases such as this.

       
    • jollypk
      By jollypk
      hI,
      Is there any UDF for Zeromq ?
      I need to communicate with a remote and local socket. Any suggestion or guidance will be very appreciated.
       
      Thanks
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning everyone
      I am working on a little script, which takes some data from a SQLite DB and should create a sort of report, inserting rows in a Word Document... I arrived at the point of:
      _Word_DocTableWrite() and, I don't know how to set the range parameter? What does that specify? 
      Thanks a lot for the help
      EDIT:
      Managed to write a table in the Word document, but now I get an error when I save the document with _Word_DocSaveAs(), with error 2.
      Which are possible causes? Thanks a lot, again
      EDIT 2:
      ... And, how can I set a border to the table? Maybe, with a sort of auto-formatting for text ( larger is the text, larger is the height/width of the table's cell ).
      Thanks  
      EDIT 3 ( bug ):
      Including the parameter $WdSaveChanges in the function _Word_DocSaveAs(), a save dialog box appears, and it should not do it, as it's written in the MSDN documentation:
      wdSaveChanges -1 Save pending changes automatically without prompting the user. Thanks again for everyone will answer to me  
    • SorryButImaNewbie
      By SorryButImaNewbie
      Hello,
      I try to add a new UDF to my AutoIT library, and it seems I fail. I started to work following the insturctions found on the wiki . 
      I made an extra folder just next to my AutoIT folder, called ExtraUDF, and copied the file CUIAutomation2.au3 in it (I try to use this UDF for automating a program) then I run sciteconfig, set this folder up as User Include Folder, applied the changes, then run the calltip manager and got a msg when I tried to parse it. I attach a few pictures for better present the problem.
      I think I miss something here, should i put anything else on the ExtraUDF folder? I dont think that the CallTip manager added the udf to scite, If I try to run it i get a msg saying that I Scite cant open the include file and naturally after that, It can't use the functions called from it.
      Thank you for your help and insight as always! Please ask, if anything is fuzzy about the problem
       





    • Gowrisankar
      By Gowrisankar
      Good day to the members of the forum.. 
      Is there any UDF that is available to automate Attachmate Extra Mainframe sessions?
      I am trying to automate mainframe processes. I couldn't get values from particular co-ordinates in mainframe or pass values to particular co-ordinates in mainframe.
      Please let me know if there is any UDF or any other kind of solution is available. 
      Thanks and regards,
      Gowrisankar R.