-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin_Twitch_Map_Command.as
121 lines (99 loc) · 2.01 KB
/
Plugin_Twitch_Map_Command.as
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
#name "Twitch commands"
#author "Monkeypac"
#category "Twitch"
#include "Settings.as"
#include "TwitchChat.as"
#include "Map.as"
#include "Command.as"
#include "MapKarma.as"
// Void callbacks for twitch
class ChatCallbacks : Twitch::ICallbacks
{
void OnMessage(IRC::Message@ msg)
{
if (Context::Setting_MapKarma) {
MapKarma::OnMessage(msg.m_params[1], msg.m_prefix.m_user);
}
}
void OnUserNotice(IRC::Message@ msg)
{}
}
void InitTwitch() {
print("Connecting to Twitch chat...");
auto callbacks = ChatCallbacks();
if (!Twitch::Connect(callbacks)) {
return;
}
print("Connected to Twitch chat!");
Twitch::Login(
Context::Setting_TwitchToken,
Context::Setting_TwitchNickname,
Context::Setting_TwitchChannel
);
}
// Main functions
void Main()
{
Context::Init();
InitTwitch();
MapKarma::SetToSave(GetCurrentMap());
while (true) {
if (onMap()) {
Twitch::Update();
MapKarma::Update();
}
if (changedMap()) {
onSetCurChallenge(GetCurrentMap());
}
yield();
}
Twitch::Disconnect();
}
void onSetCurChallenge(CGameCtnChallenge@ challenge) {
SetLastMap(challenge);
if (challenge !is null) {
print("New map");
if (Context::Setting_AutoUpdate) {
startnew(Command::Run);
}
if (Context::Setting_MapKarma) {
startnew(MapKarma::SaveAndLoadVotes);
}
} else {
print("Left map");
if (Context::Setting_MapKarma) {
startnew(MapKarma::SaveVotes);
}
}
}
void RenderMenu()
{
Command::renderMenu();
if (Context::Setting_MapKarma) {
MapKarma::renderMenu();
}
}
void RenderInterface()
{
if (Context::Setting_MapKarma) {
MapKarma::renderInterface();
}
}
void Render() {
if (Context::Setting_MapKarma) {
MapKarma::render();
}
}
bool OnMouseButton(bool down, int button, int x, int y)
{
if (Context::Setting_MapKarma) {
MapKarma::onMouseButton(down, button, x, y);
}
return true;
}
void OnMouseMove(int x, int y)
{
if (Context::Setting_MapKarma) {
MapKarma::onMouseMove(x, y);
}
}