Skip to content

Commit

Permalink
Merge pull request #72 from harmony-one/image-bot-refactoring
Browse files Browse the repository at this point in the history
more changes
  • Loading branch information
theofandrich authored Aug 10, 2023
2 parents 6ce782c + bf1ee6c commit e9d8bbd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const onMessage = async (ctx: OnMessageContext) => {
if (ctx.session.openAi.imageGen.isEnabled) {
const price = openAiBot.getEstimatedPrice(ctx);
if (price > 0) {
await ctx.reply(`Processing withdraw for ${price.toFixed(2)}¢...`);
//await ctx.reply(`Processing withdraw for ${price.toFixed(2)}¢...`);
}
const isPaid = await payments.pay(ctx, price);
if (isPaid) {
Expand All @@ -129,7 +129,7 @@ const onMessage = async (ctx: OnMessageContext) => {
if (conversationHandler.isValidCommand(ctx)) {
const price = conversationHandler.getEstimatedPrice(ctx);
if (price > 0) {
await ctx.reply(`Processing withdraw for ${price.toFixed(2)}¢...`);
//await ctx.reply(`Processing withdraw for ${price.toFixed(2)}¢...`);
}
const isPaid = await payments.pay(ctx, price);
if (isPaid) {
Expand Down
13 changes: 4 additions & 9 deletions src/modules/conversation-handler/conversationGpt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function conversationGpt(
) {
try {
await ctx.reply(
`_Usign model ${conversation.session.openAi.chatGpt.model}_.\n${appText.gptHelpText}\n`,
`${appText.gptHelpText}\n`,
{
parse_mode: "Markdown",
}
Expand Down Expand Up @@ -92,20 +92,15 @@ export async function conversationGpt(
// maxMilliseconds: 300000 // 5min
// });
const userPrompt = userInput?.msg?.text;
if (
userPrompt.toLocaleLowerCase().includes("end") ||
userPrompt.toLocaleLowerCase().includes("/end")
) {
if (userPrompt === "/end")
{
conversation.session.openAi.chatGpt.chatConversation = [];
await ctx.reply(
`${appText.gptChatEnd} ${usage} (${totalPrice.toFixed(2)}¢)`
);
break;
}
if (
userPrompt.toLocaleLowerCase().includes("help") ||
userPrompt.toLocaleLowerCase().includes("/help")
) {
if (userPrompt === "/help") {
await ctx.reply(`${appText.gptHelpText}`, {
parse_mode: "Markdown",
});
Expand Down
2 changes: 1 addition & 1 deletion src/modules/open-ai/utils/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Adjust image size or how many images are generated`,
chatGptChangeModel: `*🖌️ ChatGPT Help*\nChoose one of the following models`,
generatingText: `Generating response...`,
introText: `You can write your question/prompt for ChatGPT`,
gptHelpText: `Write *end* to finish this conversation.\nWrite *help* to repeat this message.`,
gptHelpText: `Use /end to end the conversation.\n`,
gptChatEnd: "Chat finished. Total tokens used:",
endChat: "Thanks for using 1.country services",
gptChatPaymentIssue: `Once the withdrawal instructions are completed, you can return to the current conversation by writing the */chat* command.\n
Expand Down

0 comments on commit e9d8bbd

Please sign in to comment.