Should remove username from /command@username messages in groups

This commit is contained in:
Mahdi Dibaiee
2015-07-05 00:05:58 +04:30
parent 5fd35f89c1
commit 794ef80520
3 changed files with 10 additions and 8 deletions

View File

@ -142,16 +142,15 @@ export default class Bot extends EventEmitter {
let text = res.message.text;
if (text.startsWith('/')) {
// Commands are sent in /command@thisusername format in groups
const regex = new RegExp(`@${this.info.username}$`);
text = text.replace(regex, '');
const regex = new RegExp(`(/.*)@${this.info.username}`);
text = text.replace(regex, '$1');
res.message.text = text;
console.log(res.message.text);
}
let ev = this._userEvents.find(({pattern}) => pattern.test(text));
if (!ev) {
this.emit('command-notfound', res.message);
return;
}