Skip to content

Commit

Permalink
Merge pull request #15 from stickymongoose/master
Browse files Browse the repository at this point in the history
Add config for Alert timer, add timestamp to alert title, add dismiss…
  • Loading branch information
eouia committed Jan 8, 2018
2 parents 7ef8e7f + 4e9b94a commit 98bee3b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 15 additions & 3 deletions MMM-TelegramBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

Module.register("MMM-TelegramBot", {
defaults: {
allowedUser: []
allowedUser: [],
alertTimer: "30000"
},
//requiresVersion: "2.1.2", // Required version of MagicMirror

Expand Down Expand Up @@ -152,24 +153,35 @@ Module.register("MMM-TelegramBot", {
description : this.translate("TELBOT_SHUTDOWN"),
callback : 'TELBOT_shutdown',
},
{
command: 'dismissalert',
description : this.translate("TELBOT_DISMISSALERT"),
callback : 'TELBOT_dismissalert',
},
]
defaultCommands.forEach((c) => {
Register.add(c)
})
},

TELBOT_alert: function (command, handler) {
var title = handler.message.from.first_name
var title = moment().format("LT") + " - " + handler.message.from.first_name
var message = handler.args
var alerttime = this.config.alertTimer
var text = this.translate("TELBOT_ALERT_RESULT")
this.sendNotification('SHOW_ALERT', {
timer:30000,
timer:alerttime,
title:title,
message:message
})
handler.reply("TEXT", text, {parse_mode:'Markdown'})
},

TELBOT_dismissalert: function (command, handler) {
this.sendNotification('HIDE_ALERT')
handler.reply("TEXT", text, {parse_mode:'Markdown'})
},

TELBOT_hideall: function(command, handler) {
var text = this.translate("TELBOT_HIDEALL_RESULT")
var lockString = this.name
Expand Down
3 changes: 2 additions & 1 deletion translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
"TELBOT_SHUTDOWN_RESPONSE" : "I will shutdown `MagicMirror` now.",
"TELBOT_HIDDEN" : "hidden",
"TELBOT_SHOWING" : "showing",
"TELBOT_END" : "end"
"TELBOT_END" : "end",
"TELBOT_DISMISSALERT" : "Remove Alert from Mirror"
}

0 comments on commit 98bee3b

Please sign in to comment.