#include <Wire.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// I2C address for the OLED display
#define OLED_ADDR 0x3C
void Wifi_setup(String ssid, String password) {
// Start the Wi-Fi connection
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
// Wait for the connection to establish
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
// Print the IP address
Serial.println();
Serial.println("WiFi connected.");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
String HTTP_get(String link) {
HTTPClient http;
Serial.print("Connecting to ");
Serial.println(link);
// Your domain name with URL path or IP address with path
http.begin(link);
// Send HTTP GET request
int httpResponseCode = http.GET();
// Check the returning code
if (httpResponseCode >= 200 && httpResponseCode <= 299) {
// Get the request response payload
String payload = http.getString();
Serial.println(httpResponseCode);
http.end(); // Close the HTTP connection
return payload;
} else {
Serial.print("Error on HTTP request: ");
Serial.println(httpResponseCode);
http.end(); // Close the HTTP connection
return ""; // Return an empty string on error
}
}
int Total_wl() {
String links = "https://discord.com/api/webhooks/1214936782345605170/cQhOQtNtxcJuJW_C7lcHj4exEa9VaoOTatl30p_Gs5p5gd7bq_sc2zBpanFlTjBQ2Y9p/messages/1215326447980253224";
String kacor = HTTP_get(links);
if (kacor){
int kabors1 = extract_text(kacor, "<:WL:880251447470596157> : ", "\\n").toInt() * 1;
int kabors2 = extract_text(kacor, "<:DL:880251434380165130> : ", "\\n").toInt() * 100;
int kabors3 = extract_text(kacor, "<:BGL:880251420413161533> : ", "\\n").toInt() * 10000;
return kabors1 + kabors2 + kabors3;
}else{
return 0;
}
}
void Total_player(int &plersss, String &plrs_Txt) {
static int Dump_Plyr = 0; // Make Dump_Plyr static to retain its value across function calls
String linkss = "https://www.growtopiagame.com/detail";
String ppleekk = HTTP_get(linkss);
if(ppleekk.length() > 0) {
int players = extract_text(ppleekk, "online_user\":\"", "\",").toInt();
if ((players - Dump_Plyr) > 10) {
plersss = players - Dump_Plyr;
plrs_Txt = "+" + String(plersss);
} else if ((Dump_Plyr - players) > 10) {
plersss = Dump_Plyr - players;
plrs_Txt = "-" + String(plersss);
}
Dump_Plyr = players; // Update Dump_Plyr after calculations
}else {
plersss = 0;
plrs_Txt = "-0";
}
}
void bot_stat(String &online, String &offline, String &banned) {
String botlink = "https://discord.com/api/webhooks/1214936782345605170/cQhOQtNtxcJuJW_C7lcHj4exEa9VaoOTatl30p_Gs5p5gd7bq_sc2zBpanFlTjBQ2Y9p/messages/1232740058461769838";
String ppleekk = HTTP_get(botlink);
if(ppleekk.length() > 0) {
online = extract_text(ppleekk, "ONLINE : ", "\\n");
offline = extract_text(ppleekk, "OFFLINE : ", "\\n");
banned = extract_text(ppleekk, "BANNED : ", "\\n");
}
}
String extract_text(String Text, String Start_from, String end_text) {
int startIndex = Text.indexOf(Start_from);
if (startIndex == -1) {
return "Not found";
}
startIndex += Start_from.length();
int endIndex = Text.indexOf(end_text, startIndex);
if (endIndex == -1) {
endIndex = Text.length();
}
String result = Text.substring(startIndex, endIndex);
result.trim();
return result;
}
void gt_bot_tab(){
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
//bot status
String online, offline, banned;
bot_stat(online, offline, banned);
String pakol;
int players;
Total_player(players,pakol);
int WL = Total_wl();
//display.drawBitmap(0, 0, epd_bitmap_teslcd1, SCREEN_WIDTH, SCREEN_HEIGHT, SSD1306_WHITE);
display.setCursor(20, 0);
display.println(F("GT BOT MONITOR"));
display.setCursor(0, 15 + 2);
display.println(("WL :" + String(WL)));
display.setCursor(0, 25 + 2);
display.println(("ONLINE :" + online));
display.setCursor(0, 35 + 2);
display.println(("OFFLINE:" + offline));
display.setCursor(0, 45 + 2);
display.println(("BANNED :" + banned));
display.setCursor(0, 55 + 2);
display.println(("PLAYERS:" + String(players) + "(" + pakol + ")"));
display.display();
}
void setup() {
Serial.begin(115200);
Wire.begin();
if(!display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
String Wifi_name = "Wokwi-GUEST";
String Wifi_pw = "";
Wifi_setup(Wifi_name, Wifi_pw);
}
void loop() {
gt_bot_tab();
}