forked from oldramen/hashtag-amy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
122 lines (104 loc) · 3.6 KB
/
main.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
Copyright 2012 yayramen && Inumedia.
This is the file that brings all the other files together,
and makes them play nicely. :D
*/
console.log(mName+" >>> Loading.");
//Let's require all the files to make the bot work.
global.mFunctions = require("./functions.js");
global.mTTAPI = require("ttapi");
global._ = require("underscore");
global.mMongo = require("mongoskin");
global.mReadLine = require("readline");
global.mUtil = require("util");
global.mCommandsMod = require("./commands.js");
global.ObjectID = require('bson').ObjectID;
if (mWaiter) require("./menu.js");
if (mTwitOn) global.mTwit = require("twit");
if (mUseLastfm) global.mLastfmNode = require("lastfm").LastFmNode;
Log("Initializing");
//Let's set some constant variables.
global.mCurrentSong = {
songName: "",
upVotes: -1,
downVotes: -1,
heartCount: -1
}
global.mUsers = {length: 0};
global.mDJs = [];
global.mCurrentDJ = null; /// Will be a user ( type )
global.mRecentlyLeft = {};
global.mRoomName = "";
global.mRoomShortcut = "";
global.mMaxDJs = 5;
global.mDJDropTime = Date.now();
global.mLoopInterval = null;
global.mParsing = {};
global.mMongoDB = null;
Log("Loading up with the Auth ID: " + mAuthId + " and userid: " + mUserId + " into roomid: " + mRoomId);
global.mBot = new mTTAPI(mAuthId, mUserId, mRoomId);
global.mBooted = false;
global.mIsModerator = false;
global.mBareCommands = mCommands.filter(function(e){ return e.bare == true; });
if(!mBareCommands) mBareCommands = []; else mBareCommands = mBareCommands.map(function(e){ return e.command; });;
global.mPMCommands = mCommands.filter(function(e){ return e.pm == true; });
if(!mPMCommands) mPMCommands = []; else mPMCommands = mPMCommands.map(function(e){ return e.command; });;
global.mQueue = [];
global.mQueueNextUp = null;
global.mQueueWarned = [];
global.mQueueNotified = false;
global.mQueueTimeout = null;
global.mTimeForSpin = false;
global.mLottoClaimed = null;
global.mJustRemovedDJ = [];
global.mReservedSpots = []; /// [{timestarted, userid}];
global.mLottoHolders = [];
global.mQueueCurrentlyOn = false;
global.mSongLimitCurrentlyOn = false;
global.mAFKLimitCurrentlyOn = false;
global.mCurrentSongLimit = mMaxSongs;
global.mUsingLonelyDJ = false;
global.mNoGo = null;
global.mPmOverride = false;
global.mAFKWarn = mAFK * (0.693148);
global.mPushingOutGreeting = [];
global.mSpokenMessages = [];
global.mPMQueue = [];
global.mBootedQueue = [];
global.mSaving = false;
Log("Done");
Log("Hooking events");
//Now we're going to start hooking some events.
mBot.on("registered", OnRegistered);
mBot.on("deregistered", OnDeregistered);
mBot.on("new_moderator", OnNewModerator);
mBot.on("rem_moderator", OnRemModerator);
mBot.on("add_dj", OnAddDJ);
mBot.on("rem_dj", OnRemDJ);
mBot.on("speak", OnSpeak);
mBot.on("pmmed", OnPmmed);
mBot.on("newsong", OnNewSong);
mBot.on("endsong", OnEndSong);
mBot.on("snagged", OnSnagged);
mBot.on("nosong", OnNoSong);
mBot.on("update_votes", OnVote);
Log("Done");
if (mTwitOn && mTwitKey) {
Log("Connecting to Twitter");
global.mTwitter = new mTwit({
consumer_key: mTwitKey
, consumer_secret: mTwitSecret
, access_token: mTwitToken
, access_token_secret: mTwitTokenSecret
});
global.mLastTweeted = null;
Log("Done");
};
if (mUseLastfm) {
Log("Connecting to Lastfm");
global.mLastfm = new mLastfmNode({
api_key: mLastfmKey,
secret: mLastfmSecret
});
Log("Done");
}