forked from oldramen/hashtag-amy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
93 lines (78 loc) · 2.89 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
/*
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");
if (mWaiter) require("./menu.js");
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.mJustRemovedDJ = [];
global.mReservedSpots = []; /// [{timestarted, userid}];
global.mQueueCurrentlyOn = false;
global.mSongLimitCurrentlyOn = false;
global.mAFKLimitCurrentlyOn = false;
global.mCurrentSongLimit = mMaxSongs;
global.mUsingLonelyDJ = false;
global.mNoGo = null;
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");