Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

round3, updated backs #61

Merged
merged 3 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/modules/1country/pages/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ export const oneCountryMainMenu = new Menu<BotContext>(MenuIds.ONE_COUNTRY_MAIN)
.row()
.url("Go to 1.country", "https://1.country")
.row()
.back("Back to the Main Menu");
.back("⬅️ Back");
64 changes: 64 additions & 0 deletions src/modules/conversation-handler/conversationHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Composer } from "grammy";
import { promptGen } from "../open-ai/controller";
import { BotContext, BotConversation } from "../types";
import { conversations, createConversation } from "@grammyjs/conversations";
import { conversationGpt } from "../open-ai/conversationGpt";
import { conversationDomainName } from "../1country/conversationCountry";

export const conversationHandler = new Composer<BotContext>();

const botConversation = async (
conversation: BotConversation,
ctx: BotContext
) => {
if (ctx.hasCommand("chat")) {
await conversationGpt(conversation, ctx);
} else if (ctx.hasCommand("rent")) {
await conversationDomainName(conversation, ctx);
}
};

conversationHandler.use(conversations());
conversationHandler.use(createConversation(botConversation));

conversationHandler.command("chat", async (ctx) => {
const prompt = ctx.match;
if (!prompt) {
ctx.reply("Error: Missing prompt");
return;
}
if (ctx.session.openAi.chatGpt.isEnabled) {
if (ctx.chat.type !== "private") {
ctx.reply("Generating response...");
const payload = {
conversation: [{ role: "user", content: prompt }],
model: ctx.session.openAi.chatGpt.model,
};
const response = await promptGen(payload);
ctx.reply(response.completion);
} else {
await ctx.conversation.enter("botConversation");
}
} else {
ctx.reply("Bot disabled");
}
});

conversationHandler.command("rent", async (ctx) => {
const prompt = ctx.match;
if (!prompt) {
ctx.reply(`Please add domain name`, {
parse_mode: "Markdown",
disable_web_page_preview: true,
});
return;
}
ctx.reply(
"_Domain names can use a mix of letters and numbers, with no spaces_\nWrite *end* to finish this request",
{
parse_mode: "Markdown",
}
);
ctx.reply("Checking name...");
await ctx.conversation.enter("botConversation");
});
2 changes: 1 addition & 1 deletion src/modules/open-ai/pages/chatPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const chatMainMenu = new Menu<BotContext>(MenuIds.CHAT_GPT_MAIN)
}
})
.row()
.back("Back to the Main Menu");
.back("⬅️ Back");


const chatGPTimageDefaultOptions = new Menu<BotContext>(MenuIds.CHAT_GPT_MODEL)
Expand Down
4 changes: 2 additions & 2 deletions src/modules/open-ai/pages/imagePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const imageGenMainMenu = new Menu<BotContext>(MenuIds.IMAGE_GEN_MAIN)
}
})
.row()
.back("Back to the Main Menu");
.back("⬅️ Back");

const imageDefaultOptions = new Menu<BotContext>(MenuIds.IMAGE_GEN_OPTIONS)
.submenu("Change the image number", MenuIds.IMAGE_GEN_NUMBER)
Expand Down Expand Up @@ -136,7 +136,7 @@ const imageGenSizeOptions = new Menu<BotContext>(MenuIds.IMAGE_GEN_SIZE)
(ctx) => setImageSize("1024x1024", ctx)
)
.row()
.back("Back");
.back("⬅️ Back");

function setImageNumber(n: number, ctx: any) {
ctx.session.openAi.imageGen.numImages = n;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Wallet {
}
}

ctx.reply('Telegram wallet', {
ctx.reply('Harmony ONE Wallet', {
reply_markup: keyboard
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/walletconnect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class WalletConnect {
}
}

ctx.reply("Telegram wallet", {
ctx.reply("WalletConnect", {
reply_markup: keyboard,
});
}
Expand Down