From 036e32f7da58d857a3174f7d1ab595ff0db0b1fa Mon Sep 17 00:00:00 2001 From: Koki Takahashi Date: Fri, 18 Oct 2024 06:27:32 +0000 Subject: [PATCH] city-symbol: Add achievement counter for no-hint and no-chatgpt-hint --- city-symbol/index.ts | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/city-symbol/index.ts b/city-symbol/index.ts index e4f2d43f..883b3993 100644 --- a/city-symbol/index.ts +++ b/city-symbol/index.ts @@ -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` # 指示 @@ -374,7 +374,7 @@ const getRandomCitySymbol = async (): Promise => { const citySymbol = sample(citySymbols); const cityInformation = await getCityInformation(citySymbol); - return {...citySymbol, ...cityInformation}; + return { ...citySymbol, ...cityInformation }; }; const getWikimediaImageUrl = (fileName: string) => { @@ -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) { @@ -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');