From 1dc20f9ec5e38b14b32d1c178b8479115532e00c Mon Sep 17 00:00:00 2001 From: Liryna Date: Sun, 28 Jun 2015 10:09:29 -0700 Subject: [PATCH] fix reply --- README.md | 2 +- facebookbot.js | 13 +++++++------ package.json | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8e10ed9..46586f4 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ TELEGRAM_USER="Mario" APP_TOKEN="TOKEN" node facebookbot.js - Available commands to send to your bot: ``` /threadList - List the latest conversations you had with your friends. -/cancel - Cancel the current command +/cancel - Cancel the current command. ``` ## Dependencies diff --git a/facebookbot.js b/facebookbot.js index 428fd14..54c999b 100644 --- a/facebookbot.js +++ b/facebookbot.js @@ -4,7 +4,7 @@ var login = require("facebook-chat-api"); if(!process.env.TELEGRAM_USER || !process.env.APP_TOKEN) return console.log("Please define this env variables -- TELEGRAM_USER - APP_TOKEN"); -var owner = {username: process.env.TELEGRAM_USER, chat_id: ''}; +var owner = {username: process.env.TELEGRAM_USER, chat_id: undefined}; var maxThreadNb = 10; function getUsage() { @@ -33,10 +33,12 @@ login("config.json", function(err, api) { token: process.env.APP_TOKEN }).on('message', function (message) { if (message.from.username != owner.username) - bot.sendMessage({chat_id: message.chat.id, text: "You are not my owner! Go away ! - https://github.com/Liryna/FacebookBot"}); + bot.sendMessage({chat_id: message.chat.id, + text: "You are not my owner! Go away ! \n" + + "- https://github.com/Liryna/FacebookBot"}); else { - if (!!owner.chat_id) + if (owner.chat_id == undefined) owner.chat_id = message.chat.id; //save owner chat id - TODO save in config file if (!!message.reply_to_message @@ -125,10 +127,9 @@ login("config.json", function(err, api) { //listen message from FB and forward to telegram api.listen(function callback(err, message) { - console.log(message); - var forwardmsg = message.sender_name + ": " + message.body; - if (!!owner.chat_id) + + if (owner.chat_id) bot.sendMessage({chat_id: owner.chat_id, text: forwardmsg}, function(err, res) { if(err) return console.error(err); diff --git a/package.json b/package.json index 8e821f9..606fd26 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "facebookbot", - "version": "0.1.0", + "version": "0.1.1", "description": "A Facebook bot for Telegram", "main": "facebookbot", "author": "Liryna ",