Skip to content

Commit

Permalink
city-symbol: Add achievement counter for no-hint and no-chatgpt-hint
Browse files Browse the repository at this point in the history
  • Loading branch information
hakatashi authored Oct 18, 2024
1 parent 9bf9aa0 commit 036e32f
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions city-symbol/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import 'dotenv/config';

import qs from 'querystring';
import {Mutex} from 'async-mutex';
import {load as cheerioLoad} from 'cheerio';
import {stripIndent} from 'common-tags';
import {sample} from 'lodash';
import {increment} from '../achievements';
import {AteQuiz, typicalMessageTextsGenerator} from '../atequiz';
import { Mutex } from 'async-mutex';
import { load as cheerioLoad } from 'cheerio';
import { stripIndent } from 'common-tags';
import { sample } from 'lodash';
import { increment } from '../achievements';
import { AteQuiz, typicalMessageTextsGenerator } from '../atequiz';
import logger from '../lib/logger';
import openai from '../lib/openai';
import {SlackInterface} from '../lib/slack';
import {Loader} from '../lib/utils';
import {prefectures} from '../room-gacha/prefectures';
import { SlackInterface } from '../lib/slack';
import { Loader } from '../lib/utils';
import { prefectures } from '../room-gacha/prefectures';
import chakuwikiTitles from './chakuwiki-title-map.json';

const chakuwikiTitleMap = new Map(Object.entries(chakuwikiTitles));

const mutex = new Mutex();

const log = logger.child({bot: 'city-symbol'});
const log = logger.child({ bot: 'city-symbol' });

const promptTemplate = stripIndent`
# 指示
Expand Down Expand Up @@ -374,7 +374,7 @@ const getRandomCitySymbol = async (): Promise<City> => {
const citySymbol = sample(citySymbols);
const cityInformation = await getCityInformation(citySymbol);

return {...citySymbol, ...cityInformation};
return { ...citySymbol, ...cityInformation };
};

const getWikimediaImageUrl = (fileName: string) => {
Expand Down Expand Up @@ -463,7 +463,7 @@ class CitySymbolAteQuiz extends AteQuiz {
}

export default (slackClients: SlackInterface) => {
const {eventClient} = slackClients;
const { eventClient } = slackClients;

eventClient.on('message', (message) => {
if (message.channel !== process.env.CHANNEL_SANDBOX) {
Expand Down Expand Up @@ -646,6 +646,12 @@ export default (slackClients: SlackInterface) => {

if (result.state === 'solved') {
await increment(result.correctAnswerer, 'city-symbol-answer');
if (result.hintIndex === 0) {
await increment(result.correctAnswerer, 'city-symbol-answer-no-hint');
}
if (result.hintIndex <= 1) {
await increment(result.correctAnswerer, 'city-symbol-answer-no-chatgpt-hint');
}
}
if (city.cityName === '博多市') {
await increment(result.correctAnswerer, 'city-symbol-answer-hakatashi');
Expand Down

0 comments on commit 036e32f

Please sign in to comment.