This repository has been archived by the owner on Feb 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mariah.js
79 lines (60 loc) · 2.24 KB
/
mariah.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
console.log("I don't want a lot for Christmas...");
//checking if it's in develop mode for local use
if (process.env.NODE_ENV === "develop") {
require("dotenv").config();
};
// using Node Schedule from https://github.com/node-schedule/node-schedule suggested by Brendan O'leary https://twitter.com/olearycrew
const schedule = require("node-schedule");
const rule = new schedule.RecurrenceRule();
rule.dayOfWeek = [1, 2, 3, 4, 5];
rule.hour = 6;
rule.minute = 30;
rule.tz = "Etc/GMT+4";
// Create an Twitter object to connect to Twitter API
const Twit = require('twit');
// Pulling keys from another file
const config = require('./configM.js');
// Making a Twit object for connection to the API
const T = new Twit(config);
// Setting up a user stream
const stream = T.stream('statuses/filter', { track: '@MechanicalCarey' });
// Now looking for tweet events
// See: https://dev.twitter.com/streaming/userstreams
stream.on('tweet', tweetEvent);
// Here a tweet event is triggered!
function tweetEvent(tweet) {
var id = tweet.id_str;
var text = tweet.text;
var name = tweet.user.screen_name;
let regex = /(👀🙄😒)/g;
let str = text;
let fantasy = str.match(regex) || [];
let alwaysBeMyBaby = fantasy.length>0;
console.log(fantasy);
console.log(alwaysBeMyBaby);
//from itsAydrian in twitch chat on 1/28 😘
let i = Math.floor(Math.random() * 3);
// checks text of tweet for mention of Shania Bot
if ((text.includes('@MechanicalCarey') && alwaysBeMyBaby === true)) {
// Start a reply back to the sender
const replyText = "@"+ name + "... I don't know her ¯\\_(ツ)_/¯... ";
// Post that tweet
T.post('statuses/update', { status: replyText, in_reply_to_status_id: id}, tweeted);
// Make sure it worked!
function tweeted(err, reply) {
if (err) {
console.log(err.message);
} else {
console.log('Tweeted: ' + reply.text);
}
}
} else {
console.log("Just a sweet sweet fantasy");
}
};
function AlwaysBeMyBaby()
{
console.log("You can't escape me");
T.post('statuses/update', {status: "Boy don't you know you can't escape me... https://www.youtube.com/watch?v=Dxce3s7bV9s"});
};
const job1 = schedule.scheduleJob(rule, AlwaysBeMyBaby);