File size: 2,184 Bytes
fa32f5f
6a2b293
 
316322b
fa32f5f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6a2b293
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
const axios = require('axios')
const cheerio = require('cheerio');

const {GptModelOld} = require('./models');

const OpenaiRes = async (prompt) => {
    try {
        const EncodeUrl = "aHR0cHM6Ly9vcGVuYWktZ3B0LnJlbWl4cHJvamVjdC5vcmcv"
        let url;
        try {
           url = atob(EncodeUrl);
        } catch (e) {
            console.error("Could not decode the string! " + e);
        }
        const headers = {
            "Accept": "application/json",
            "Content-Type": "application/json",
            "Accept-Language": "en",
            "Connection": "keep-alive",
            "Origin": "https://remix.ethereum.org",
            "Referer": "https://remix.ethereum.org/",
            "Sec-Fetch-Dest": "empty",
            "Sec-Fetch-Mode": "cors",
            "Sec-Fetch-Site": "cross-site",
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134"
        };
        const response = await axios.post(url, GptModelOld(prompt), { headers, timeout: 50000 });
        if (response.status === 200) {
          return response.data.choices[0].message.content + "\n\nPowered By xtdevs";
        }
    } catch (error) {
        console.error("Error:", error.message);
        return null;
    }
};

async function tebakgambar() {
  try {
    const url = "https://jawabantebakgambar.net/all-answers/";
    const response = await axios.get(url);
    const $ = cheerio.load(response.data);

    const randomNum = Math.floor(Math.random() * (2836 - 2 + 1)) + 2; // Random between 2 and 2836
    const selectedItem = $(`#images > li:nth-child(${randomNum}) > a`);

    if (selectedItem.length > 0) {
      const img = 'https://jawabantebakgambar.net' + selectedItem.find('img').attr('data-src');
      const jwb = selectedItem.find('img').attr('alt');

      const result = {
        message: "By Randydev",
        image: img,
        jawaban: jwb
      };

      return result;
    } else {
      throw new Error("Selected item not found.");
    }
  } catch (error) {
    console.error(error);
    return null;
  }
}

module.exports = {
  OpenaiRes,
  tebakgambar
};