예제 #1
0
async def hmm(event):
    test = event.pattern_match.group(1)
    r = (
        '\n    \"consent\": true,\n    \"ip\": \"::1\",\n    \"question\": \"{}\"\n'
    ).format(test)
    k = f"({r})"
    new_string = k.replace("(", "{")
    lol = new_string.replace(")", "}")
    payload = lol
    headers = {
        'content-type': "application/json",
        'x-forwarded-for': "<user's ip>",
        'x-rapidapi-key': "33b8b1a671msh1c579ad878d8881p173811jsn6e5d3337e4fc",
        'x-rapidapi-host': "iamai.p.rapidapi.com"
    }

    response = requests.request("POST", url, data=payload, headers=headers)
    lodu = response.json()
    result = (lodu['message']['text'])
    if "no no" in result:
        pro = "Dattebayo Give me some Ramen!"
        try:
            async with telethn.action(event.chat_id, 'typing'):
                await asyncio.sleep(2)
                await event.reply(pro)
        except CFError as e:
            print(e)
    elif "ann" in result:
        pro = "I am Naruto!"
        try:
            async with telethn.action(event.chat_id, 'typing'):
                await asyncio.sleep(2)
                await event.reply(pro)
        except CFError as e:
            print(e)
    else:
        try:
            async with telethn.action(event.chat_id, 'typing'):
                await asyncio.sleep(2)
                await event.reply(result)
        except CFError as e:
            print(e)
예제 #2
0
async def _(event):
    if event.is_group:
        pass
    else:
        return
    prof = str(event.text)

    if not "Masha" in prof:
        if not "masha" in prof:
            reply_msg = await event.get_reply_message()
            if not reply_msg.sender_id == BOT_ID:
                return
    chat = event.chat
    msg = prof
    is_chat = sql.is_chat(chat.id)
    if not is_chat:
        return
    if msg.startswith("/") or msg.startswith("@"):
        return
    lan = translator.detect(msg)
    if not "en" in lan and not lan == "":
        test = translator.translate(msg, lang_tgt="en")
    else:
        test = msg

    url = "https://iamai.p.rapidapi.com/ask"
    r = (
        '\n    \"consent\": true,\n    \"ip\": \"::1\",\n    \"question\": \"{}\"\n'
    ).format(test)
    k = f"({r})"
    new_string = k.replace("(", "{")
    lol = new_string.replace(")", "}")
    payload = lol
    headers = {
        'content-type': "application/json",
        'x-forwarded-for': "<user's ip>",
        'x-rapidapi-key': "33b8b1a671msh1c579ad878d8881p173811jsn6e5d3337e4fc",
        'x-rapidapi-host': "iamai.p.rapidapi.com"
    }

    response = requests.request("POST", url, data=payload, headers=headers)
    lodu = response.json()
    result = (lodu['message']['text'])
    if "Thergiakis" in result:
        pro = random.choice(string)
        try:
            async with tbot.action(event.chat_id, 'typing'):
                await event.reply(pro)
        except CFError as e:
            print(e)
    elif "Ann" in result:
        pro = "Yeah, My name is Masha"
        try:
            async with tbot.action(event.chat_id, 'typing'):
                await event.reply(pro)
        except CFError as e:
            print(e)
    else:
        if not "en" in lan and not lan == "":
            finale = translator.translate(result, lang_tgt=lan[0])
        else:
            finale = result
        try:
            async with tbot.action(event.chat_id, 'typing'):
                await event.reply(finale)
        except CFError as e:
            await event.reply(lodu)