Telegram Bot

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
marco
Posts: 64
Joined: 03 Dec 2015 19:50

Telegram Bot

Post by marco » 31 Jul 2019 18:38

Hi all,
I use raspberry platform with razberry.
I usually spend some time to check new stuff so I've tested also Telegram bot too. I tested it with v2.3.7, v2.3.8 and now with v3.0.0 release. Every time, I have the same results:

"something went wrong",
"Cannot instantiate module: Zway-Telegram-Bot: TypeError: undefined is not a function".

Well, let me try to recap.
At first, I found this interesting project

https://github.com/CopyCat73/Zway-Telegram-Bot

so I cloned it in /opt/z-way-server/automation/modules and I've prepared bot on telegram as per instructions and as usual.
Rebooted z-way server I was able to see the new app between LocalApps but when I tried to instantiate it pushing on save button, the error appeared.

So I googled searching for a solution.

These posts

https://github.com/maros/Zway-InfluxDbStats/issues/2
https://github.com/maros/Zway-BaseModul ... /README.md

pushed me, as described referring to BaseModule, to edit and modify the index.js and module.json files directly.

Same results.

Just to attempt, I tried also this

https://github.com/CopyCat73/Zway-Teleg ... e7f33d2b28

Of course, the same results.

Now I'm here to ask if anyone of you have an idea to make the bot working. Do you have?
Thanks,
Marco
Marco

User avatar
PoltoS
Posts: 4846
Joined: 26 Jan 2011 19:36

Re: Telegram Bot

Post by PoltoS » 31 Jul 2019 23:19

The easiest is to look in the log to see the line where the problem occurs. The error happens because something is called, but not defined.

like some.thing(...), where thing is not defined.

marco
Posts: 64
Joined: 03 Dec 2015 19:50

Re: Telegram Bot

Post by marco » 01 Aug 2019 09:54

Thanks Poltos for your quick reply.
This is what log reports (I already checked at it).
[2019-08-01 08:37:21.458] [core] Notification: error (core): Cannot instantiate module: Zway-Telegram-Bot: TypeError: undefined is not a function
[2019-08-01 08:37:21.469] [core] TypeError: undefined is not a function
at AutomationController.instantiateModule (automation/classes/AutomationController.js:465:14)
at AutomationController.createInstance (automation/classes/AutomationController.js:936:17)
at ZAutomationAPIWebRequest._.extend.createInstance (automation/ZAutomationAPIProvider.js:1333:31)
at ZAutomationAPIWebRequest.ZAutomationWebRequest.handleRequest (automation/WebserverRequestRouter.js:263:35)
at automation/WebserverRequestRouter.js:32:29
at WebServer.document_root (automation/Webserver.js:35:11)


As we can see it refers to external resources from Telegram module and I don't think there is something to correct in them.
Actually, I can only proceed by attempts on the module files...
Marco

User avatar
PoltoS
Posts: 4846
Joined: 26 Jan 2011 19:36

Re: Telegram Bot

Post by PoltoS » 02 Aug 2019 00:03

Ah, obvious. This means the file name do not match the class name (in the file itself).

In fact looks they match, but it is not allowed to name JavaScript classes with hyphen.

Name it ZwayTelegramBot instead of Zway-Telegram-Bot. Please rename the older and all metions in index.js and module.json.

User avatar
PoltoS
Posts: 4846
Joined: 26 Jan 2011 19:36

Re: Telegram Bot

Post by PoltoS » 02 Aug 2019 00:04

Correction - just rename the folder to TelegramBot instead of Zway-Telegram-Bot. Inside everythin is okey

marco
Posts: 64
Joined: 03 Dec 2015 19:50

Re: Telegram Bot

Post by marco » 03 Aug 2019 21:09

Correct. Thak you Poltos.
I've just checked and it works for me. Then I can send notifications to my telegram chat from my zway system with the relevant bot.
Now, I'm going to look for sending commands from chat to system...
Hope that CopyCat will upload the module for everybody
Marco

Post Reply