Skip to content

Commit

Permalink
fix(*): fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
brgman committed May 13, 2024
1 parent 705f99f commit d77c4f1
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bot/commands/keyboard/chat_gpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const keyboardChatGPT = async (bot, msg) => {
{ modeGPT: modesChatGPT[i].code },
{ where: { chat_id: chatId } }
).then(async res => {
// TODO: отправить сообщение приветствие
// TODO: если это премиум то нужно менять на нужную модель чата в заголовке
await bot.editMessageText(
`<b>ChatGPT</b> 3.5 – ${t(character(modesChatGPT[i].code)?.name)}\n${t(character(modesChatGPT[i].code)?.welcome)}`,
{
Expand Down
4 changes: 2 additions & 2 deletions bot/commands/keyboard/dalle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const keyboardDalle = async (bot, msg) => {
reply_markup: {
inline_keyboard: [
[{ text: t('keyboard_buy_subscription'), callback_data: `buy_subscription_M_${chatId}` }],
[{ text: t('exit_key'), callback_data: `${COMMAND_GPT}_M_${chatId}` }]
[{ text: t('exit_to_gpt'), callback_data: `${COMMAND_GPT}_M_${chatId}` }]
]
}
}
Expand All @@ -46,7 +46,7 @@ export const keyboardDalle = async (bot, msg) => {

eventEmitter.on(`buy_subscription_M_${chatId}`, async function() {
eventEmitter.removeAllListeners()
return keyboardMyAccount(bot, msg, accountMessage, keyboardDalle)
return keyboardMyAccount(bot, msg, accountMessage, keyboardDalle, null, 'buy')
})

eventEmitter.on(`${COMMAND_GPT}_M_${chatId}`, function() {
Expand Down
30 changes: 21 additions & 9 deletions bot/commands/keyboard/my_account.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { createStartKeyboardForReplyMarkup } from '../../utils/createStartKeyboa

dotenv.config({ path: '../.env' })

export const keyboardMyAccount = async (bot, msg, prevMessageForEdit, prevLevel, changeDescription) => {
export const keyboardMyAccount = async (bot, msg, prevMessageForEdit, prevLevel, changeDescription, setPrices) => {
const t = await ct(msg)
let accountMessage
const { id: chatId } = msg.chat
Expand Down Expand Up @@ -220,14 +220,26 @@ Payok - оплачивайте следующими способами:
}
}).then(res => {
clearTimeout(timeout)
bot.editMessageText(
changeDescription ? changeDescription : t('account', { tokens: numberWithSpaces(tokens), paid_days }),
{
message_id: accountMessage.message_id,
chat_id: chatId,
...firstLevel.options
}
).catch(err => console.log(err))

if (setPrices) {
bot.editMessageText(
buyLevel.message,
{
message_id: accountMessage.message_id,
chat_id: chatId,
...buyLevel.options
}
).catch(err => console.log(err))
} else {
bot.editMessageText(
changeDescription ? changeDescription : t('account', { tokens: numberWithSpaces(tokens), paid_days }),
{
message_id: accountMessage.message_id,
chat_id: chatId,
...firstLevel.options
}
).catch(err => console.log(err))
}
})
}, prevMessageForEdit ? 0 : 1500, accountMessage)
} catch (error) {
Expand Down
1 change: 0 additions & 1 deletion bot/commands/keyboard/quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,5 @@ export const keyboardQuiz = async (bot, msg, isDescription) => {
eventEmitter.emit(callbackQuery.data)
bot.answerCallbackQuery(callbackQuery.id, 'quiz', false)
eventEmitter.removeAllListeners()
// TODO: исправить баг. запуск нескольких игр одновременно
})
}
1 change: 0 additions & 1 deletion bot/commands/modes/chatGPT.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const modeChatGPT = async (bot, msg, qweryOptions) => {
ctx = await JSON.parse(response.dataValues.comment)
})

// TODO: Запоминать контекст беседы пользователя или всегда начинать новый чат
ctx ??= INITIAL_SESSION

console.log('🔺ctx', ctx.messages.length)
Expand Down
2 changes: 1 addition & 1 deletion bot/commands/modes/midjourney.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Midjourney } from 'midjourney'
import { saveAndSendPhoto, saveAndSendPreloaderPhoto } from '../../utils/saveAndSendPhoto.js'
import { loaderOn } from '../../utils/loader.js'
import { REQUEST_TYPES } from '../../constants/index.js'
import { REQUEST_TYPES, TYPE_RESPONSE_MJ } from '../../constants/index.js'
import { upscale } from './midjourney/upscale.js'
import events from 'events'
import { variation } from './midjourney/variation.js'
Expand Down
2 changes: 1 addition & 1 deletion bot/db/models/subscriber.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default (sequelize, DataTypes) => {
},
tokens: {
type: DataTypes.DOUBLE,
defaultValue: 10000,
defaultValue: 20000,
},
paid_days: {
type: DataTypes.DOUBLE,
Expand Down

0 comments on commit d77c4f1

Please sign in to comment.