PoetOS / moodle-message_output_telegram

A Telegram message output plugin for Moodle.
6 stars 5 forks source link

Bot token should be configured by admin #1

Closed xow closed 7 years ago

xow commented 7 years ago

To prevent the users from needing to create their own bot whenever they want messages via telegram. It should be set up in admin settings.

mchurchward commented 7 years ago

I believe Telegram is most used as a personal communication tool, rather than an institutional one (like Skype). Is this not the case?

xow commented 7 years ago

Telegram group chats are used for organisations. We use them here at HQ. And we are looking for a way to connect our Moodle up with telegram. Generally it's no effort for an institution to make one bot for everyone to use. Much better than everyone being expected to create their own.

mchurchward commented 7 years ago

Okay. Now I get what you mean. So set it up such that the bot token is set up at the site level. Makes sense. However, I think that the bot token is tied to the individual account that is logged in. So that all telegram notifications for all individuals would then go the admin who set it up. I'll have to look deeper.

mchurchward commented 7 years ago

Looking deeper, I do not believe it is possible to configure one bot for the site. When you configure the bot, it defines the chat that will receive the Moodle messages and notifications. If you set up one for the site, everyone's messages would go to the same chat, violating privacy issues. I'm open to other suggestions though, or corrections if I'm understanding how this works incorrectly.

xow commented 7 years ago

Hmm I didn't know the bot token was per user. That seems like an oversight in telegram's api!

mchurchward commented 7 years ago

I'm going to close this issue as "not doable". From everything I read, a Bot is setup by an individual user, and is tied to that user. A Bot can be part of a group, but then the group is getting everything the bot gets and does. For this purpose, we want a personal channel for a Moodle user to receive their Moodle notifications and messages. Unfortunately, that means each user who wants Telegram integration will have to go through BotFather to set up their bot.

mchurchward commented 7 years ago

I'm going to reopen this. I borrowed someone else's phone number and set up another Telegram account. I was able to use the same Bot token I set up on mine, with the new account's chatid, and the messages only went to the users I configured with the chatid's. So, I will go ahead and allow the code to work with one Bot, configured at the site level. Getting the chatid for each user, remains tricky for the user. But I cannot see another way.

mchurchward commented 7 years ago

I released a new version that allows a site to configure a single bot to be used by everyone. I'm still not sure on the security implications, and there is still no easy way for a user to get their chat id. In fact one of the ways requires that you know the bot token. The other way depends on a bot setup by another user - it works, but feels wrong.

mchurchward commented 7 years ago

Version 3.2.4 solves this issue.