-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.php
More file actions
160 lines (146 loc) · 7.57 KB
/
run.php
File metadata and controls
160 lines (146 loc) · 7.57 KB
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
<?php
/*
* This file is apart of the ValZargaming project.
*
* Copyright (c) 2021 Valithor Obsidion <valzargaming@gmail.com>
*/
ini_set('max_execution_time', 0);
define('MAIN_INCLUDED', 1); //Token and SQL credential files are protected, this must be defined to access
$GLOBALS['debug_echo'] = true; //Both Palace and Slash checks for this to determine whether to echo debug prompts or not
include 'vendor/autoload.php';
include 'ValZarGaming/ValZarGaming.php';
require __DIR__ .'/../secret.php'; //$secret
require __DIR__ . '/../token.php'; //$token
$loop = React\EventLoop\Factory::create();
$streamHandler = new Monolog\Handler\StreamHandler('php://stdout', Monolog\Level::Debug);
$streamHandler->setFormatter(new Monolog\Formatter\LineFormatter(null, null, true, true));
$logger = new Monolog\Logger('Tutelar', [$streamHandler]);
$discord_options = array(
'token' => $token,
'loop' => $loop,
'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),
'cacheSweep' => false, //Don't periodically wipe the in-memory cache in case something happens to Redis
/*'socket_options' => [
'dns' => '8.8.8.8', // can change dns
],*/
'loadAllMembers' => true,
'storeMessages' => true,
'logger' => $logger,
'intents' => Discord\WebSockets\Intents::getDefaultIntents() | Discord\WebSockets\Intents::GUILD_MEMBERS | Discord\WebSockets\Intents::MESSAGE_CONTENT // default intents as well as guild members
);
$discord = new \Discord\Discord($discord_options);
$browser = new \React\Http\Browser($discord->getLoop()/*, $connector*/);
include __DIR__ . '/vendor/vzgcoders/palace/stats_object.php';
$stats = new Stats();
$stats->init($discord);
$nick = 'ValZarGaming'; // Twitch username (Case sensitive)
$twitch_options = array(
//Required
'secret' => $secret, // Client secret
'nick' => $nick,
'channels' => [
strtolower($nick), // Your channel
//'smalltowngamingtv', // (Optional) Additional channels
//'rattlesire',
//'shrineplays',
//'violentvixen_',
//'linkdrako',
//'ebonychimera',
'shriekingechodanica',
],
//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
//'guild_id' => '923969098185068594', //ID of the Discord server
//'channel_id' => '924019611534503996', //ID of the Discord channel to output messages to
'guild_id' => '999053951670423643', //ID of the Discord server
'channel_id' => '1014429625826414642', //ID of the Discord channel to output messages to
'loop' => $loop, // 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)
//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
'!',
';',
],
'whitelist' => [ // Users who are allowed to use restricted functions
strtolower($nick), //Your channel
//'smalltowngamingtv',
//'rattlesire',
//'shrineplays',
//'violentvixen_',
//'linkdrako',
//'ebonychimera',
'shriekingechodanica',
],
'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',
],
'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
],
'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
*/
);
// 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'].' | Instagram - '.$twitch_options['social']['instagram'].' | Discord - '.$twitch_options['social']['discord'].' | Tumblr - '.$twitch_options['social']['tumblr'].' | YouTube - '.$twitch_options['social']['youtube'];
//$twitch_options['responses']['tip'] = 'Wanna help fund the magick? PayPal - '.$twitch_options['tip']['paypal'].' | CashApp - '.$twitch_options['tip']['cashapp'];
//$twitch_options['responses']['discord'] = $twitch_options['social']['discord'];
$twitch = new Twitch\Twitch($twitch_options);
$options = array(
'loop' => $loop,
'browser' => $browser,
'discord' => $discord,
'twitch' => $twitch,
);
$valzargaming = new ValZarGaming\ValZarGaming($options);
$discord->getLoop()->addTimer(86400, function() {
//exit();
});
echo 'cwd: ' . getcwd() . PHP_EOL;
include 'Palace/Palace_include.php'; //Declare Discord event listeners and start the bot
//$valzargaming->run(); //Twitch and Discord start independently inside of Palace_include.php, and for some reason $twitch does not get started with this
?>