-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.php
280 lines (262 loc) · 11.9 KB
/
run.php
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<?php
/*
* This file is a part of the Tutelar project.
*
* Copyright (c) 2022-present Valithor Obsidion <[email protected]>
*/
set_time_limit(0);
ignore_user_abort(1);
ini_set('max_execution_time', 0);
ini_set('memory_limit', '-1'); //Unlimited memory usage
define('MAIN_INCLUDED', 1); //Token and SQL credential files may be protected locally and require this to be defined to access
require getcwd() . '/token.php'; //$token
require getcwd() . '/secret.php'; //twitchphp helix secrets
include getcwd() . '/vendor/autoload.php';
$loop = \React\EventLoop\Loop::get();
$logger = new Monolog\Logger('New logger');
$logger->pushHandler(new Monolog\Handler\StreamHandler('php://stdout'));
$discord = new \Discord\Discord([
'loop' => $loop,
'logger' => $logger,
//'cache' => new \Discord\Helpers\CacheConfig($interface = new WyriHaximus\React\Cache\Redis((new Clue\React\Redis\Factory($loop))->createLazyClient('127.0.0.1:6379'), 'dphp:cache:'), $compress = true, $sweep = false),
/*'socket_options' => [
'dns' => '8.8.8.8', // can change dns
],*/
'token' => $token,
'loadAllMembers' => true,
'storeMessages' => true, //Required for rolepicker and other functions
'intents' => \Discord\WebSockets\Intents::getDefaultIntents() | \Discord\WebSockets\Intents::GUILD_MEMBERS | \Discord\WebSockets\Intents::MESSAGE_CONTENT // default intents as well as guild members
]);
include 'stats_object.php';
$stats = new Stats();
$stats->init($discord);
$browser = new \React\Http\Browser($loop);
include 'functions.php'; //execInBackground()
include 'variable_functions.php';
$nick = 'Valgorithms'; // Twitch username (Case sensitive)
$twitch_options = array(
//Required
'secret' => $secret, // Client secret
'nick' => $nick,
//Optional
'discord' => $discord, // Pass your own instance of DiscordPHP (https://github.com/discord-php/DiscordPHP)
'discord_output' => true, // Output Twitch chat to a Discord server
'loop' => $loop, // (Optional) Pass your own instance of $loop to share with other ReactPHP applications
'socket_options' => [
//'dns' => '8.8.8.8', // Can change DNS provider
],
'verbose' => true, // Additional output to console (useful for debugging)
'debug' => true, // Additional output to console (useful for debugging communications with Twitch)
'logger' => $logger,
//Custom commands
'commandsymbol' => [ // Process commands if a message starts with a prefix in this array
"@$nick", //Users can mention your channel instead of using a command symbol prefix
'!s',
],
'whitelist' => [ // Users who are allowed to use restricted functions
strtolower($nick), //Your channel
'valzargamingcaptures',
'shriekingechodanica',
//'smalltowngamingtv',
//'rattlesire',
//'shrineplays',
//'violentvixen_',
//'linkdrako',
//'ebonychimera',
],
'badwords' => [ // List of blacklisted words or phrases in their entirety; User will be immediately banned with reason 'badword' if spoken in chat
'Buy Followers, primes and viewers',
'bigfollows . com',
'stearncomminuty',
'Get viewers, followers and primes on',
],
'social' => [ //NYI
'twitter' => 'https://twitter.com/valzargaming',
'discord' => 'https://discord.gg/NU4BS5P36g',
'youtube' => 'https://www.youtube.com/valzargaming',
],
'tip' => [ //NYI
'paypal' => 'https://www.paypal.com/paypalme/valithor',
'cashapp' => '$Valithor',
],
'responses' => [ // Whenever a message is sent matching a key and prefixed with a command symbol, reply with the defined value
'ping' => 'Pong!',
'github' => 'https://github.com/VZGCoders/TwitchPHP',
'lurk' => 'You have said the magick word to make yourself invisible to all eyes upon you, allowing you to fade into the shadows.',
'return' => 'You have rolled a Nat 1, clearing your invisibility buff from earlier. You might want to roll for initiative…',
],
'functions' => [ // Enabled functions usable by anyone
'help', // Send a list of commands as a chat message
],
'restricted_functions' => [ // Enabled functions usable only by whitelisted users
'so', //Advertise someone else
'ban', //Ban someone with or without a reason included after the username
],
'private_functions' => [ // Enabled functions usable only by the bot owner sharing the same username as the bot
'php', //Outputs the current version of PHP as a message
'join', //Joins another user's channel
'leave', //Leave the current user's channel
'stop', //Kills the bot
],
/*
`HelixCommandClient => [
$HelixCommandClient, // Optionally pass your own instance of the HelixCommandClient class
],
'helix' => [ // REQUIRES a bot application https://dev.twitch.tv/console/apps
'bot_id' => $bot_id, // Obtained from application
'bot_secret' => $bot_secret, // Obtained from application
'bot_token' => $bot_token, // Obtained from your own server using twitch_oauth.php (see example at https://www.valzargaming.com/twitch_oauth/twitch_oauth_template.html)
'refresh_token' => $refresh_token, // Obtained from your own server using twitch_oauth.php (see example at https://www.valzargaming.com/twitch_oauth/twitch_oauth_template.html)
'expires_in' => $expires_in, // Obtained from your own server using twitch_oauth.php (see example at https://www.valzargaming.com/twitch_oauth/twitch_oauth_template.html)
],
*/
/*
'browser' => new \React\Http\Browser($options['loop']), //Optionally pass your own browser for use by Helix' async commands
*/
);
//Discord servers to relay chat for
//Syntax: $twitch_options['channels']['twitch_channel_name']['discord_guild_id'] = 'discord_channel_id';
//Official ValZarGaming Team
//ValZarGaming
$twitch_options['channels']['valgorithms']['923969098185068594'] = '924019611534503996';
$twitch_options['channels']['valzargamingcaptures']['923969098185068594'] = '924019611534503996';
$twitch_options['channels']['quenya']['923969098185068594'] = '924019611534503996';
$twitch_options['channels']['shriekingechodanica']['923969098185068594'] = '924019611534503996';
$twitch_options['channels']['silentwingsstudio']['923969098185068594'] = '924019611534503996';
//Valgorithms
$twitch_options['channels']['valgorithms']['1077144430588469349'] = '1201002265419456602';
$twitch_options['channels']['valzargamingcaptures']['1077144430588469349'] = '1201002265419456602';
$twitch_options['channels']['quenya']['1077144430588469349'] = '1200997389444599928';
$twitch_options['channels']['shriekingechodanica']['1077144430588469349'] = '1201412793774116965';
$twitch_options['channels']['silentwingsstudio']['1077144430588469349'] = '1077144433096654934';
//Danica's Rat Nest
$twitch_options['channels']['shriekingechodanica']['999053951670423643'] = '1014429625826414642'; // Danica's Rat Nest
// Responses that reference other values in options should be declared afterwards
$twitch_options['responses']['social'] = 'Come follow the magick through several dimensions: Twitter - '.$twitch_options['social']['twitter'].' | Discord - '.$twitch_options['social']['discord'].' | YouTube - '.$twitch_options['social']['youtube'];
$twitch_options['responses']['tip'] = 'Wanna help fund the magick? PayPal - '.$twitch_options['tip']['paypal'];
$twitch_options['responses']['discord'] = $twitch_options['social']['discord'];
//$twitch = new Twitch\Twitch($twitch_options);
include 'db.php'; //$mysqli[$mysqli1, $mysqli2, $mysqli3], //$pdo[$pdo1, $pdo2, $pdo3]
$options = array(
'loop' => $loop,
'discord' => $discord,
//'twitch' => $twitch,
'twitch_options' => $twitch_options,
'browser' => $browser,
'logger' => $logger,
'stats' => $stats,
'mysqli' => $mysqli,
'pdo' => $pdo,
//Filecache
//'filecache_path' = getcwd() . '/json/', // Manually change where cached files get saved to
//'filecache_prefix' = 'tutelar;cache;', // Manually change automatically generated filenames to include this prefix (possibly easier to locate/ignore with other programs)
//Configurations
'command_symbol' => '!s',
'owner_id' => '116927250145869826', //Valithor#5947
'owner_guild_id' => '923969098185068594', //ValZarGaming
'github' => 'https://github.com/VZGCoders/Palace-Revived',
//Configurations
'files' => [
'statuslist' => getcwd() . '\status.txt',
'serverinfo' => 'V:\WinNMP2021\WWW\vzg.project\servers\serverinfo.json'
],
'channel_ids' => [
'923969098185068594' => [
//'nomads_ooc_channel' => '636644156923445269',
],
],
'role_ids' => [
'923969098185068594' => [
//'admiral' => '468980650914086913',
],
],
'functions' => [
'init' => [
'on_init' => $on_init,
'status_changer_random' => $status_changer_random,
'set_ips' => $set_ips,
],
'init_slash' => [
'slash_init' => $slash_init,
],
'message' => [
'on_message' => $on_message,
],
'GUILD_MEMBER_ADD' => [
//
],
'GUILD_MEMBER_REMOVE' => [
//
],
'GUILD_MEMBER_UPDATE' => [
//
],
'GUILD_BAN_ADD' => [
//
],
'GUILD_BAN_REMOVE' => [
//
],
'MESSAGE_UPDATE' => [
//
],
'MESSAGE_DELETE' => [
//
],
'MESSAGE_DELETE_BULK' => [
//
],
'userUpdate' => [
//
],
'misc' => [ //Custom functions
//DiscordPHP
'timeout' => $timeout,
'status_changer' => $status_changer,
'perm_check' => $perm_check,
//ReactPHP Browser
'browser_get' => $browser_get,
'browser_post' => $browser_post,
//Message functions
'debug_direct_message' => $debug_direct_message,
'debug_guild_message' => $debug_guild_message,
'any_called_debug_message' => $any_called_debug_message,
'any_debug_message' => $any_debug_message,
'owner_message' => $owner_message,
'manager_message' => $manager_message,
'admin_message' => $admin_message,
'moderator_message' => $moderator_message,
'direct_message' => $direct_message,
'guild_message' => $guild_message,
'guild_called_message' => $guild_called_message,
'any_called_message' => $any_called_message,
'any_message' => $any_message,
],
],
);
if (include 'log_functions.php') {
echo 'Included log functions' . PHP_EOL;
$options['functions']['message']['log_message'] = $log_message;
$options['functions']['MESSAGE_UPDATE']['log_MESSAGE_UPDATE'] = $log_MESSAGE_UPDATE;
$options['functions']['MESSAGE_DELETE']['log_MESSAGE_DELETE'] = $log_MESSAGE_DELETE;
$options['functions']['GUILD_MEMBER_ADD']['log_GUILD_MEMBER_ADD'] = $log_GUILD_MEMBER_ADD;
$options['functions']['GUILD_MEMBER_REMOVE']['log_GUILD_MEMBER_REMOVE'] = $log_GUILD_MEMBER_REMOVE;
$options['functions']['GUILD_MEMBER_UPDATE']['log_GUILD_MEMBER_UPDATE'] = $log_GUILD_MEMBER_UPDATE;
$options['functions']['GUILD_BAN_ADD']['log_GUILD_BAN_ADD'] = $log_GUILD_BAN_ADD;
$options['functions']['GUILD_BAN_REMOVE']['log_GUILD_BAN_REMOVE'] = $log_GUILD_BAN_REMOVE;
$options['functions']['MESSAGE_DELETE_BULK']['log_MESSAGE_DELETE_BULK'] = $log_MESSAGE_DELETE_BULK;
$options['functions']['userUpdate']['log_userUpdate'] = $log_userUpdate;
}
if (include 'ss13_functions.php') {
echo 'Included ss13 functions' . PHP_EOL;
$options['functions']['init_slash']['ss13_slash_init'] = $ss13_slash_init;
$options['functions']['message']['ss13_on_message'] = $ss13_on_message;
$options['functions']['misc']['discord2ckey'] = $discord2ckey;
}
if (include 'verifier_functions.php') {
echo 'Included verifier functions' . PHP_EOL;
}
include 'tutelar.php';
$tutelar = new Tutelar\Tutelar($options);
if (include 'webapi.php') $tutelar->setWebAPI($webapi); //$socket, $webapi, $external_ip, webapiFail(), webapiSnow()
$tutelar->run();