Should only accept commands if the message starts with them
This commit is contained in:
parent
bfa2313f3a
commit
5fd35f89c1
@ -203,6 +203,7 @@ var Bot = (function (_EventEmitter) {
|
||||
if (!ev) {
|
||||
return;
|
||||
}
|
||||
|
||||
ev.listener(res.message);
|
||||
});
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ export default class Bot extends EventEmitter {
|
||||
*/
|
||||
command(cmd, listener) {
|
||||
this._userEvents.push({
|
||||
pattern: new RegExp(`/${cmd}`),
|
||||
pattern: new RegExp(`^/${cmd}`),
|
||||
listener
|
||||
});
|
||||
|
||||
@ -145,6 +145,8 @@ export default class Bot extends EventEmitter {
|
||||
const regex = new RegExp(`@${this.info.username}$`);
|
||||
text = text.replace(regex, '');
|
||||
res.message.text = text;
|
||||
|
||||
console.log(res.message.text);
|
||||
}
|
||||
|
||||
let ev = this._userEvents.find(({pattern}) => pattern.test(text));
|
||||
@ -152,6 +154,7 @@ export default class Bot extends EventEmitter {
|
||||
if (!ev) {
|
||||
return;
|
||||
}
|
||||
|
||||
ev.listener(res.message);
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "telegram-api",
|
||||
"version": "0.4.6",
|
||||
"version": "0.4.61",
|
||||
"description": "Control Telegram bots easily using the new Telegram API",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
Loading…
Reference in New Issue
Block a user