EXT‐TelegramBot - bugsounet/MMM-Bugsounet GitHub Wiki
TelegramBot plugin for MMM-Bugsounet
You can remote-control plugins within Telegram
.
The Bot is implemented in this plugin thus you don't need to manage antoher daemon.
Other module developers can add their commands easily.
Ref : https://core.telegram.org/bots#6-botfather
- Open your browser in Desktop PC(or your mirror or your phone, anywhere) and Navigate to https://telegram.me/botfather
- Click
Send Message
button, then your telegram will be opened in your phone or your PC whichTelegram
is already installed on. MeetBotFather
. - Command
/newbot
, give aname
to the bot created, give anusername
.username
should end withbot
. (e.g.MyMagicMirrorBot
ormystupidslave-bot
... ) - After created, you can get API Token. It looks like
110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw
. Remember that. - Read messages from
BotFather
. You can find your bot and change chat room of your Bot. Type anything, but your bot will not react yet.
In your mirror, open terminal and execute below
cd ~/MagicMirror/modules/MMM-Bugsounet
npm run setup:EXT-TelegramBot
- Open
config.js
ofMagicMirror
, add this:
{
module: 'MMM-Bugsounet/EXTs/EXT-TelegramBot',
position: 'top_center',
config: {
telegramAPIKey : '<your Telegram API Token>',
allowedUser : ['<your Telegram username without @>'], // This is NOT the username of bot.
}
},
- restart your
MagicMirror
.
- Back to the chat room with your Bot in Telegram, try
/help
or/commands
. Your bot will react! - Now,try
/mychatid
. This command will show the id of this chat room. Thechat id
looks like12345678
. Remember that. We will use this id for admin.
- Open
config.js
again.
{
module: 'MMM-Bugsounet/EXTs/EXT-TelegramBot',
position: 'top_center',
config: {
telegramAPIKey : '<your Telegram API Token>',
allowedUser : ['<your Telegram username without @>'],
adminChatId : <your admin chat id>,
}
},
- Restart your
MagicMirror
. - You can get welcome message in your admin chat room. Now you can use Bot!
{
module: 'MMM-Bugsounet/EXTs/EXT-TelegramBot',
position: "top_left",
config: {
debug: false,
telegramAPIKey : '<your Telegram API Token>',
allowedUser : ['<your Telegram username without @>'],
adminChatId : <your admin chat id>,
useWelcomeMessage: false,
favourites:["/commands", "/modules", "/hideall", "/showall"],
detailOption: {},
telecast: null, // true or chat_id
telecastLife: 1000 * 60 * 60 * 6,
telecastLimit: 5,
telecastHideOverflow: true,
commandAllowed: {},
useSoundNotification: true,
dateFormat: "DD-MM-YYYY HH:mm:ss",
telecastContainer: 300,
screenshotTool: "grim"
}
},
Option | Description | Type | Defaut |
---|---|---|---|
debug | Display debug logs. | Boolean | false |
useWelcomeMessage | Display Wake-up message | Boolean | true |
favourites | Put your favourite commands to telegram keyboard. They will be loaded by command /favor
|
Array | ["/commands", "/modules", "/hideall", "/showall"] |
detailOption | For Developer/Expert. Set detail options for node-telegram-bot-api constructor
|
Object | {} |
telecast |
null for disallowance.true for activating by only /telecast command."{chatId}" for telecasting whole chats in specific chat room. |
String | null |
telecastLife | ms of lifetime of chat. After this time, chat will be disappeared and cache data also be removed. | Number | 1000 * 60 * 60 * 6 |
telecastLimit | How many chats be displayed. Older chat will be shifted by new one. | Number | 5 |
telecastHideOverflow | on true , when overflowed old chats will be hidden. (defined by CSS) If you have touch/mouse interface, you can scroll hidden area.Telecast might have different look by position of module. on .bar, .middle.center, .third region, telecastLimit:1 would be better.Or modify CSS by yourself. |
Boolean | true |
commandAllowed | Command would be executable by only specific users. Others, even in allowedUser cannot use it. |
Object | {} |
useSoundNotification | Use Official notification sound, on incomming messages | Boolean | true |
dateFormat | Your prefered date format | String | "DD-MM-YYYY HH:mm:ss" |
telecastContainer | Force le with of the telecast container in px. Default: 300, mini: 200, max : 1000 | Number | 300 |
screenshotTool | Set screenshot tool to use for /screenshot commandgrim : This tool is designed for Wayland or LabWc compositor using (default)scrot : This tool is designed for X11 compositor using |
String | "grim" |
In this example:
-
me
andjohn
can execute/telecast
command, butjane
cannot. - only
me
can execute/mychatid
command. The others can't. -
jane
can execute all other commands except/telecast
and/mychatid
. -
"modules":[],
will be ignored. It does not mean "Nobody can use this command.
allowedUser: ["me", "john", "jane"],
commandAllowed: {
"telecast": ["me", "john"],
"mychatid": ["me"],
"modules": [],
}
Try /commands
in your TelegramBot.
Supported commands are dependent on which module you've installed.
Currently default supported commands and modules are below:
Command | Description |
---|---|
help | Show description of commands. |
commands | List of available commands. |
modules | List of current installed modules. |
mychatid | Show chatId of this chat room. |
allowed | List of allowed users. |
allowuser | Allow user temporally. |
hideall | Hide All modules. |
showall | Show All modules. |
hide | Hide a module. |
show | Show a module. |
favor | Load favourite commands as keyboard. |
recent | Load recent used commands as keyboard. |
resetkeyboard | Reset Kyeboard. |
notification | Send custom notification. |
screenshot | Take a screenshot of MagicMirror². |
You can use the result of /commands
for /setcommands
of BotFather
.
- For naming commands, use lower case letters.
- For description, First sentence or line-break should happen in 32 chars.
- send specific chat by command
/telecast
(SeeUse commands
) - telecasting chats from specific chat room(group) to MagicMirror without command. (See
Telecast chats
)
- To enable telecasting chats from room(group) without command, you need 2 things before.
- Your telegramBot needs
privacy:disabled
. You can setup privacy mode of bot with@botfather
. - You should know
chatId
of target chat room and your bot is a member of that group. To getchatId
, use/mychatid
command in that room after inviting bot.
- Your telegramBot needs
- Be careful to use. Bot could obtain private user information (name, profile photo, username and conversations), so you should know what you are doing. Explain to members and get consents before using. All rights and responsibilites are yours.
- All photos and text messages(except reply to bots) from human members will be telecasted.
- To use this feature, set
telecast: {chatId}
.
telecast: "-1111111", // "-1111111" will be chatId of target room.
- Instead, a user can explicitly telecast his message with command
/telecast
.
For example;/telecast Kids! Time to go to bed!
will telecast the message "Kids! Time to go to bed".
telecast: true,
- To send a photo, write caption with command
/telecast
.
telecast: null, // or `false`
If you are using this on *_bar
, *_third
or middle_center
position: telecastLimit:1
would be recommended.
You can override CSS in your css/custom.css