Make sure we only strip username if it the message contains it

This commit is contained in:
Mahdi Dibaiee
2015-07-05 00:25:07 +04:30
parent 794ef80520
commit ac625708f9
2 changed files with 4 additions and 2 deletions

View File

@ -140,7 +140,9 @@ export default class Bot extends EventEmitter {
update.forEach(res => {
let text = res.message.text;
if (text.startsWith('/')) {
const selfUsername = `@${this.info.username}`;
if (text.startsWith('/') && text.indexOf(selfUsername) > -1) {
// Commands are sent in /command@thisusername format in groups
const regex = new RegExp(`(/.*)@${this.info.username}`);
text = text.replace(regex, '$1');