Commit aa92f9bf authored by Iván Sánchez Ortega's avatar Iván Sánchez Ortega

Try to handle twitter DMs

parent 3d560dba
......@@ -59,6 +59,8 @@ class TwitterAccount extends Account {
this._id = json.screen_name + '@twitter';
this._idStr = json.id_str;
// Hackishly listen to the user's main stream
this._stream = this._tw.stream('user', {
// replies: "all", // Should explicitly listen to the "replies" channel
......@@ -422,8 +424,33 @@ class TwitterAccount extends Account {
})
};
} else if (msg.direct_message) {
let sender = msg.direct_message.sender_screen_name;
if (msg.direct_message.sender_id === this._idStr) {
sender = '→' + msg.direct_message.recipient_screen_name;
}
let str = this._cleanString(msg.direct_message.text, msg.direct_message.entities);
return {
timestamp: Date.parse(msg.created_at),
itemPromise: Promise.resolve({
accountNumber: this._accountNumber,
accountId: this._id,
platform: 'twitter',
sender: sender,
str: str,
// url: 'https://www.twitter.com/' + msg.user.screen_name + '/status/' + msg.id_str,
channel: 'DM',
raw: channel && msg,
media: this._cleanMedia(msg.direct_message),
timestamp: Date.parse(msg.created_at),
})
};
} else {
this._vorpal.log(chalk.red('Received something which is not a tweet'));
this._vorpal.log(chalk.red('Received something which is not a tweet nor a DM'));
return {
timestamp: Date.parse(msg.created_at),
itemPromise: Promise.resolve(msg)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment