-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.php
157 lines (146 loc) · 6.12 KB
/
bot.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
<?php
/*
* This file is a part of the PS13 project.
*
* Copyright (c) 2022-present Valithor Obsidion <valithor@valzargaming.com>
*/
use \PS13\PS13;
use \Discord\Discord;
use \Discord\Helpers\CacheConfig;
use \React\EventLoop\Loop;
use \WyriHaximus\React\Cache\Redis as RedisCache;
use \Clue\React\Redis\Factory as Redis;
use \React\Filesystem\Factory as Filesystem;
use \Monolog\Logger;
use \Monolog\Handler\StreamHandler;
use \Discord\WebSockets\Intents;
use \React\Http\Browser;
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
include getcwd() . '/vendor/autoload.php';
$loop = Loop::get();
$logger = new Logger('PS13');
$logger->pushHandler(new StreamHandler('php://stdout'));
$discord = new Discord([
'loop' => $loop,
'logger' => $logger,
//'cache' => new CacheConfig($interface = new RedisCache((new Redis($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, //Because why not?
'intents' => Intents::getDefaultIntents() | Intents::GUILD_MEMBERS | Intents::MESSAGE_CONTENT,
]);
include 'stats_object.php';
$stats = new Stats();
$stats->init($discord);
$browser = new Browser($loop);
$filesystem = Filesystem::create($loop);
include 'functions.php'; //execInBackground(), portIsAvailable()
include 'variable_functions.php';
include 'verifier_functions.php';
include 'PS13.php';
$options = array(
'loop' => $loop,
'discord' => $discord,
'browser' => $browser,
'filesystem' => $filesystem,
'logger' => $logger,
'stats' => $stats,
//Configurations
'github' => 'https://github.com/VZGCoders/PS13-bot',
'command_symbol' => '!s',
'owner_id' => '116927250145869826', //Valithor
'PS13_guild_id' => '1043390003285344306', //PS13
'verifier_feed_channel_id' => '1043390006150053947', //Channel VZG Verifier webhooks verification messages to
'files' => array(
//Fun
'insults_path' => 'insults.txt',
'ranking_path' => 'ranking.txt',
'status_path' => 'status.txt',
//Defines
'map_defines_path' => 'C:/GitHub/Dwarf-Fortress-13/PS13-git/code/__defines/maps.dm',
//PS13
'log_basedir' => 'C:/GitHub/Dwarf-Fortress-13/data/logs',
'ooc_path' => 'C:/GitHub/Dwarf-Fortress-13/ooc.log',
'admin_path' => 'C:/GitHub/Dwarf-Fortress-13/admin.log',
'discord2ooc' => 'C:/GitHub/Dwarf-Fortress-13/SQL/discord2ooc.txt',
'discord2admin' => 'C:/GitHub/Dwarf-Fortress-13/SQL/discord2admin.txt',
'discord2dm' => 'C:/GitHub/Dwarf-Fortress-13/SQL/discord2dm.txt',
'discord2ban' => 'C:/GitHub/Dwarf-Fortress-13/SQL/discord2ban.txt',
'discord2unban' => 'C:/GitHub/Dwarf-Fortress-13/SQL/discord2unban.txt',
'whitelist' => 'C:/GitHub/Dwarf-Fortress-13/SQL/whitelist.txt',
'bans' => 'C:/GitHub/Dwarf-Fortress-13/SQL/bans.txt',
//Script paths
'updateserverabspaths' => 'C:/GitHub/Dwarf-Fortress-13/scripts/updateserverabspaths.py',
'serverdata' => 'C:/GitHub/Dwarf-Fortress-13/serverdata.txt',
'dmb' => 'C:/GitHub/Dwarf-Fortress-13/PS13.dmb',
'killsudos' => 'C:/GitHub/Dwarf-Fortress-13/scripts/killsudos.py',
'killPS13' => 'C:/GitHub/Dwarf-Fortress-13/scripts/killPS13.py',
'mapswap' => 'C:/GitHub/Dwarf-Fortress-13/scripts/mapswap.py',
//Unused
'playerlogs' => 'C:/GitHub/Dwarf-Fortress-13/SQL/playerlogs.txt',
),
'channel_ids' => array(
'ooc_channel' => '1046226008010936360', //#ooc
'ahelp_channel' => '1046226107638231120', //#ahelp
'asay_channel' => '1046272438612283452', //#asay
'ic_channel' => '1046273289540096070', //#ic-emote
'admin-log_channel' => '1046273316756918402', //#admin-log
'runtime_channel' => '1046308005685248050', #runtime
'login-logout_channel' => '1046353236891803708', #login-logout_channel
'staff-bot' => '712685552155230278', //#staff-bot
'webserver-status' => '1116781510180208682', #webserver-status
'playercount' => '1048755726719389716', //#players-#
),
'role_ids' => array(
'thane' => '1043390003381817362', //Host
'rune king' => '1043390003381817359', //Head admin
'longbeard' => '1043390003381817354', //Admin
'bearded' => '1043390003327291395', //Promoted
'unbearded' => '1043390003327291394', //Verified
'banished' => '1043390003327291397', //Banned in-game (unused)
'paroled' => '1043390003360837729', //On parole (unused)
'respawn_notice' => '1046241083685884066',
),
'functions' => array(
'ready' => [
//'on_ready' => $on_ready,
'status_changer_timer' => $status_changer_timer,
'status_changer_random' => $status_changer_random,
//'set_ips' => $set_ips,
'ps13_listeners' => $ps13_listeners,
//'serverinfo_timer' => $serverinfo_timer,
],
'ready_slash' => [
'slash_init' => $slash_init,
],
'message' => [
'on_message' => $on_message,
],
'GUILD_MEMBER_ADD' => [
//
],
'misc' => [ //Custom functions
'status_changer' => $status_changer,
'ban' => $ban,
'browser_call' => $browser_call,
'bancheck' => $bancheck,
'verify_new' => $verify_new,
'promotable_check' => $promotable_check,
'mass_promotion_loop' => $mass_promotion_loop,
'mass_promotion_check' => $mass_promotion_check,
'serverinfo_parse' => $serverinfo_parse,
],
),
);
if (include 'ps13_token.php') $options['ps13_token'] = $ps13_token;
$PS13 = new PS13($options);
include 'webapi.php'; //$socket, $webapi, webapiFail(), webapiSnow();
$PS13->run();