|
@@ -6,69 +6,10 @@ import db from './database.js';
|
|
|
import {init as init_discord_interactions} from './discord_interactions.js';
|
|
|
import {init as init_discord_updates} from './discord_updates.js';
|
|
|
import {listen as website_listen} from './website.js';
|
|
|
-import {init_lobby} from './ranked.js';
|
|
|
import Config from './util/config.js';
|
|
|
import {capture_sentry_exception} from './util/helpers.js';
|
|
|
import {update_division_tresholds} from './elo_cache.js';
|
|
|
-
|
|
|
-
|
|
|
-async function rejoin_lobbies() {
|
|
|
- const rejoin_lobby = async (match) => {
|
|
|
- console.info(`Rejoining lobby #${match.match_id}`);
|
|
|
-
|
|
|
- try {
|
|
|
- const bancho_lobby = await bancho.join('#mp_' + match.match_id);
|
|
|
- await init_lobby(bancho_lobby, JSON.parse(match.data), false);
|
|
|
- } catch (err) {
|
|
|
- console.error(`Failed to rejoin lobby #${match.match_id}: ${err}`);
|
|
|
- db.prepare(`UPDATE match SET end_time = ? WHERE match_id = ?`).run(Date.now(), match.match_id);
|
|
|
-
|
|
|
- console.info(`Recreating lobby #${match.match_id}`);
|
|
|
- try {
|
|
|
- const new_lobby = await bancho.make('New o!RL lobby');
|
|
|
- await init_lobby(new_lobby, JSON.parse(match.data), true);
|
|
|
- } catch (err) {
|
|
|
- console.error(`Failed to recreate lobby #${match.match_id}: ${err}`);
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- const lobbies = db.prepare(`SELECT * FROM match WHERE end_time IS NULL`).all();
|
|
|
- if (lobbies.length == 0 && Config.IS_PRODUCTION) {
|
|
|
- try {
|
|
|
- console.info('Creating default lobby...');
|
|
|
- const lobby = await bancho.make('JOIN NOW | o!RL Auto map select');
|
|
|
- await init_lobby(
|
|
|
- lobby,
|
|
|
- {
|
|
|
- creator: 'botkiwec',
|
|
|
- creator_id: 29343500,
|
|
|
- ruleset: 0,
|
|
|
- title: '$avg_stars* | o!RL Auto map select (!info)',
|
|
|
- map_selection_algo: 'pp',
|
|
|
- map_pool: 'leaderboarded',
|
|
|
- mods: 0,
|
|
|
- mod_list: [],
|
|
|
- freemod: true,
|
|
|
- min_stars: 0,
|
|
|
- max_stars: 11,
|
|
|
- filter_query: '1 AND length > 60 AND length < 500 AND ar > 8.9 AND ar < 11',
|
|
|
- nb_non_repeating: 100,
|
|
|
- pp_closeness: 50,
|
|
|
- },
|
|
|
- true,
|
|
|
- );
|
|
|
- } catch (err) {
|
|
|
- console.error('Failed to create default lobby:', err.message);
|
|
|
- }
|
|
|
- } else {
|
|
|
- const promises = [];
|
|
|
- for (const lobby of lobbies) {
|
|
|
- promises.push(rejoin_lobby(lobby));
|
|
|
- }
|
|
|
- await Promise.all(promises);
|
|
|
- }
|
|
|
-}
|
|
|
+import {auto_rejoin_lobbies} from './supervisor.js';
|
|
|
|
|
|
|
|
|
async function init_discord() {
|
|
@@ -123,7 +64,7 @@ async function main() {
|
|
|
process.exit();
|
|
|
});
|
|
|
await bancho.connect();
|
|
|
- await rejoin_lobbies();
|
|
|
+ await auto_rejoin_lobbies();
|
|
|
}
|
|
|
|
|
|
console.log('All ready and fired up!');
|