From ac625708f99d2fd893a37e1bb2c0bc6b2c6c1e4d Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Sun, 5 Jul 2015 00:25:07 +0430 Subject: [PATCH] Make sure we only strip username if it the message contains it --- lib/index.js | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index d238c29..fb6146b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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'); diff --git a/package.json b/package.json index b03713f..3036faa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "telegram-api", - "version": "0.4.61", + "version": "0.4.62", "description": "Control Telegram bots easily using the new Telegram API", "main": "index.js", "scripts": {