Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
ptkdev committed Nov 17, 2022
2 parents 029d397 + 79d520e commit fa1ba87
Show file tree
Hide file tree
Showing 11 changed files with 19,644 additions and 19,629 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# v0.7.3 (November 07, 2022)
# v0.7.4 (November 17, 2022)

- Fix: Telegram Topics
- Fix: misprint in the translation
- Fix: unpin if exist question and use `/master`
- Fix: unpin if exist question and master send again a new question
- New: `/master off` to stop bot

<!-- all-shields/sponsors-badges:START -->

[![Donate Paypal](https://img.shields.io/badge/donate-paypal-005EA6.svg?style=for-the-badge&logo=paypal)](https://www.paypal.me/ptkdev) [![Donate Ko-Fi](https://img.shields.io/badge/donate-ko--fi-29abe0.svg?style=for-the-badge&logo=ko-fi)](https://ko-fi.com/ptkdev) [![Donate Github Sponsors](https://img.shields.io/badge/donate-sponsors-ea4aaa.svg?style=for-the-badge&logo=github)](https://github.com/sponsors/ptkdev) [![Donate Patreon](https://img.shields.io/badge/donate-patreon-F87668.svg?style=for-the-badge&logo=patreon)](https://www.patreon.com/join/ptkdev) [![Donate Bitcoin](https://img.shields.io/badge/BTC-35jQmZCy4nsxoMM3QPFrnZePDVhdKaHMRH-E38B29.svg?style=flat-square&logo=bitcoin)](https://ptk.dev/img/icons/menu/bitcoin_wallet.png) [![Donate Ethereum](https://img.shields.io/badge/ETH-0x8b8171661bEb032828e82baBb0B5B98Ba8fBEBFc-4E8EE9.svg?style=flat-square&logo=ethereum)](https://ptk.dev/img/icons/menu/ethereum_wallet.png)

<!-- all-shields/sponsors-badges:END -->

# v0.7.3 (November 07, 2022)

- Fix: Telegram Topics

# v0.7.2 (January 10, 2022)

- Fix: now split with two HASHTAGS (##), not with MINUS sign (-)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- all-shields/header-badges:START -->

[![v0.7.3](https://img.shields.io/badge/version-v0.7.3-lightgray.svg?style=flat&logo=)](https://github.com/ptkdev/quizquickanswer-telegram-game-bot/blob/main/CHANGELOG.md) [![](https://img.shields.io/npm/v/@ptkdev/quizquickanswer-telegram-game-bot?color=CC3534&logo=npm)](https://www.npmjs.com/package/@ptkdev/quizquickanswer-telegram-game-bot) [![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat&logo=license)](https://github.com/ptkdev/quizquickanswer-telegram-game-bot/blob/main/LICENSE.md) [![Language: TypeScript](https://img.shields.io/badge/language-typescript-blue.svg?style=flat&logo=typescript)](https://www.typescriptlang.org/) [![Framework: Grammy](https://img.shields.io/badge/powered%20by-grammy-009dca.svg?style=flat&logo=telegram)](https://grammy.dev/) [![ECMAScript: 2019](https://img.shields.io/badge/ES-9-F7DF1E.svg?style=flat&logo=javascript)](https://github.com/tc39/ecma262) [![Discord Server](https://discordapp.com/api/guilds/383373985666301975/embed.png)](https://discord.ptkdev.io)
[![v0.7.4-beta.1](https://img.shields.io/badge/version-v0.7.4--beta.1-lightgray.svg?style=flat&logo=)](https://github.com/ptkdev/quizquickanswer-telegram-game-bot/blob/main/CHANGELOG.md) [![](https://img.shields.io/npm/v/@ptkdev/quizquickanswer-telegram-game-bot?color=CC3534&logo=npm)](https://www.npmjs.com/package/@ptkdev/quizquickanswer-telegram-game-bot) [![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat&logo=license)](https://github.com/ptkdev/quizquickanswer-telegram-game-bot/blob/main/LICENSE.md) [![Language: TypeScript](https://img.shields.io/badge/language-typescript-blue.svg?style=flat&logo=typescript)](https://www.typescriptlang.org/) [![Framework: Grammy](https://img.shields.io/badge/powered%20by-grammy-009dca.svg?style=flat&logo=telegram)](https://grammy.dev/) [![ECMAScript: 2019](https://img.shields.io/badge/ES-9-F7DF1E.svg?style=flat&logo=javascript)](https://github.com/tc39/ecma262) [![Discord Server](https://discordapp.com/api/guilds/383373985666301975/embed.png)](https://discord.ptkdev.io)

<!-- all-shields/header-badges:END -->

Expand Down
3 changes: 3 additions & 0 deletions app/functions/api/database/scores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const schema = new Schema<MasterInterface>({
group_id: { type: Number, default: 0 },
score_2021: { type: Number, default: 0 },
score_2022: { type: Number, default: 0 },
score_2023: { type: Number, default: 0 },
score_2024: { type: Number, default: 0 },
score_2025: { type: Number, default: 0 },
});

const query = model<MasterInterface>("Scores", schema, "scores");
Expand Down
4 changes: 4 additions & 0 deletions app/functions/commands/hears.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ const hears = async (): Promise<void> => {
translate(lang.language, "hears_missing_tip"),
);
} else {
if (master?.pin_id > 0) {
await telegram.api.message.unpin(ctx, master?.group_id, master?.pin_id);
}

await db.master.update({ username: telegram.api.message.getUsername(ctx) }, json);

const master_in_multi_groups = await db.master.getMultiple({
Expand Down
4 changes: 4 additions & 0 deletions app/functions/commands/hearsphoto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ const hearsPhoto = async (): Promise<void> => {
translate(lang.language, "hears_missing_tip"),
);
} else {
if (master?.pin_id > 0) {
await telegram.api.message.unpin(ctx, master?.group_id, master?.pin_id);
}

await db.master.update({ username: telegram.api.message.getUsername(ctx) }, json);

const master_in_multi_groups = await db.master.getMultiple({
Expand Down
18 changes: 16 additions & 2 deletions app/functions/commands/master.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const master = async (): Promise<void> => {
logger.info("command: /master", "master.ts:master()");
const lang = await telegram.api.message.getLanguage(ctx);

const username = telegram.api.message.getText(ctx).replace("/master ", "").replace("@", "").trim();

if (telegram.api.message.getChatID(ctx) < 0) {
// is group chat
if (
Expand All @@ -38,9 +40,13 @@ const master = async (): Promise<void> => {
telegram.api.message.getChatID(ctx),
translate(lang.language, "master_command_empty"),
);
} else if (username === "off") {
await telegram.api.message.send(
ctx,
telegram.api.message.getChatID(ctx),
translate(lang.language, "master_off"),
);
} else {
const username = telegram.api.message.getText(ctx).replace("/master ", "").replace("@", "").trim();

const json = {
id: "0",
is_bot: false,
Expand All @@ -51,6 +57,9 @@ const master = async (): Promise<void> => {
description: "",
score_2021: 0,
score_2022: 0,
score_2023: 0,
score_2024: 0,
score_2025: 0,
pin_id: 0,
group_id: telegram.api.message.getChatID(ctx),
message_thread_id: telegram.api.message.getThreadID(ctx),
Expand All @@ -59,6 +68,11 @@ const master = async (): Promise<void> => {
const master: MasterInterface = await db.master.get({
group_id: telegram.api.message.getChatID(ctx),
});

if (master?.pin_id > 0) {
await telegram.api.message.unpin(ctx, master?.group_id, master?.pin_id);
}

logger.debug(`master:${JSON.stringify(master)}`);
if (master.group_id < 0) {
await db.master.update({ group_id: telegram.api.message.getChatID(ctx) }, json);
Expand Down
19 changes: 10 additions & 9 deletions app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@
"app_name": "Quiz Quick Answer Bot",
"command_only_group": "You can use this command only in a Telegram group!",
"goodquestion_not_autovote": "⛔️ Sorry man, you can't <b>vote for yourself</b>!",
"haers_not_you_master": "📵 You're not the master at the moment, if it's a mistake you can use: /master @TUO_NICKNAME",
"hears_missing_question": "🤬 Hey buddy! What are you writing? First of all, the WORD(S) to guess, then two HASHTAGS, finally the HINT. If you want to send also a picture, please insert it the caption. All in a single message. Exemple:\n\ng<code>gameboy ## old console '90s</code>\n\ngameboy is the word to guess, then there is the two HASHTAS sign and finally the HINT (old console '90s). Don't be ashamed, try again!",
"hears_missing_tip": "🤬 Hey buddy! You forgot the two HASHTAGS. First of all, the WORD(S) to guess, then two HASHTAGS, finally the HINT. If you want to send also a picture, please insert it the caption. All in a single message. Exemple:\n\ng<code>gameboy ## old console '90s</code>\n\ngameboy is the word to guess, then there is the two HASHTAGS and finally the HINT (old console '90s). Don't be ashamed, try again!",
"hears_missing_caption": "🤬 Hey buddy! You forgot the caption. First of all, the WORD(S) to guess, then two HASHTAGS, finally the HINT. If you want to send also a picture, please insert it the caption. All in a single message. Exemple:\n\ng<code>gameboy ## old console '90s</code>\n\ngameboy is the word to guess, then there is the two HASHTAGS and finally the HINT (old console '90s). Don't be ashamed, try again!",
"hears_missing_photo_caption": "🤬 Hey buddy! You forgot the caption when you inserted the picture. Write down the WORD(S) to guess as caption, then two HASHTAGS and finally the HINT. All in a single message. Exemple:\n\ng<code>gameboy ## old console '90s</code>\n\ngameboy is the word to guess, then there is the two HASHTAGS and finally the HINT (old console '90s). Don't be ashamed, try again!!",
"haers_not_you_master": "📵 You're not the master at the moment, if it's a mistake you can use:\n\n<code>/master @nickname</code>",
"hears_missing_question": "🤬 Hey buddy! What are you writing? First of all, the WORD(S) to guess, then two HASHTAGS, finally the HINT. If you want to send also a picture, please insert it the caption. All in a single message. Exemple:\n\n<code>gameboy ## old console '90s</code>\n\ngameboy is the word to guess, then there is the two HASHTAS sign and finally the HINT (old console '90s). Don't be ashamed, try again!",
"hears_missing_tip": "🤬 Hey buddy! You forgot the two HASHTAGS. First of all, the WORD(S) to guess, then two HASHTAGS, finally the HINT. If you want to send also a picture, please insert it the caption. All in a single message. Exemple:\n\n<code>gameboy ## old console '90s</code>\n\ngameboy is the word to guess, then there is the two HASHTAGS and finally the HINT (old console '90s). Don't be ashamed, try again!",
"hears_missing_caption": "🤬 Hey buddy! You forgot the caption. First of all, the WORD(S) to guess, then two HASHTAGS, finally the HINT. If you want to send also a picture, please insert it the caption. All in a single message. Exemple:\n\n<code>gameboy ## old console '90s</code>\n\ngameboy is the word to guess, then there is the two HASHTAGS and finally the HINT (old console '90s). Don't be ashamed, try again!",
"hears_missing_photo_caption": "🤬 Hey buddy! You forgot the caption when you inserted the picture. Write down the WORD(S) to guess as caption, then two HASHTAGS and finally the HINT. All in a single message. Exemple:\n\n<code>gameboy ## old console '90s</code>\n\ngameboy is the word to guess, then there is the two HASHTAGS and finally the HINT (old console '90s). Don't be ashamed, try again!!",
"hears_win": "🏆 <b>GREAT JOB </b> {{first_name}} (@{{username}}) YOU WIN!!!\n\n✍️ The correct answer was: <b>{{answer}}</b>\n👑 Now you are the new <b>master</b>! ⚽️ Your score is <b>{{score}}</b> 🔥\n\nTo take a quiz, write a private message to @{{bot_username}} (click on the nickname) and follow the instruction.",
"hears_win_but_not_master": "🏆 YOU WIN {{first_name}}!! But you can't be master because you don't have a Telegram username. Please set a username: go to Telegram settings, click on edit and write your @nickname! {{master_first_name}} (@{{master_username}}) is still the master.",
"master_command_empty": "Insert a nickname, for exemple:\n\n<code>/master @ptkdev</code>",
"master_command_success": "Now you are the master @{{username}}! To take a quiz, write a private message to @{{bot_username}} (click on the nickname) and write there the word or the sentence to guess, followed by two HASHTAGS and the hint, for exemple: \n\ng<code>gameboy ## old console '90s</code>",
"master_command_success": "Now you are the master @{{username}}!\n\nTo take a quiz, write a private message to @{{bot_username}} (click on the nickname) and write there the word or the sentence to guess, followed by two HASHTAGS and the hint, for exemple: \n\n<code>gameboy ## old console '90s</code>",
"score_command_show": "<b>{{first_name}}</b> (@{{username}}) your score in this group is <b>{{score}}</b>!",
"score_command_show_with_username": "<b>@{{username}}</b> 's score in this group is <b>{{score}}</b>!",
"start_command_group": "Before starting to play set this bot as an admin of this group. Then make yourself the master by running the command:\n\n<code>/master @{{username}}</code>",
"start_command_private": "Write down the world or the sentence to guess followed by two HASHTAGS and the hint. You can also send a picture and use the same scheme in the caption. All in a single message, for exemple: \n\ng<code>gameboy ## old console '90s</code>\n\ngameboy is the word to guess, then there is the two HASHTAGS and finally the HINT (old console '90s).\n\nChange language on /settings",
"start_command_private": "Write down the world or the sentence to guess followed by two HASHTAGS and the hint. You can also send a picture and use the same scheme in the caption. All in a single message, for exemple: \n\n<code>gameboy ## old console '90s</code>\n\ngameboy is the word to guess, then there is the two HASHTAGS and finally the HINT (old console '90s).\n\nChange language on /settings",
"top10_command_not_available": "Leaderboard not available for this group!",
"top10_command_list": "{{emoji}} <b>{{first_name}}</b> ({{username}}) - <b>{{score}}</b> points\n\n",
"hot_answer": "🔥 <b>{{first_name}}</b> (@{{username}}) - PRETTY CLOSE! You quite guess the answer!\n\n",
"admin_welcome": "Welcome to the admin board. Choose the option:\n\n",
"action_send_messagge_all_groups": "Send a message to all groups",
"action_set_user_score": "Set a user's score",
"admin_set_user_score_info_request": "Insert the username, the score and the id of the user in a single message separated by two HASHTAGS, for exemple:\n\nptkdev - 100 - 5032010\n\n",
"admin_set_user_score_info_request": "Insert the username, the score and the id of the user in a single message separated by two HASHTAGS, for exemple:\n\nptkdev ## 100 ## 5032010\n\n",
"settings_command_options": "⚙️ The available options are:",
"settings_command_switchlanguage": "🌎 Choose the language of the bot",
"settings_command_setlanguage": "🌎 Set language",
Expand All @@ -49,5 +49,6 @@
"ping_command": "🎮 Come and play! ⏱ The game is about to start!",
"show_command": "👨‍💻 The master is: {{first_name}} (@{{username}})\n\n⏱ The quiz is: <b>{{answer}}</b>",
"show_command_noquiz": "👨‍💻 The master is: {{first_name}} (@{{username}})\n\n⏱ The quiz is not avaiable! Hurry up to write it!",
"top10_commands": "The top10 available are: \n\n/top2021\n\n/top2022"
"top10_commands": "The top10 available are: \n\n/top2021\n\n/top2022\n\n/top2023",
"master_off": "🌙🌙🌙 Night mode 🌙🌙🌙\n\nWe play 9:00-12:00 Sunday-Thursday, 9:00-1:00 Friday and Saturday.\n\nSee you tomorrow!"
}
9 changes: 5 additions & 4 deletions app/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"app_name": "Quiz Quick Answer Bot",
"command_only_group": "Puoi usare questo comando solo in un gruppo telegram!",
"goodquestion_not_autovote": "⛔️ Mi dispiace, non puoi <b>votarti da solo</b>!",
"haers_not_you_master": "📵 Non sei tu il master al momento, se è un errore puoi usare: /master @TUO_NICKNAME",
"hears_not_you_master": "📵 Non sei tu il master al momento, se è un errore puoi usare:\n\n<code>/master @TUO_NICKNAME</code>",
"hears_missing_question": "🤬 Devi mettere prima la parola che devono indovinare, due HASHTAG, e poi il suggerimento. Se stai mandando una foto inseriscila nella didascalia. Tutto in un unico messaggio, Esempio:\n\ngameboy ## console anni 90\n\ngameboy è la parola che devono indovinare, dopo i due HASHTAG è il suggerimento che gli dai tu (console anni '90). Riprova!",
"hears_missing_tip": "🤬 Hai dimenticato i due hashtag. Devi mettere prima la parola che devono indovinare, due HASHTAG, e poi il suggerimento. Se stai mandando una foto inseriscila nella didascalia. Tutto in un unico messaggio, Esempio:\n\n<code>gameboy ## console anni '90</code>\n\ngameboy è la parola che devono indovinare, dopo i due HASHTAG è il suggerimento che gli dai tu (console anni '90). Riprova!",
"hears_missing_caption": "🤬 Hai dimenticato la caption. Devi mettere prima la parola che devono indovinare, due HASHTAG, e poi il suggerimento. Tutto in un unico messaggio, Esempio:\n\n<code>gameboy ## console anni '90</code>\n\ngameboy è la parola che devono indovinare, dopo i due HASHTAG è il suggerimento che gli dai tu (console anni '90). Riprova!",
"hears_missing_photo_caption": "🤬 Hai dimenticato la didascalia quando hai inviato la foto. Devi mettere come didascalia prima la parola che devono indovinare, due HASHTAG, e poi il suggerimento. Tutto in un unico messaggio, Esempio:\n\n<code>gameboy ## console anni '90</code>\n\ngameboy è la parola che devono indovinare, dopo i due HASHTAG è il suggerimento che gli dai tu (console anni '90). Riprova!",
"hears_win": "🏆 <b>HAI VINTO</b> {{first_name}} (@{{username}})!!!\n\n✍️ La risposta giusta era: <b>{{answer}}</b>\n👑 Ora sei il nuovo <b>master</b>! ⚽️ Il tuo punteggio é <b>{{score}}</b> 🔥\n\nContatta in privato @{{bot_username}} (clicca sul nickname) e segui le istruzioni.",
"hears_win_but_not_master": "🏆 HAI VINTO {{first_name}}!! Ma non puoi diventare master perchè non hai impostato un username su telegram. Vai nelle impostazioni di telegram, entra su modifica in alto e imposta un @nickname! Il master è rimasto {{master_first_name}} (@{{master_username}}).",
"master_command_empty": "Inserisci un nickname, ad esempio:\n\n<code>/master @ptkdev</code>",
"master_command_success": "Ora sei diventato master @{{username}}! Contatta in privato @{{bot_username}} (clicca sul nickname) e scrivigli la parola o frase che gli altri devono indovinare, a seguire sempre nello stesso messaggio, aggiungi due HASHTAG per dare un suggerimento, esempio: \n\n<code>gameboy ## console anni '90</code>",
"master_command_success": "Ora sei diventato master @{{username}}!\n\nContatta in privato @{{bot_username}} (clicca sul nickname) e scrivigli la parola o frase che gli altri devono indovinare, a seguire sempre nello stesso messaggio, aggiungi due HASHTAG per dare un suggerimento, esempio: \n\n<code>gameboy ## console anni '90</code>",
"score_command_show": "<b>{{first_name}}</b> (@{{username}}) il tuo punteggio in questo gruppo è di <b>{{score}}</b> punti!",
"score_command_show_with_username": "Il punteggio di <b>@{{username}}</b> in questo gruppo è di <b>{{score}}</b> punti!",
"start_command_group": "Prima di iniziare a giocare rendi questo bot amministratore. Successivamente diventa master lanciando il comando:\n\n<code>/master @{{username}}</code>",
Expand All @@ -26,7 +26,7 @@
"admin_welcome": "Benvenuto nel pannello di amministrazione. Scegli una delle seguenti opzioni:\n\n",
"action_send_messagge_all_groups": "Inviare messaggio a tutti i gruppi",
"action_set_user_score": "Assegnare lo score di un utente",
"admin_set_user_score_info_request": "Inserisci l'username, lo score e l'id del gruppo di un utente in un singolo messaggio separato da due HASHTAG Esempio:\n\nptkdev - 100 - 5032010\n\n",
"admin_set_user_score_info_request": "Inserisci l'username, lo score e l'id del gruppo di un utente in un singolo messaggio separato da due HASHTAG Esempio:\n\nptkdev ## 100 ## 5032010\n\n",
"settings_command_options": "⚙️ Le opzioni disponibili sono:",
"settings_command_switchlanguage": "🌎 Seleziona la lingua del bot",
"settings_command_setlanguage": "🌎 Cambia lingua",
Expand All @@ -46,5 +46,6 @@
"ping_command": "🎮 Venite a giocare! ⏱ La partita sta per iniziare!",
"show_command": "👨‍💻 Il master è: {{first_name}} (@{{username}})\n\n⏱ Il quiz è: <b>{{answer}}</b>",
"show_command_noquiz": "👨‍💻 Il master è: {{first_name}} (@{{username}})\n\n⏱ Il quiz non c'è! Daje un po'! Sbrigati a scriverlo!",
"top10_commands": "I top10 disponibili sono: \n\n/top2021\n\n/top2022"
"top10_commands": "Le Top10 disponibili sono: \n\n/top2021\n\n/top2022\n\n/top2023",
"master_off": "🌙🌙🌙 Notte Time 🌙🌙🌙\n\nSi gioca 9:00-00:00 domenica-giovedì, 9:00-01:00 venerdì e sabato.\n\nA domani!"
}
3 changes: 3 additions & 0 deletions app/types/master.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ export interface MasterInterface {
*/
score_2021: number;
score_2022: number;
score_2023: number;
score_2024: number;
score_2025: number;
/**
* Master Interface
* =====================
Expand Down
Loading

0 comments on commit fa1ba87

Please sign in to comment.