Compare commits
No commits in common. "9c1966f600fe769fe3ce42f38288b0e99649c845" and "157ae8bfcc052b6ed30920053551de39be0a1373" have entirely different histories.
9c1966f600
...
157ae8bfcc
|
@ -985,8 +985,7 @@
|
||||||
"file": "174f.png",
|
"file": "174f.png",
|
||||||
"code": 760,
|
"code": 760,
|
||||||
"alpha2": "SY",
|
"alpha2": "SY",
|
||||||
"name": "Syria",
|
"name": "Syrian Arab Republic"
|
||||||
"fullName": "Syrian Arab Republic"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "715f.png",
|
"file": "715f.png",
|
||||||
|
|
|
@ -2,25 +2,9 @@
|
||||||
|
|
||||||
const fs = require('fs').promises;
|
const fs = require('fs').promises;
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
// const bhttp = require('bhttp');
|
|
||||||
|
|
||||||
const countries = require('./countries.json');
|
const countries = require('./countries.json');
|
||||||
|
|
||||||
/*
|
|
||||||
async function fetchCountries() {
|
|
||||||
const res = await bhttp.get('http://localhost:3000/api/countries');
|
|
||||||
|
|
||||||
if (res.statusCode === 200) {
|
|
||||||
await fs.writeFile('./assets/countries.json', JSON.stringify(res.body, null, 4));
|
|
||||||
console.log('Done fetching countries!');
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Failed to fetch countries: ${res.statusCode}`);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
const countryImgs = await fs.readdir('./assets/countries');
|
const countryImgs = await fs.readdir('./assets/countries');
|
||||||
const countriesByCode = Object.fromEntries(countries.map((country) => [country.alpha2, country]));
|
const countriesByCode = Object.fromEntries(countries.map((country) => [country.alpha2, country]));
|
||||||
|
@ -44,4 +28,3 @@ async function init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
// fetchCountries();
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.20.3",
|
"version": "1.20.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.20.3",
|
"version": "1.20.2",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bhttp": "^1.2.8",
|
"bhttp": "^1.2.8",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "schat2-clive",
|
"name": "schat2-clive",
|
||||||
"version": "1.20.3",
|
"version": "1.20.2",
|
||||||
"description": "Game host for SChat 2-powered chat sites",
|
"description": "Game host for SChat 2-powered chat sites",
|
||||||
"main": "src/app.js",
|
"main": "src/app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -19,12 +19,20 @@ const questions = [
|
||||||
|
|
||||||
function hint(game, context) {
|
function hint(game, context) {
|
||||||
if (game.name.length >= 5) {
|
if (game.name.length >= 5) {
|
||||||
context.sendMessage(`${style.bold(`${game.name.slice(0, 1)} ${game.name.slice(1, -1).replace(/\s/g, ' ').replace(/[^\s]/g, '_ ')}${game.name.slice(-1)}`.toUpperCase())}, the country code s ${style.bold(game.alpha2)}`, context.room.id); // eslint-disable-line no-irregular-whitespace
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.sendMessage(`${style.bold(`${game.name.slice(0, 1)} ${game.name.slice(1).replace(/\s/g, ' ').replace(/[^\s]/g, '_ ').trim()}`.toUpperCase())}, the country code is ${style.bold(game.alpha2)}`, context.room.id); // eslint-disable-line no-irregular-whitespace
|
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 play(context) {
|
function play(context) {
|
||||||
|
@ -34,7 +42,7 @@ function play(context) {
|
||||||
games.set(context.room.id, {
|
games.set(context.room.id, {
|
||||||
...country,
|
...country,
|
||||||
url,
|
url,
|
||||||
regexp: new RegExp(country.fullName ? `(${country.name})|(${country.fullName})` : country.name, 'i'),
|
regexp: new RegExp(country.name, 'i'),
|
||||||
});
|
});
|
||||||
|
|
||||||
context.sendMessage(`${url} ${pickRandom(questions)}`, context.room.id);
|
context.sendMessage(`${url} ${pickRandom(questions)}`, context.room.id);
|
||||||
|
@ -51,7 +59,7 @@ async function onCommand(args, context) {
|
||||||
const game = games.get(context.room.id);
|
const game = games.get(context.room.id);
|
||||||
|
|
||||||
games.delete(context.room.id);
|
games.delete(context.room.id);
|
||||||
context.sendMessage(`Geo was skipped by ${context.user.prefixedUsername}. The country was ${style.bold(game.fullName ? `${game.fullName} (${game.name})` : game.name)}.`, context.room.id);
|
context.sendMessage(`Geo was skipped by ${context.user.prefixedUsername}. The country was ${style.bold(game.name)}.`, context.room.id);
|
||||||
|
|
||||||
await timers.setTimeout(2000);
|
await timers.setTimeout(2000);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +87,7 @@ async function onMessage(message, context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game.regexp.test(message.body)) {
|
if (game.regexp.test(message.body)) {
|
||||||
context.sendMessage(`${style.answer(game.fullName || game.name)} is the right answer! ${style.username(context.user.prefixedUsername)} gets a point.`, context.room.id);
|
context.sendMessage(`${style.answer(game.name)} is the right answer! ${style.username(context.user.prefixedUsername)} gets a point.`, context.room.id);
|
||||||
context.setPoints(context.user);
|
context.setPoints(context.user);
|
||||||
|
|
||||||
games.delete(context.room.id);
|
games.delete(context.room.id);
|
||||||
|
|
Loading…
Reference in New Issue