Page 1 of 1

Telegram BOT

Posted: Monday 07 August 2017 15:33
by bing69
Have been running the telegram bot for some time without any problems. Now also want to add my wife. Follow the wiki again and create a new bot. However, if I want to retrieve the ID by:

https://api.telegram.org/bot784324329:E ... getUpdates

(fill in her information ofcourse), I only get the result:

{"ok": true, "result": []} further Is not shown.

What do i wrong??

Re: Telegram BOT

Posted: Monday 07 August 2017 16:03
by jvdz
Why have you created a new bot? I am using a single BOT instances with multiple different persons/phones?
It is just a matter of getting them setup in the TelegramBotWhiteListedIDs variable seperated with a verticalbar character.

Jos

Re: Telegram BOT

Posted: Monday 07 August 2017 17:18
by bing69
Sorry but where van i find that??

Re: Telegram BOT

Posted: Monday 07 August 2017 19:21
by jvdz
From: https://www.domoticz.com/wiki/Remote_Co ... _Variables
Domoticz User Variables[edit]
Create the following user variables in Domoticz before starting dtgbot
TelegramBotOffset - integer: In order to stop dtgbot from processing the same message repeatedly it needs to keep track of the id of the next message. To do this create a user variable in Domoticz called TelegramBotOffset and set it to a value of 1. The first use of dtgbot will result in all unread messages being received and processed, at which point the offset will be correctly set and then only new messages will be processed from now on.
TelegramBotMenu - string: This will determine whether custom keyboards are displayed - set the value to On to use custom keyboard and Off to not use custom keyboards.
TelegramBotWhiteListedIDs string: Use this string to secure your dtgbot from being used by everybody. Put a list of userids that you want to allow to access your system separated by | here as userid1|userid2|userid3 , these are numbers so it will look like 12345678|2343249724|4534957 or use 1234342234 if you only want 1 person to access the system. If this variable does not exist then anybody can access your bot.
Jos

Re: Telegram BOT

Posted: Monday 07 August 2017 20:46
by bing69
jvdz wrote:From: https://www.domoticz.com/wiki/Remote_Co ... _Variables
Domoticz User Variables[edit]
Create the following user variables in Domoticz before starting dtgbot
TelegramBotOffset - integer: In order to stop dtgbot from processing the same message repeatedly it needs to keep track of the id of the next message. To do this create a user variable in Domoticz called TelegramBotOffset and set it to a value of 1. The first use of dtgbot will result in all unread messages being received and processed, at which point the offset will be correctly set and then only new messages will be processed from now on.
TelegramBotMenu - string: This will determine whether custom keyboards are displayed - set the value to On to use custom keyboard and Off to not use custom keyboards.
TelegramBotWhiteListedIDs string: Use this string to secure your dtgbot from being used by everybody. Put a list of userids that you want to allow to access your system separated by | here as userid1|userid2|userid3 , these are numbers so it will look like 12345678|2343249724|4534957 or use 1234342234 if you only want 1 person to access the system. If this variable does not exist then anybody can access your bot.
Jos
Jos,

Do we talk about the same? I have installed and work according to this page:
Https://www.domoticz.com/wiki/Telegram_Bot

Ad

Re: Telegram BOT

Posted: Monday 07 August 2017 21:00
by jvdz
You are correct when you only use the Telegram bot to send notifications.
I assume you also use the Bot to control Domoticz. :-)
Either way, you still are able to use the single bot to send messages to multiple users of Telegram, and control Domoticz from this BOT with the page I linked to.
I use LUA code to send notifications to the different telephones like described on the page you linked: https://www.domoticz.com/wiki/Telegram_ ... iple_users

Jos

Re: Telegram BOT

Posted: Monday 07 August 2017 21:31
by bing69
jvdz wrote:You are correct when you only use the Telegram bot to send notifications.
I assume you also use the Bot to control Domoticz. :-)
Either way, you still are able to use the single bot to send messages to multiple users of Telegram, and control Domoticz from this BOT with the page I linked to.
I use LUA code to send notifications to the different telephones like described on the page you linked: https://www.domoticz.com/wiki/Telegram_ ... iple_users

Jos
Jos,

Thanks. But then we're back with my problem again.
I do not get an id back from telegram. As in the example.

{"ok":true,"result":[{"update_id":939819607,
"message":{"message_id":81,"from":{"id":1234567,"first_name":"Joe","last_name":"Bloggs","username":"jbloggs"},"chat":
{"id":1234567,"first_name":"Joe","last_name":"Bloggs","username":"jbloggs"},"date":1436104501,"text":"\/devices Study"}},{"update_id":939819608,
"message":{"message_id":82,"from":{"id":1234567,"first_name":"Joe","last_name":"Bloggs","username":"jbloggs"},"chat":
{"id":1234567,"first_name":"Joe","last_name":"Bloggs","username":"jbloggs"},"date":1436104512,"text":"\/off 1"}}]}

i get only :

{"ok":true,"result":[{

Re: Telegram BOT

Posted: Monday 07 August 2017 22:13
by zicht
Hi

Just an idea, "Thinking out loud" :

you should be able to send a message to your bot from you wifes phone.
Then you should be able to read the message with the getupdate from the telegram api.
Do this in you browser. In the returned update message containing the message you have send you should be able to read the ID of you wifes telegram.

like : https://api.telegram.org/bot:key/getUpdates

probably cause of you issue :
Just be shure to turn of any other receptors of the message (turn your script and phone off just to be sure), the getupdate is reset if message has status read, mening you would only get an empty ok message.

Also, if the api sees unread messages (EG no getupdates?offset=xxx where xxx is the message id) that is limted, you have to read received messages or thing will hangup *i assume queu full"....
I have ported the complete telegram thingy to lua as i am on windows and working fine. I can control any thing i want right now this way.
Sure willing to help you find you problem, as it took me quite a while to understand how to manage things :)

Hope this will get you on track...

Re: Telegram BOT

Posted: Monday 07 August 2017 22:19
by bing69
Thanks all for the answers. Tomorrow i go away for a holiday.
When i'm back i go further!