mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 09:44:50 +00:00
Add bard api key
Signed-off-by: Yasir Aris M <github@yasirdev.my.id>
This commit is contained in:
parent
7fe984783b
commit
e8d99b5190
3 changed files with 8 additions and 2 deletions
|
|
@ -12,4 +12,5 @@ SUPPORT_CHAT=YasirPediaChannel
|
||||||
COMMAND_HANDLER=
|
COMMAND_HANDLER=
|
||||||
USER_SESSION=
|
USER_SESSION=
|
||||||
OPENAI_API=
|
OPENAI_API=
|
||||||
|
BARD_API=
|
||||||
CURRENCY_API=
|
CURRENCY_API=
|
||||||
|
|
@ -15,7 +15,7 @@ from pyrogram.types import Message
|
||||||
from misskaty import app
|
from misskaty import app
|
||||||
from misskaty.core import pyro_cooldown
|
from misskaty.core import pyro_cooldown
|
||||||
from misskaty.helper import check_time_gap, fetch, post_to_telegraph, use_chat_lang
|
from misskaty.helper import check_time_gap, fetch, post_to_telegraph, use_chat_lang
|
||||||
from misskaty.vars import COMMAND_HANDLER, OPENAI_API, SUDO
|
from misskaty.vars import BARD_API, COMMAND_HANDLER, OPENAI_API, SUDO
|
||||||
|
|
||||||
openai.api_key = OPENAI_API
|
openai.api_key = OPENAI_API
|
||||||
|
|
||||||
|
|
@ -28,10 +28,12 @@ async def bard_chatbot(_, ctx: Message, strings):
|
||||||
return await ctx.reply_msg(
|
return await ctx.reply_msg(
|
||||||
strings("no_question").format(cmd=ctx.command[0]), quote=True, del_in=5
|
strings("no_question").format(cmd=ctx.command[0]), quote=True, del_in=5
|
||||||
)
|
)
|
||||||
|
if not BARD_API:
|
||||||
|
return await ctx.reply_msg("BARD_API env is mising!!!")
|
||||||
msg = await ctx.reply_msg(strings("find_answers_str"), quote=True)
|
msg = await ctx.reply_msg(strings("find_answers_str"), quote=True)
|
||||||
try:
|
try:
|
||||||
req = await fetch.get(
|
req = await fetch.get(
|
||||||
f"https://yasirapi.eu.org/bard?input={ctx.text.split(maxsplit=1)[1]}"
|
f"https://yasirapi.eu.org/bard?input={ctx.text.split(maxsplit=1)[1]}&key={BARD_API}"
|
||||||
)
|
)
|
||||||
random_choice = random.choice(req.json().get("choices"))
|
random_choice = random.choice(req.json().get("choices"))
|
||||||
await msg.edit_msg(
|
await msg.edit_msg(
|
||||||
|
|
@ -50,6 +52,8 @@ async def openai_chatbot(_, ctx: Message, strings):
|
||||||
return await ctx.reply_msg(
|
return await ctx.reply_msg(
|
||||||
strings("no_question").format(cmd=ctx.command[0]), quote=True, del_in=5
|
strings("no_question").format(cmd=ctx.command[0]), quote=True, del_in=5
|
||||||
)
|
)
|
||||||
|
if not OPENAI_API:
|
||||||
|
return await ctx.reply_msg("OPENAI_API env is mising!!!")
|
||||||
uid = ctx.from_user.id if ctx.from_user else ctx.sender_chat.id
|
uid = ctx.from_user.id if ctx.from_user else ctx.sender_chat.id
|
||||||
is_in_gap, _ = await check_time_gap(uid)
|
is_in_gap, _ = await check_time_gap(uid)
|
||||||
if is_in_gap and (uid not in SUDO):
|
if is_in_gap and (uid not in SUDO):
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ SUDO = list(
|
||||||
SUPPORT_CHAT = environ.get("SUPPORT_CHAT", "YasirPediaChannel")
|
SUPPORT_CHAT = environ.get("SUPPORT_CHAT", "YasirPediaChannel")
|
||||||
AUTO_RESTART = environ.get("AUTO_RESTART", False)
|
AUTO_RESTART = environ.get("AUTO_RESTART", False)
|
||||||
OPENAI_API = environ.get("OPENAI_API")
|
OPENAI_API = environ.get("OPENAI_API")
|
||||||
|
BARD_API = environ.get("BARD_API")
|
||||||
|
|
||||||
## Config For AUtoForwarder
|
## Config For AUtoForwarder
|
||||||
# Forward From Chat ID
|
# Forward From Chat ID
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue