Should remove username from /command@username messages in groups
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user