Telegram API

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Telegram API

Post by Fulminare » 17 Sep 2021, 19:46

Okay let me make it abundantly clear, strictly speaking this code is WAY above my understanding / execution.

However I followed some steps and it began to sort of work.

This script connects telegram and ahk. As I understand, commands can be sent from phone's telegram to ahk for performing some tasks.

I have been able to send a message by running this script to the telegram bot that I have created .

This is my doubt (yes I have entered token,chat id e.t.c and downloaded the json file.)

Code: Select all

#include json.ahk																		; Coco's JSON library, get it here:   https://autohotkey.com/boards/viewtopic.php?t=627





botToken  :=  "MyToken"					; add your Telegram bot token
chatID := MyChatID																	; add your chat ID for testing porposes

oCustomers := {}																; Object of user ids of registered customers -> add your customers, you can send them a personal registration link
oCustomers[CHAT ID] := ""										; add your chat id (and name) to the customer object for testing purposes
offset := ""																			; Telegram message offset

cmds := {	"Command1" : "somefunction"										; bundle commands (case insensitive) and corresponding script functions to call 
				, 	"Command2" : "somefunction"
				,   "Command3" : "somefunction"
				, 	"Show inline buttons" : "inlinebuttons"
				, 	"Remove keyboard" : "RemoveKeyb"  }

; add custom keyboard for testing
keyb=																		; json formatted string
( 
	{"keyboard":[ ["Command1", "Command2"], ["Show inline buttons", "Remove Keyboard"] ], "resize_keyboard" : true } 
)																			
url := "https://api.telegram.org/bot" botToken "/sendMessage?text=Keyboard added&chat_id=" chatID "&reply_markup=" keyb
json_message := URLDownloadToVar(url)   
	; msgbox % json_message

; Check for new updates 
 SetTimer, UpdateTimer, 1000							; every 1000 ms = 1 second
return
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Esc::ExitApp													; hit Escape to stop the script
;----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

UpdateTimer:																									; checks constantly for user input in your bot
stack := {}																										; message stack			

updates := GetUpdates(botToken, (offset+1))											; get (new) updates from your bot as JSON string; keep track of old messages  
	;msgbox % updates
oUpdates := JSON.Load(updates)											; create an AHK object from the JSON string
If oUpdates.ok																			; check if json answer was "ok" : true
{
		
	loop % oUpdates.result.MaxIndex()		; determine number of new messages (updates) 
			stack.Push(oUpdates.result[A_index])		; add all updates (=messages) to stack
	For key, msg in stack
	{
		from_id := first_name := mtext := last_name := username := ""
		if (msg.callback_query.data!="")									; inline buttons have to be handled differently than normal messages and normal keyboards
		{	
			from_id := msg.callback_query.from.id
			mtext := msg.callback_query.data
		}	
		else 																					; get message text or message from normal keyboard
		{		
			from_id := msg.message.from.id									; which ID sent the message?
			mtext := msg.message.text
					;first_name := msg.message.from.first_name
					;last_name := msg.message.from.last_name
					;username ;=  msg.message.from.username
		}
		offset := msg.update_id													; keep track of processed messages
	
		if oCustomers.Haskey(from_id)				; check for known users...   optional
		{	
				if cmds.Haskey(mtext)														; is message a known command?
				{
					fun := cmds[mtext]									;look up which function to call for a specific command
					%fun%(botToken, msg, from_id, mtext)			; call function
				}
				else
				{
					text := "Sorry... I don't know this command."				  
					;    url encoding for messages :  %0A = newline (\n)   	%2b = plus sign (+)		%0D for carriage return \r        single Quote ' : %27			%20 = space
					SendText(botToken, text, from_id)
				}
		}
		else
				Traytip, No, Unknown user, 3		
	}  ; end 'for' 
}
return

;--------------------------------------------------------  functions for user commands ---------------------------------------------------------------------------------------------------------
somefunction(botToken, msg, from_id, mtext) 
{
		if (msg.callback_query.id!="")						;  After the user presses a callback button, Telegram clients will display a progress bar until you call answerCallbackQuery 
		{	
			cbQuery_id := msg.callback_query.id
			; Notification and alert are optional
			url := "https://api.telegram.org/bot" botToken "/answerCallbackQuery?text=Notification&callback_query_id=" cbQuery_id "&show_alert=true"
			json_message := URLDownloadToVar(url)  
				;msgbox % json_message
		}
		text := "You chose " mtext				  
		SendText(botToken, text, from_id)        ;  url encoding for messages :  %0A = newline (\n)   	%2b = plus sign (+)		%0D for carriage return \r        single Quote ' : %27			%20 = space
		return
}
;--------------------------------------------------------------------
; add inline buttons
inlinebuttons(botToken, msg,  from_id, mtext="") 
{
	keyb=																	; json string:
	( 
		{"inline_keyboard":[ [{"text": "Command One" , "callback_data" : "Command1"}, {"text" : "Some button (Cmd3)",  "callback_data" : "Command3"} ] ], "resize_keyboard" : true } 
	)
	url := "https://api.telegram.org/bot" botToken "/sendMessage?text=Keyboard added&chat_id=" from_id "&reply_markup=" keyb
	json_message := URLDownloadToVar(url)   ; find this function at the next code box below
	return json_message		
}
;---------------------------------------------------------------------
; Remove custom keyboard 
 RemoveKeyb(botToken, msg, from_id, mtext="") 
 {
	keyb=
	( 
		{"remove_keyboard" : true } 
	)
	url := "https://api.telegram.org/bot" botToken "/sendMessage?text=Keyboard removed&chat_id=" from_id "&reply_markup=" keyb
	json_message := URLDownloadToVar(url)  
		;msgbox % json_message
	return
}	
;------------------------------------------  Telegram functions  --------------------------------------------------------------------------------------------------------
GetUpdates(token, offset="", updlimit=100, timeout=0)     
{							
	If (updlimit>100)
		updlimit := 100
	; Offset = Identifier of the first update to be returned.
	url := "https://api.telegram.org/bot" token "/getupdates?offset=" offset "&limit=" updlimit "&timeout=" timeout
	updjson := URLDownloadToVar(url)					
	return updjson
}
;------------------------------------------------
SendText(token, text, from_id, replyMarkup="",  parseMode="" )
{
		url := "https://api.telegram.org/bot" token "/sendmessage?chat_id=" from_ID "&text=" text "&reply_markup=" replyMarkup "&parse_mode=" parseMode
		json_message := URLDownloadToVar(url)
		return json_message
}
;----------------------------------- additional functions ------------------------------------------------------------------------------------------------------------------
URLDownloadToVar(url,ByRef variable=""){						; function originally by Maestrith, I think
	try																						; keep script from breaking if API is down or not reacting
	{	
		hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
		hObject.Open("GET",url)
		hObject.Send()
		variable:=hObject.ResponseText
		return variable
	}
}

In line 14 it says cmds := { "Command1" : "somefunction" }

the script adds a keyboard to the bot chat (ref img)


This is a simple function

Code: Select all

myfunc()
return

myfunc(){
	MsgBox HI
}

1. So will including the above function in { "Command1" : "somefunction" } Call it ?

2. How to call that function from the telegram api script ?




Kindly do not take the trouble of downloading and testing. My lack of coding knowledge will result in your time being wasted.

If this question is as simple as I think, please let me know and answer at your convenience :)

Thank you !

Regards.
Attachments
bot.jpeg
bot.jpeg (34.7 KiB) Viewed 3059 times
gregster
Posts: 8886
Joined: 30 Sep 2013, 06:48

Re: Telegram API

Post by gregster » 18 Sep 2021, 05:04

You are using some example code which I made some time ago to demonstrate some basic ideas. It could be varied or improved in a myriad of ways.
If you just want to change the function which gets called when you press the Command1 button, just change the line cmds := { "Command1" : "somefunction" to

Code: Select all

cmds := {	"Command1" : "myfunc"	
(without parentheses after the function name! you added them in the code you PMed me)

Although the other functions used here all have the same set of parameters (botToken, msg, from_id, mtext) and your function has no parameter at all, you don't even have to change the code because dynamic function calls ignore/tolerate surplus parameters in the function call.
Generally, it would make sense - and would be cleaner - to also add some information which function should be called with which parameter set, if there are differences. But in this simple case that is not necessary.

Btw, you introduced a typo in the line oCustomers[CHAT ID] := "" - please remove the space in the variable name.
Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Re: Telegram API

Post by Fulminare » 18 Sep 2021, 22:06

Your code (in it's current form) can perform any action on receiving a command isn't it ?
I mean of course when everything is set up properly that is.

1. Doubt regarding setting up

Code: Select all

botToken  :=  "MyToken"					; add your Telegram bot token
chatID := MyChatID																	; add your chat ID for testing porposes

oCustomers := {}																; Object of user ids of registered customers -> add your customers, you can send them a personal registration link
oCustomers[	chatID] := ""										; add your chat id (and name) to the customer object for testing purposes
offset := ""																			; Telegram message offset

A.
in lines 1 & 2 my token and my id should be entered.

as I myself am the "customer" so to speak, lines 4 & 5 should carry the same token and ID as the first two lines ?

B.
Should telegram on my desktop be opened or run in the background ?(like a minimised tray icon.) ?


2. Doubt regarding command.

Code: Select all

cmds := {	"Command1" : "somefunction"										; bundle commands (case insensitive) and corresponding script functions to call 
				, 	"Command2" : "somefunction"
				,   "Command3" : "somefunction"
A.
Function as in a function ?

like

Code: Select all

"Command1" : "myfunc"



Or any "action" ?

like

Code: Select all

"Command1" : "Open file"  / "Append File"  e.t.c
?



if it's a function I tried calling "myfunc" and it didn't work

I used #include , Run file . Nothing worked.


Everything seems to be fine, but I feel there is one key point that I am doing incorrectly. Because, a connection exists between my phone and ahk. it's only from ahk to telegram.


I will keep trying of course. Will post any progress if I make any
gregster
Posts: 8886
Joined: 30 Sep 2013, 06:48

Re: Telegram API

Post by gregster » 19 Sep 2021, 20:28

Fulminare wrote:
18 Sep 2021, 22:06
Your code (in it's current form) can perform any action on receiving a command isn't it ?
I mean of course when everything is set up properly that is.
You can execute any AHK code you want. But some caution is certainly advised.
Since a Telegram bot is generally public, limiting its (re-)actions to your personal chatID makes sense, so that no other Telegram user can trigger actions on your computer - intentionally or unintentionally.

ad 1.A: You have to add your bot's token and your personal chatID on the first two lines. This is all the setup you need - now the two variables botToken and chatID are assigned and can be used furtheron. Like, for example, in line 5 oCustomers[chatID] := "" - there is no need to hardcode your chatID in that line; it can use the variable. That's what variables are for.

ad 1.B: No. You can open it, but generally there is no need.

ad 2.A: Currently, the code will look for an existing function (usually user-defined, like yours, or the ones included in the example code). Of course, you could change the code in any way you like. But "Open file" / "Append File" are no "actions" that AHK would understand without making some code changes to the script.
You don't even have to use the cmds object as a look-up. The general idea is to parse the message which gets sent via the bot and then react to it in a pre-defined way. Of course, you could simply do that with if/else- or switch/case-ladders. Or, if you wanted to parse whole sentences, you would need some more elaborate code.

Fulminare wrote:if it's a function I tried calling "myfunc" and it didn't work

I used #include , Run file . Nothing worked.
You don't need run or #include (in fact, these statements are not suited to call functions) - the code is already set up to dynamically call any function which is defined for the given bot commands (see comments in the example code), with the caveat re the parameter handling that I mentioned in my last post. Just add your own function to the code, and define in cmds, for which sent command(s)/message(s) it should be called.

Fulimnare wrote:Because, a connection exists between my phone and ahk. it's only from ahk to telegram.
That should be enough. AHK communicates via the Telegram Bot API with your bot (that's what the bot token and the chat ID(s) are for). No additional Telegram client needs to be running on your computer to do that.
Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Re: Telegram API

Post by Fulminare » 19 Sep 2021, 22:30

Summing up what you have said (please correct me if I am wrong)

1. Bots are public and can be misused by others. Hence only I should interact with my bot.

2. As I am the the only user of the bot, the following lines

Code: Select all

oCustomers := {}																; Object of user ids of registered customers -> add your customers, you can send them a personal registration link
oCustomers[	chatID] := ""										; add your chat id (and name) to the customer object for testing purposes
offset := ""																			; Telegram message offset
Can be left blank.

3. Telegram on my desktop need not be open for the command to get executed.


4. Your script in its current form basically gets triggered if the command received from the phone is expressed as a "function" like "myfunc()"
So if I want to use it as it is,
actions like run a file e.t.c should be put in a function and that function needs to be called from your script.


5. In your previous reply, you've told me to use

Code: Select all

cmds := {	"Command1" : "myfunc"	
If I am just wanting to call "myfunc()"


That didn't work.

That's why I tried using #include and then calling "myfunc".

How will the bot script know which function is "myfunc" ?

the code is already set up to dynamically call any function
You mean to say the bot script will search for "myfunc" in all my ahk scripts and call it ?



This is what I have done based on your suggestion

Code: Select all

#include json.ahk		; Coco's JSON library, get it here:   https://autohotkey.com/boards/viewtopic.php?t=627

;Run C:\Users\user\Desktop\AHK TELEGRAM\msgbox test.ahk

botToken  :=  "MyToken"					; add your Telegram bot token
chatID := MyID																		; add your chat ID for testing porposes

oCustomers := {}																; Object of user ids of registered customers -> add your customers, you can send them a personal registration link
oCustomers[] := ""											; add your chat id (and name) to the customer object for testing purposes
offset := ""																			; Telegram message offset

cmds := {	"Command1" : "myfunc"										; bundle commands (case insensitive) and corresponding script functions to call 
				, 	"Command2" : "somefunction"
				,   "Command3" : "somefunction"
				, 	"Show inline buttons" : "inlinebuttons"
				, 	"Remove keyboard" : "RemoveKeyb"  }

; add custom keyboard for testing
keyb=																		; json formatted string
( 
	{"keyboard":[ ["Command1", "Command2"], ["Show inline buttons", "Remove Keyboard"] ], "resize_keyboard" : true } 
)																			
url := "https://api.telegram.org/bot" botToken "/sendMessage?text=Keyboard added&chat_id=" chatID "&reply_markup=" keyb
json_message := URLDownloadToVar(url)   
	; msgbox % json_message

; Check for new updates 
 SetTimer, UpdateTimer, 1000							; every 1000 ms = 1 second
return
;---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Esc::ExitApp													; hit Escape to stop the script
;----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

UpdateTimer:																									; checks constantly for user input in your bot
stack := {}																										; message stack			

updates := GetUpdates(botToken, (offset+1))											; get (new) updates from your bot as JSON string; keep track of old messages  
	;msgbox % updates
oUpdates := JSON.Load(updates)											; create an AHK object from the JSON string
If oUpdates.ok																			; check if json answer was "ok" : true
{
		
	loop % oUpdates.result.MaxIndex()		; determine number of new messages (updates) 
			stack.Push(oUpdates.result[A_index])		; add all updates (=messages) to stack
	For key, msg in stack
	{
		from_id := first_name := mtext := last_name := username := ""
		if (msg.callback_query.data!="")									; inline buttons have to be handled differently than normal messages and normal keyboards
		{	
			from_id := msg.callback_query.from.id
			mtext := msg.callback_query.data
		}	
		else 																					; get message text or message from normal keyboard
		{		
			from_id := msg.message.from.id									; which ID sent the message?
			mtext := msg.message.text
					;first_name := msg.message.from.first_name
					;last_name := msg.message.from.last_name
					;username ;=  msg.message.from.username
		}
		offset := msg.update_id													; keep track of processed messages
	
		if oCustomers.Haskey(from_id)				; check for known users...   optional
		{	
				if cmds.Haskey(mtext)														; is message a known command?
				{
					fun := cmds[mtext]									;look up which function to call for a specific command
					%fun%(botToken, msg, from_id, mtext)			; call function
				}
				else
				{
					text := "Sorry... I don't know this command."				  
					;    url encoding for messages :  %0A = newline (\n)   	%2b = plus sign (+)		%0D for carriage return \r        single Quote ' : %27			%20 = space
					SendText(botToken, text, from_id)
				}
		}
		else
				Traytip, No, Unknown user, 3		
	}  ; end 'for' 
}
return

;--------------------------------------------------------  functions for user commands ---------------------------------------------------------------------------------------------------------
somefunction(botToken, msg, from_id, mtext) 
{
		if (msg.callback_query.id!="")						;  After the user presses a callback button, Telegram clients will display a progress bar until you call answerCallbackQuery 
		{	
			cbQuery_id := msg.callback_query.id
			; Notification and alert are optional
			url := "https://api.telegram.org/bot" botToken "/answerCallbackQuery?text=Notification&callback_query_id=" cbQuery_id "&show_alert=true"
			json_message := URLDownloadToVar(url)  
				;msgbox % json_message
		}
		text := "You chose " mtext				  
		SendText(botToken, text, from_id)        ;  url encoding for messages :  %0A = newline (\n)   	%2b = plus sign (+)		%0D for carriage return \r        single Quote ' : %27			%20 = space
		return
}
;--------------------------------------------------------------------
; add inline buttons
inlinebuttons(botToken, msg,  from_id, mtext="") 
{
	keyb=																	; json string:
	( 
		{"inline_keyboard":[ [{"text": "Command One" , "callback_data" : "Command1"}, {"text" : "Some button (Cmd3)",  "callback_data" : "Command3"} ] ], "resize_keyboard" : true } 
	)
	url := "https://api.telegram.org/bot" botToken "/sendMessage?text=Keyboard added&chat_id=" from_id "&reply_markup=" keyb
	json_message := URLDownloadToVar(url)   ; find this function at the next code box below
	return json_message		
}
;---------------------------------------------------------------------
; Remove custom keyboard 
 RemoveKeyb(botToken, msg, from_id, mtext="") 
 {
	keyb=
	( 
		{"remove_keyboard" : true } 
	)
	url := "https://api.telegram.org/bot" botToken "/sendMessage?text=Keyboard removed&chat_id=" from_id "&reply_markup=" keyb
	json_message := URLDownloadToVar(url)  
		;msgbox % json_message
	return
}	
;------------------------------------------  Telegram functions  --------------------------------------------------------------------------------------------------------
GetUpdates(token, offset="", updlimit=100, timeout=0)     
{							
	If (updlimit>100)
		updlimit := 100
	; Offset = Identifier of the first update to be returned.
	url := "https://api.telegram.org/bot" token "/getupdates?offset=" offset "&limit=" updlimit "&timeout=" timeout
	updjson := URLDownloadToVar(url)					
	return updjson
}
;------------------------------------------------
SendText(token, text, from_id, replyMarkup="",  parseMode="" )
{
		url := "https://api.telegram.org/bot" token "/sendmessage?chat_id=" from_ID "&text=" text "&reply_markup=" replyMarkup "&parse_mode=" parseMode
		json_message := URLDownloadToVar(url)
		return json_message
}
;----------------------------------- additional functions ------------------------------------------------------------------------------------------------------------------
URLDownloadToVar(url,ByRef variable=""){						; function originally by Maestrith, I think
	try																						; keep script from breaking if API is down or not reacting
	{	
		hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
		hObject.Open("GET",url)
		hObject.Send()
		variable:=hObject.ResponseText
		return variable
	}
}

As I have said, the script sort of works. On running it says "Keyboard added" on my phone
But selecting "Command1" is not causing anything to happen on my desktop
gregster
Posts: 8886
Joined: 30 Sep 2013, 06:48

Re: Telegram API

Post by gregster » 22 Sep 2021, 19:28

Fulminare wrote:
19 Sep 2021, 22:30
1. Bots are public and can be misused by others. Hence only I should interact with my bot.
Public, yes. Generally, they can be found over Telegram's search function. Perhaps a cryptic name can reduce that risk, but as long as your bot only reacts to known chat IDs (your's, and perhaps your grandmother's and whoever you will allow), a random user will be ignored by this bot and probably lose interest in it very quickly.

Of course, bots are mainly meant to provide services to other users (like for example weather forecasts or news updates) and usually just send messages back to the bot's users. Your use case, in which you want to control your computer, is a special case. That's why you should apply extra care, understand what your script is doing exactly, and test your final code very thoroughly.

Fulminare wrote:
19 Sep 2021, 22:30
2. As I am the the only user of the bot, the following lines

Code: Select all

oCustomers := {}																; Object of user ids of registered customers -> add your customers, you can send them a personal registration link
oCustomers[	chatID] := ""										; add your chat id (and name) to the customer object for testing purposes
offset := ""																			; Telegram message offset
Can be left blank.
It's not about keeping them blank, but about keeping this example script functioning. The second line adds your userID to the group of allowed users (in this case, you are the only one). Of course, you can change how the script works, if you understand what it does, and depending on your goal.
Btw, the third line is completely unrelated to the allowed user question. It will be set by the script in order to keep track of message processing.
Fulminare wrote:
19 Sep 2021, 22:30
3. Telegram on my desktop need not be open for the command to get executed.
Correct.
Fulminare wrote:
19 Sep 2021, 22:30
4. Your script in its current form basically gets triggered if the command received from the phone is expressed as a "function" like "myfunc()"
So if I want to use it as it is,
actions like run a file e.t.c should be put in a function and that function needs to be called from your script.
Yes. Define a function.
Again, you could change how the script handles the parameters of functions, or you could change it to use no functions at all. This code is just a basic example.
Fulminare wrote:
19 Sep 2021, 22:30
5. In your previous reply, you've told me to use

Code: Select all

cmds := {	"Command1" : "myfunc"	
If I am just wanting to call "myfunc()"


That didn't work.

That's why I tried using #include and then calling "myfunc".

How will the bot script know which function is "myfunc" ?

the code is already set up to dynamically call any function
You mean to say the bot script will search for "myfunc" in all my ahk scripts and call it ?
You should read that quote in its context:
gregster wrote:the code is already set up to dynamically call any function which is defined for the given bot commands [...] Just add your own function to the code, and define in cmds, for which sent command(s)/message(s) it should be called.
You know how to define a function, right?
I mean, you started this topic with

Code: Select all

myfunc(){
	MsgBox HI
}
Of course, AHK won't look for this function in all of your AHK scripts.
That's why you add this function to your script (either by writing it into the script itself, or by pasting it into a script that you #include into your main script; or you could put your function in one of the library folders - but for now, for testing, just put it directly into the script!).
With the line

Code: Select all

cmds := {	"Command1" : "myfunc"	
you tell the script to call the myfunc() function, if the bot receives the message "Command1". If you look at the script, you will also find all the other functions which are mentioned in the following lines of the cmds object (look at the section "functions for user commands" of the script).
Fulminare wrote:
19 Sep 2021, 22:30
This is what I have done based on your suggestion
There is no myfunc() function in this script. What do you expect to happen?
So, please add your myfunc() function to the code...!
Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Re: Telegram API

Post by Fulminare » 22 Sep 2021, 21:03

First of all, Thanks a lot for taking the trouble of typing out such a detailed explanation :).

This script shows a message box "HI"

Code: Select all

myfunc()
return

myfunc(){
	MsgBox HI
}

So you are saying I should add the above to the Telegram script, and do this

Code: Select all

cmds := {	"Command1" : "myfunc"

Code: Select all

;myfunc()
;return

myfunc(){
	MsgBox HI
}

botToken  :=  ""					; add your Telegram bot token
chatID := 																		; add your chat ID for testing porposes

oCustomers := {}																; Object of user ids of registered customers -> add your customers, you can send them a personal registration link
oCustomers[] := ""											; add your chat id (and name) to the customer object for testing purposes
offset := ""																			; Telegram message offset

cmds := {	"Command1" : "myfunc"										; bundle commands (case insensitive) and corresponding script functions to call 
				, 	"Command2" : "somefunction"
				,   "Command3" : "somefunction"
				, 	"Show inline buttons" : "inlinebuttons"
				, 	"Remove keyboard" : "RemoveKeyb"  }
(for the purpose of showing you I didn't paste all the other lines of code from the telegram script)

I tried all combinations of adding that to the telegram script. But none of them worked. :(

Based on what you said. the function that is being called should be present in the telegram script like at the top (some place after #include json.ahk)

So the only problem is I am placing the message box code incorrectly.

After pasting the msgbox code in the telegram script and running it, it shows the message box and says "keyboard added" on my phone. But when I select command1 from the phone, no msgbox gets shown on the desktop

(look at the section "functions for user commands" of the script)
Yes. I have to add something there as well ?
It's not about keeping them blank, but about keeping this example script functioning.
Which means they have to be filled for this script to work ?
Post Reply

Return to “Ask for Help (v1)”