async def _(event): if event.is_group: pass else: return global api_client msg = str(event.text) chat = event.chat is_chat = sql.is_chat(chat.id) if not is_chat: return if msg: if not await check_message(event): return sesh, exp = sql.get_ses(chat.id) query = msg try: if int(exp) < time(): ses = api_client.create_session() ses_id = str(ses.id) expires = str(ses.expires) sql.set_ses(chat.id, ses_id, expires) sesh, exp = sql.get_ses(chat.id) except ValueError: pass try: rep = api_client.think_thought(sesh, query) except Exception: pass async with tbot.action(event.chat_id, 'typing'): await event.reply(rep)
async def _(event): if event.is_group: if not await can_change_info(message=event): return else: return chat = event.chat send = await event.get_sender() user = await tbot.get_entity(send) is_chat = sql.is_chat(chat.id) if not is_chat: await event.reply("AI isn't enabled here in the first place!") return "" sql.rem_chat(chat.id) await event.reply("AI disabled successfully!")
async def _(event): if event.is_group: if not event.sender_id == OWNER_ID: if not await can_change_info(message=event): return else: return chat = event.chat is_chat = sql.is_chat(chat.id) k = ly.is_chat(chat.id) if k: ly.rem_chat(chat.id) if not is_chat: ses_id = 'null' expires = 'null' sql.set_ses(chat.id, ses_id, expires) await event.reply("AI successfully enabled for this chat!") return await event.reply("AI Bot is already enabled for this chat!")
async def _(event): if event.is_group: if not await can_change_info(message=event): return else: return global api_client chat = event.chat send = await event.get_sender() user = await tbot.get_entity(send) is_chat = sql.is_chat(chat.id) k = ly.is_chat(chat.id) if k: ly.rem_chat(chat.id) if not is_chat: ses = api_client.create_session() ses_id = str(ses.id) expires = str(ses.expires) sql.set_ses(chat.id, ses_id, expires) await event.reply("AI successfully enabled for this chat!") return await event.reply("AI is already enabled for this chat!") return ""