Disabled various small island countries, added hint to Geo.

This commit is contained in:
Niels Simenon
2022-11-02 20:46:47 +01:00
parent 72aed56485
commit 210155305c
228 changed files with 1166 additions and 1243 deletions

View File

@@ -2,33 +2,36 @@
const config = require('config');
const countries = require('../../assets/countries.json');
const countries = require('../../assets/countries-curated.json');
const pickRandom = require('../utils/pick-random');
const style = require('../utils/style');
const games = new Map();
async function onCommand(args, context) {
const game = games.get(context.room.id);
const questions = [
'What\'s this country?',
'Where are we going on holiday?',
];
if (['stop', 'reset'].includes(context.subcommand)) {
if (game) {
games.delete(context.room.id);
context.sendMessage(`Geo was stopped by ${context.user.prefixedUsername}. The country was ${style.bold(game.name)}.`, context.room.id);
return;
}
context.sendMessage(`There is no country in play right now. Start a new round with ${config.prefix}geo!`, context.room.id);
function hint(game, context) {
if (game.name.length >= 5) {
context.sendMessage(`${style.bold(game.name
.split('')
.map((letter, index) => (index === 0 || index === game.name.length - 1 ? letter : '_'))
.join(' ')
.toUpperCase())}, the country code is ${style.bold(game.alpha2)}`, context.room.id);
return;
}
if (game) {
context.sendMessage(game.url, context.room.id);
return;
}
context.sendMessage(`${style.bold(game.name
.split('')
.map((letter, index) => (index === 0 ? letter : '_'))
.join(' ')
.toUpperCase())}, the country code is ${style.bold(game.alpha2)}`, context.room.id);
}
function start(context) {
const country = pickRandom(countries);
const url = `${config.geo.url}${country.file}`;
@@ -38,10 +41,38 @@ async function onCommand(args, context) {
regexp: new RegExp(country.name, 'i'),
});
context.sendMessage(url, context.room.id);
context.sendMessage(`${pickRandom(questions)} ${url}`, context.room.id);
context.logger.info(`Geo played '${country.name}' (${url})`);
}
async function onCommand(args, context) {
const game = games.get(context.room.id);
if (!game && context.subcommand) {
context.sendMessage(`There is no country in play right now. Start a new round with ${config.prefix}geo!`, context.room.id);
return;
}
if (['skip', 'stop', 'reset'].includes(context.subcommand)) {
games.delete(context.room.id);
context.sendMessage(`Geo was skipped by ${context.user.prefixedUsername}. The country was ${style.bold(game.name)}.`, context.room.id);
return;
}
if (context.subcommand === 'hint') {
hint(game, context);
return;
}
if (game) {
context.sendMessage(game.url, context.room.id);
return;
}
start(context);
}
async function onMessage(message, context) {
const game = games.get(context.room.id);