Closed jonathanschneider closed 3 years ago
Haha, how awsome is that?! I created a develop branch, but feel free to commit to your PR and we merge straight into master as soon as it's ready. Here are some entry points for your questions:
settings
object itself is transmitted "as whole" to the nodeJS backend (no need to adjust the socket). The logic resides in the (way too big, I know...) app.js file, starting line 1218.token
, chatID
, and telegram_enabled
-state are fields of the settings object, storing will work just fine (it's noSQL mongo db). Just do not forget to add a field in the mongoose object appsettings.jsappSettings.telegram_enabled
(as you said :) )Feel free to reach out again, anytime!
Cheers
@BernhardSchlegel any idea if updating the request package to v2.88.2 will break something?
@BernhardSchlegel any idea if updating the request package to v2.88.2 will break something?
There is a fair chance that it will work since the major version stays the same. Give it a try and let me know. I'm happy to help with debugging if something goes sideways...
Okay, I added the required settings to the front end, created the model and set default settings. I am not sure how to get the settings from the data base in telegram.js. I wanted the Telegram implementation in its own file even though it isn't much code. Since all settings are already available in server.js would it make more sense to implement Telegram there than in its own file? Could you have a look?
Sure, I'm happy to! Putting it in a separate file is cleaner way to go - even if it's just a few lines.
How I would do it:
require
) the Settings object (e.g. as done in pd.js) into telegram.js.bot
below the imports, make it a module wide available var
(not a const
). Delete variable token
and chatId
- these should be part of your settings object.init
In telegram.js. This will init the bot (bot = new TelegramBot(token, {polling: false});
) using the token from Settings, and set the chatId
. This function should be called on startup after the settings are loaded (e.g. here) and whenever the settings are changed (here).Backup: If importing the Settings module in telegram.js
won't work, you can pass the a settings
object to the telegram::init()
function on every call. In this case, you cannot delete the token
and chatId
variables.
Thanks for the hints and the idea with the init function @BernhardSchlegel. That was really helpful. I managed to access the settings in telegram.js but after implementing the init method, I decided to just go with your backup plan. Wherever the init method is called, the settings are "right there", so why not just pass them as arguments?
I believe I am done with this enhancement then. Check it out.
I'll have a look at the weekend !
So, I brewed my first beer with BierBot yesterday and the Telegram messages came in really handy. Since currently messages are only sent when BierBot enters a manual step I added a few more manual steps to my recipe just to go the reminders. I now think it’d be better if BierBot sent messages on every step transition. What do you think?
Hi Jonathan! I think that's a great idea. Can you open a new PR for this (I merged this one as of today)? Also, as I tested the telegram integration today I noticed two things: 1st: it worked pretty great out of the box 2nd: The option to provide multiple chat ids would come in super handy (we are a group of 4 hobby brewers). A simple way to implement it would be to allow CSV in the SettingsPage (chatID1,chatID2
) and then do a simple settingsObject.chatID.split(',')
to iterate over all chat ids (nice side effect of split is, that if there is no ,
at all in the string, it returns (still) an array of size 1). Let me know what you think!
I’ll look into it. In the meantime you could also create a Telegram group between the four of you (and IDBot) and provide the group‘s chat ID.
Am 23.01.2021 um 16:35 schrieb Bernhard Schlegel notifications@github.com:
Hi Jonathan! I think that's a great idea. Can you open a new PR for this (I merged this one as of today)? Also, as I tested the telegram integration today I noticed two things: 1st: it worked pretty great out of the box 2nd: The option to provide multiple chat ids would come in super handy (we are a group of 4 hobby brewers). A simple way to implement it would be to allow CSV in the SettingsPage (chatID1,chatID2) and then do a simple settingsObject.chatID.split(',') to iterate over all chat ids (nice side effect of split is, that if there is no , at all in the string, it returns (still) an array of size 1). Let me know what you think!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Plus the bot you created of course!
Am 23.01.2021 um 17:00 schrieb Jonathan Schneider jonathan.schneider@gmx.de:
I’ll look into it. In the meantime you could also create a Telegram group between the four of you (and IDBot) and provide the group‘s chat ID.
Am 23.01.2021 um 16:35 schrieb Bernhard Schlegel notifications@github.com:
Hi Jonathan! I think that's a great idea. Can you open a new PR for this (I merged this one as of today)? Also, as I tested the telegram integration today I noticed two things: 1st: it worked pretty great out of the box 2nd: The option to provide multiple chat ids would come in super handy (we are a group of 4 hobby brewers). A simple way to implement it would be to allow CSV in the SettingsPage (chatID1,chatID2) and then do a simple settingsObject.chatID.split(',') to iterate over all chat ids (nice side effect of split is, that if there is no , at all in the string, it returns (still) an array of size 1). Let me know what you think!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
ahhh ! Didn't know that, my feature request does not make soo much sense than after all
I don’t know. With your suggestion you could just change the chat IDs for the brewers present on that day without having to edit the Telegram group. Since it has no disadvantage for single chat IDs, why not? I’ll look into it.
Am 23.01.2021 um 17:08 schrieb Bernhard Schlegel notifications@github.com:
ahhh ! Didn't know that, my feature request does not make soo much sense than after all
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
I appreciate that!
So I was wondering how BierBot could let a user know that the brew is finished or user action is required when the user isn't within hearing distance. I thought a Telegram bot might be a great idea so I started implementing it.
What I've done so far:
If you're interested, this is still missing because I haven't quite figured out completely how everything plays together:
Since this is not yet function you might not want to merge it into your master branch. If you're interested and want to create a develop branch I will create another pull request.