Skip to content

Commit

Permalink
fix reply
Browse files Browse the repository at this point in the history
  • Loading branch information
Liryna committed Jun 28, 2015
1 parent 0a652eb commit 1dc20f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions facebookbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "facebookbot",
"version": "0.1.0",
"version": "0.1.1",
"description": "A Facebook bot for Telegram",
"main": "facebookbot",
"author": "Liryna <liryna.stark@gmail.com>",
Expand Down

0 comments on commit 1dc20f9

Please sign in to comment.