Kembali ke katalog plugin
fun
tekateki
Kuis Teka-Teki: pengetahuan umum pilihan ganda
Trivia quiz: general knowledge multiple choice
plugins/fun/tekateki.js
Lokasi file di repo kana-md
2
Perintah termasuk alias
3.0 KB
Ukuran file sumber
4/11/2026
Update terakhir, commit 5d6f23b
Daftar perintah
Ketuk tombol salin untuk menyalin perintah, lalu tempel di chat WhatsApp bot KANA.
.tekateki.tekaCara pakai
.tekateki lalu pilih jawaban lewat tombol atau balas pesan ini dengan hurufnya
Contoh
.tekateki
Kode sumber plugin
Cara pasang: simpan file ini ke folder plugins/fun/ di bot KANA kamu, lalu restart bot. Pemilik source code lain bisa mengambil update plugin terbaru dari halaman ini kapan saja.
import { answerQuiz, bindQuestionMessage, getSession, startQuiz } from '../../src/quiz/engine.js'
import { reportResult } from '../../src/quiz/respond.js'
import { sendButtons } from '../../src/ui/buttons.js'
export const config = {
name: 'tekateki',
alias: ['teka'],
category: 'fun',
description: { id: 'Kuis Teka-Teki: pengetahuan umum pilihan ganda', en: 'Trivia quiz: general knowledge multiple choice' },
usage: '.tekateki lalu pilih jawaban lewat tombol atau balas pesan ini dengan hurufnya',
example: '.tekateki',
cooldown: 5,
}
export const i18n = {
id: {
tekateki: {
title: 'Kuis Teka-Teki',
intro: '❓ KUIS TEKA-TEKI\n\n{question}\n\n{options}\n\nPoin: {points} | Waktu: {seconds} detik. Balas (reply) pesan ini dengan huruf jawabannya, atau pencet tombolnya yaa~ {mood}',
already: 'Ehh, masih ada kuis {type} yang jalan di chat ini. Selesaikan dulu atau pencet tombol menyerah di bawah yaa~',
giveUpBtn: '🏳️ Menyerah (.nyerah)',
footer: 'Kuis KANA',
},
},
en: {
tekateki: {
title: 'Trivia Quiz',
intro: '❓ TRIVIA QUIZ\n\n{question}\n\n{options}\n\nPoints: {points} | Time: {seconds} seconds. Reply to this message with the answer letter, or tap an answer button~ {mood}',
already: 'Eh, a {type} quiz is still running in this chat. Finish it first or tap the give up button below~',
giveUpBtn: '🏳️ Give Up (.nyerah)',
footer: 'KANA Quiz',
},
},
}
const LETTERS = ['A', 'B', 'C', 'D']
export const test = { input: '.tekateki', expect: /teka-teki|kuis/i }
export async function handler(ctx) {
const existing = await getSession(ctx.storage, ctx.chat)
const letterArg = (ctx.text || '').trim().toUpperCase()
if (existing && existing.type === 'tekateki' && /^[A-D]$/.test(letterArg)) {
const result = await answerQuiz(ctx.storage, ctx.chat, ctx.senderDigits, letterArg)
return reportResult(ctx, result)
}
if (existing) {
const body = ctx.t('tekateki.already', { type: existing.type })
return sendButtons(ctx.sock, ctx.chat, {
title: ctx.t('tekateki.title'),
body,
footer: ctx.t('tekateki.footer'),
replies: [{ text: ctx.t('tekateki.giveUpBtn'), id: '.nyerah' }],
textFallback: body,
})
}
const { question } = await startQuiz(ctx.storage, ctx.chat, 'tekateki', {
lang: ctx.lang,
startedBy: ctx.senderDigits,
})
const options = question.options ?? []
const optionsText = options.map((opt, i) => `${LETTERS[i]}. ${opt}`).join('\n')
const body = ctx.t('tekateki.intro', {
question: question.text,
options: optionsText,
points: question.points,
seconds: 120,
mood: ctx.say('senang'),
})
const sentQuestion = await sendButtons(ctx.sock, ctx.chat, {
title: ctx.t('tekateki.title'),
body,
footer: ctx.t('tekateki.footer'),
replies: options.map((opt, i) => ({ text: `${LETTERS[i]}. ${opt}`.slice(0, 60), id: `.tekateki ${LETTERS[i]}` })),
textFallback: body,
})
await bindQuestionMessage(ctx.storage, ctx.chat, sentQuestion?.key?.id)
return sentQuestion
}
