File size: 7,408 Bytes
21bc372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2020-2024 (c) Randy W @xtdevs, @xtsea
#
# from : https://github.com/TeamKillerX
# Channel : @RendyProjects
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import google.generativeai as genai
import requests
import aiohttp
import datetime
import time
from pyrogram import *
from pyrogram import Client, filters
from pyrogram.types import *
from RyuzakiLib import FaceAI, FullStackDev, GeminiLatest, RendyDevChat

from akn.utils.chat import chat_message
from akn.utils.database import db
from akn.utils.handler import *
from akn.utils.logger import LOGS
from akn.utils.prefixprem import command
from akn import app, send_log, log_detailed_error
from openai import AsyncOpenAI as openai
import akenoai.openai as akeno
from config import *

from . import *

async def openailatest(message_str):
    BASE_PROMPT = f"""
    You are my name Akeno AI and python language powered by @xtdevs on telegram support and language models GPT-5-ULTRA
    - off topic free questions
    - language code etc convert to requests python
    - fix spell check in word

    {datetime.datetime.now()}
    """
    
    response = await akeno.OpenAI.run(
        api_key_openai,
        openai_meta=openai,
        model="gpt-4o-mini-2024-07-18",
        messages=[
            {"role": "system", "content": BASE_PROMPT},
            {"role": "user", "content": message_str}
        ]
    )
    return response

async def mistraai(messagestr):
    url = "https://private-akeno.randydev.my.id/akeno/mistralai"
    payload = {"args": messagestr}
    async with aiohttp.ClientSession() as session:
        async with session.post(url, json=payload) as response:
            if response.status != 200:
                return None
            return await response.json()


async def chatgptold(messagestr):
    url = "https://private-akeno.randydev.my.id/ryuzaki/chatgpt-old"
    payload = {"query": messagestr}
    async with aiohttp.ClientSession() as session:
        async with session.post(url, json=payload) as response:
            if response.status != 200:
                return None
            return await response.json()

@Akeno(
    ~filters.scheduled
    & command(["dev"])
    & filters.me
    & ~filters.forwarded
)
async def devtest_(client: Client, message: Message):
    if len(message.command) > 1:
        prompt = message.text.split(maxsplit=1)[1]
    elif message.reply_to_message:
        prompt = message.reply_to_message.text
    else:
        return await message.reply_text("Example: .dev not working ytv or request add module")
    await app.send_message(
        "@xtdevs",
        f"Report to Group: `{message.chat.id}` | {message.chat.title}\n"
        f"UserID: `{message.from_user.id}`\n"
        f"FirstName: `{message.from_user.first_name}`\n"
        f"Text Bug: `{prompt}`"
    )
    await message.reply_text("You have sent the bug to the developer. Thank you! Please check back soon.")
    
@Akeno(
    ~filters.scheduled
    & command(["cmai"])
    & filters.user(1191668125)
    & ~filters.me
    & ~filters.forwarded
)
@Akeno(
    ~filters.scheduled
    & command(["mistralai"])
    & filters.me
    & ~filters.forwarded
)
async def mistralai_(client: Client, message: Message):
    if len(message.command) > 1:
        prompt = message.text.split(maxsplit=1)[1]
    elif message.reply_to_message:
        prompt = message.reply_to_message.text
    else:
        return await message.reply_text("Give ask from mistralai")
    try:
        messager = await mistraai(prompt)
        if messager is None:
            return await message.reply_text("No response")
        output = messager["randydev"].get("message")
        if len(output) > 4096:
            with open("chat.txt", "w+", encoding="utf8") as out_file:
                out_file.write(output)
            await message.reply_document(
                document="chat.txt",
                disable_notification=True
            )
            os.remove("chat.txt")
        else:
            await message.reply_text(output)
    except Exception as e:
        await log_detailed_error(e, where=client.me.id, who=message.chat.title)
        await message.reply_text(str(e))

@Akeno(
    ~filters.scheduled
    & command(["caskold"])
    & filters.user(1191668125)
    & ~filters.me
    & ~filters.forwarded
)
@Akeno(
    ~filters.scheduled
    & command(["askold"])
    & filters.me
    & ~filters.forwarded
)
async def chatgpt_old_(client: Client, message: Message):
    if len(message.command) > 1:
        prompt = message.text.split(maxsplit=1)[1]
    elif message.reply_to_message:
        prompt = message.reply_to_message.text
    else:
        return await message.reply_text("Give ask from CHATGPT-3")
    try:
        messager = await chatgptold(prompt)
        if messager is None:
            return await message.reply_text("No response")
        output = messager["randydev"].get("message")
        if len(output) > 4096:
            with open("chat.txt", "w+", encoding="utf8") as out_file:
                out_file.write(output)
            await message.reply_document(
                document="chat.txt",
                disable_notification=True
            )
            os.remove("chat.txt")
        else:
            await message.reply_text(output)
    except Exception as e:
        await log_detailed_error(e, where=client.me.id, who=message.chat.title)
        await message.reply_text(str(e))

@Akeno(
    ~filters.scheduled
    & command(["cask"])
    & filters.user(1191668125)
    & ~filters.me
    & ~filters.forwarded
)
@Akeno(
    ~filters.scheduled
    & command(["ask"])
    & filters.me
    & ~filters.forwarded
)
async def askren(client: Client, message: Message):
    if len(message.command) > 1:
        prompt = message.text.split(maxsplit=1)[1]
    elif message.reply_to_message:
        prompt = message.reply_to_message.text
    else:
        return await message.reply_text("Give ask from GPT-5")
    try:
        response = await openailatest(prompt)
        output = response
        if len(output) > 4096:
            with open("chat.txt", "w+", encoding="utf8") as out_file:
                out_file.write(output)
            await message.reply_document(
                document="chat.txt",
                disable_notification=True
            )
            os.remove("chat.txt")
        else:
            await message.reply_text(output)
    except Exception as e:
        await log_detailed_error(e, where=client.me.id, who=message.chat.title)
        await message.reply_text(str(e))

module = modules_help.add_module("chatgpt", __file__)
module.add_command("ask", "to question from chatgpt-4o")
module.add_command("askold", "to question from chatgpt-3")
module.add_command("mistralai", "to question from mistralai")