Created
May 18, 2017 04:10
-
-
Save gartnera/913e3bda0acf68d2f0df7f942cbcac84 to your computer and use it in GitHub Desktop.
Delete garbage posts from a facebook messenger conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const login = require("facebook-chat-api"); | |
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, (err, api) => { | |
if(err) return console.error(err); | |
api.setOptions({selfListen: true}); | |
api.listen((err, event) => { | |
if(err) return console.error(err); | |
console.log(event); | |
//only match group chat | |
if (event.type == "message" && event.threadID == '1072921849467619') { | |
let a = event.attachments; | |
if(a.length > 0 ) { | |
if (a[0].type == "animated_image") { | |
api.deleteMessage(event.messageID); | |
} | |
} | |
} | |
if (event.type == "share" && event.threadID == '1072921849467619') { | |
//if from luke | |
if (event.senderID == '100000179506731') | |
api.deleteMessage(event.messageID); | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const login = require("facebook-chat-api"); | |
const readline = require("readline-sync"); | |
var email = readline.question("Enter your email: "); | |
var password = readline.question("Enter your password: ", {hideEchoBack: true}); | |
var credentials = {email: email, password: password}; | |
login(credentials, (err, api) => { | |
if(err) return console.error(err); | |
fs.writeFileSync('appstate.json', JSON.stringify(api.getAppState())); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment