-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9662608
commit 3924092
Showing
5 changed files
with
279 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
if($text == "🎮 PC") { | ||
$selectUser = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `user_id` = $userId"); | ||
if($rowUser = mysqli_fetch_assoc($selectUser)) { | ||
$recordPc = $rowUser["pc"]; | ||
if($recordPc == "❌") { | ||
$updateUser = mysqli_query($mysqli, "UPDATE `halmpwct_game`.`users` SET `pc` = '✔️' WHERE `users`.`user_id` = $userId"); | ||
sendMessage($chatId, "✔️ Release notifications enabled"); | ||
} else { | ||
$updateUser = mysqli_query($mysqli, "UPDATE `halmpwct_game`.`users` SET `pc` = '❌' WHERE `users`.`user_id` = $userId"); | ||
sendMessage($chatId, "❌ Release notifications disabled"); | ||
} | ||
} | ||
} | ||
|
||
if($text == "🎮 XBOX") { | ||
$selectUser = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `user_id` = $userId"); | ||
if($rowUser = mysqli_fetch_assoc($selectUser)) { | ||
$recordPc = $rowUser["xbox"]; | ||
if($recordPc == "❌") { | ||
$updateUser = mysqli_query($mysqli, "UPDATE `halmpwct_game`.`users` SET `xbox` = '✔️' WHERE `users`.`user_id` = $userId"); | ||
sendMessage($chatId, "✔️ Release notifications enabled"); | ||
} else { | ||
$updateUser = mysqli_query($mysqli, "UPDATE `halmpwct_game`.`users` SET `xbox` = '❌' WHERE `users`.`user_id` = $userId"); | ||
sendMessage($chatId, "❌ Release notifications disabled"); | ||
} | ||
} | ||
} | ||
|
||
if($text == "🎮 PS4") { | ||
$selectUser = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `user_id` = $userId"); | ||
if($rowUser = mysqli_fetch_assoc($selectUser)) { | ||
$recordPc = $rowUser["ps4"]; | ||
if($recordPc == "❌") { | ||
$updateUser = mysqli_query($mysqli, "UPDATE `halmpwct_game`.`users` SET `ps4` = '✔️' WHERE `users`.`user_id` = $userId"); | ||
sendMessage($chatId, "✔️ Release notifications enabled"); | ||
} else { | ||
$updateUser = mysqli_query($mysqli, "UPDATE `halmpwct_game`.`users` SET `ps4` = '❌' WHERE `users`.`user_id` = $userId"); | ||
sendMessage($chatId, "❌ Release notifications disabled"); | ||
} | ||
} | ||
} | ||
|
||
if($text == "🎮 SWITCH") { | ||
$selectUser = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `user_id` = $userId"); | ||
if($rowUser = mysqli_fetch_assoc($selectUser)) { | ||
$recordPc = $rowUser["switch"]; | ||
if($recordPc == "❌") { | ||
$updateUser = mysqli_query($mysqli, "UPDATE `halmpwct_game`.`users` SET `switch` = '✔️' WHERE `users`.`user_id` = $userId"); | ||
sendMessage($chatId, "✔️ Release notifications enabled"); | ||
} else { | ||
$updateUser = mysqli_query($mysqli, "UPDATE `halmpwct_game`.`users` SET `switch` = '❌' WHERE `users`.`user_id` = $userId"); | ||
sendMessage($chatId, "❌ Release notifications disabled"); | ||
} | ||
} | ||
} | ||
|
||
if($text == "🎮 ANDROID") { | ||
$selectUser = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `user_id` = $userId"); | ||
if($rowUser = mysqli_fetch_assoc($selectUser)) { | ||
$recordPc = $rowUser["android"]; | ||
if($recordPc == "❌") { | ||
$updateUser = mysqli_query($mysqli, "UPDATE `halmpwct_game`.`users` SET `android` = '✔️' WHERE `users`.`user_id` = $userId"); | ||
sendMessage($chatId, "✔️ Release notifications enabled"); | ||
} else { | ||
$updateUser = mysqli_query($mysqli, "UPDATE `halmpwct_game`.`users` SET `android` = '❌' WHERE `users`.`user_id` = $userId"); | ||
sendMessage($chatId, "❌ Release notifications disabled"); | ||
} | ||
} | ||
} | ||
|
||
if($text == "🎮 IOS") { | ||
$selectUser = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `user_id` = $userId"); | ||
if($rowUser = mysqli_fetch_assoc($selectUser)) { | ||
$recordPc = $rowUser["ios"]; | ||
if($recordPc == "❌") { | ||
$updateUser = mysqli_query($mysqli, "UPDATE `halmpwct_game`.`users` SET `ios` = '✔️' WHERE `users`.`user_id` = $userId"); | ||
sendMessage($chatId, "✔️ Release notifications enabled"); | ||
} else { | ||
$updateUser = mysqli_query($mysqli, "UPDATE `halmpwct_game`.`users` SET `ios` = '❌' WHERE `users`.`user_id` = $userId"); | ||
sendMessage($chatId, "❌ Release notifications disabled"); | ||
} | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
if($text == "/start") { | ||
$selectUser = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `user_id` = $userId"); | ||
if($rowUser = mysqli_fetch_assoc($selectUser)) { | ||
function keyboardStart($chatId, $text) { | ||
$keyboard = '&reply_markup={"keyboard":[["🎮 PC", "🎮 XBOX"],["🎮 PS4", "🎮 SWITCH"],["🎮 ANDROID", "🎮 IOS"]],"resize_keyboard":true}'; | ||
$url = $GLOBALS[website]."/sendMessage?chat_id=$chatId&parse_mode=HTML&text=".urlencode($text).$keyboard; | ||
file_get_contents($url); | ||
} | ||
keyboardStart($chatId, "Hi, welcome to the Game Releases Bot. 🕹\nPlease choose your desidered platform(s) and I will send you a message at 11pm if a new release should be available.\nThe source code is available on <b>GitHub</b>\nEnjoy! 🍿\nhttps://github.com/Crazy-Marvin/GameReleasesTelegramBot."); | ||
} else { | ||
$insert_user = mysqli_query($mysqli, "INSERT INTO `halmpwct_game`.`users` (`user_id`, `pc`, `xbox`, `ps4`, `switch`, `android`, `ios`) VALUES ('$userId', '❌', '❌', '❌', '❌', '❌', '❌')"); | ||
function keyboardStart($chatId, $text) { | ||
$keyboard = '&reply_markup={"keyboard":[["🎮 PC", "🎮 XBOX"],["🎮 PS4", "🎮 SWITCH"],["🎮 ANDROID", "🎮 IOS"]],"resize_keyboard":true}'; | ||
$url = $GLOBALS[website]."/sendMessage?chat_id=$chatId&parse_mode=HTML&text=".urlencode($text).$keyboard; | ||
file_get_contents($url); | ||
} | ||
keyboardStart($chatId, "Hi, welcome to the Game Releases Bot. 🕹\nPlease choose your desidered platform(s) and I will send you a message at 11pm if a new release should be available.\nThe source code is available on <b>GitHub</b>\nEnjoy! 🍿\nhttps://github.com/Crazy-Marvin/GameReleasesTelegramBot."); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
require_once "/var/www/html/game/index.php"; | ||
|
||
$i = 0; | ||
|
||
$selectUsersPC = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `pc` = "✔️""); | ||
$numUsersPC = mysqli_num_rows($selectUsersPC); | ||
while ($i <= $numUsersPC) { | ||
$rowUsersPC = mysqli_fetch_assoc($selectUsersPC); | ||
$recordUserIdPC = $rowUsersPC["user_id"]; | ||
$filePC = file_get_contents("var/www/html/game/pc.text"); | ||
sendMessage($recordUserIdPC, "🔔 [NEW GAME]:\n$filePC"); | ||
} | ||
|
||
$selectUsersXBOX = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `xbox` = "✔️""); | ||
$numUsersXBOX = mysqli_num_rows($selectUsersXBOX); | ||
while ($i <= $numUsersXBOX) { | ||
$rowUsersXBOX = mysqli_fetch_assoc($selectUsersXBOX); | ||
$recordUserIdXBOX = $rowUsersXBOX["user_id"]; | ||
$fileXBOX = file_get_contents("var/www/html/game/xbox.text"); | ||
sendMessage($recordUserIdXBOX, "🔔 [NEW GAME]:\n$fileXBOX"); | ||
} | ||
|
||
$selectUsersSWITCH = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `switch` = "✔️""); | ||
$numUserSWITCH = mysqli_num_rows($selectUsersSWITCH); | ||
while ($i <= $numUsersSWITCH) { | ||
$rowUsersSWITCH = mysqli_fetch_assoc($selectUsersSWITCH); | ||
$recordUserIdSWITCH = $rowUsersSWITCH["user_id"]; | ||
$fileSWITCH = file_get_contents("var/www/html/game/switch.text"); | ||
sendMessage($recordUserIdSWITCH, "🔔 [NEW GAME]:\n$fileSWITCH"); | ||
} | ||
|
||
$selectUsersPS4 = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `ps4` = "✔️""); | ||
$numUserPS4 = mysqli_num_rows($selectUsersPS4); | ||
while ($i <= $numUsersPS4) { | ||
$rowUsersPS4 = mysqli_fetch_assoc($selectUsersPS4); | ||
$recordUserIdPS4 = $rowUsersPS4["user_id"]; | ||
$filePS4 = file_get_contents("var/www/html/game/ps4.text"); | ||
sendMessage($recordUserIdPS4, "🔔 [NEW GAME]:\n$filePS4"); | ||
} | ||
|
||
$selectUsersANDROID = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `android` = "✔️""); | ||
$numUserANDROID = mysqli_num_rows($selectUsersANDROID); | ||
while ($i <= $numUsersANDROID) { | ||
$rowUsersANDROID = mysqli_fetch_assoc($selectUsersANDROID); | ||
$recordUserIdANDROID = $rowUsersANDROID["user_id"]; | ||
$fileANDROID = file_get_contents("var/www/html/game/android.text"); | ||
sendMessage($recordUserIdANDROID, "🔔 [NEW GAME]:\n$fileANDROID"); | ||
} | ||
|
||
$selectUsersIOS = mysqli_query($mysqli, "SELECT * FROM `users` WHERE `ios` = "✔️""); | ||
$numUserIOS = mysqli_num_rows($selectUsersIOS); | ||
while ($i <= $numUsersIOS) { | ||
$rowUsersIOS = mysqli_fetch_assoc($selectUsersIOS); | ||
$recordUserIdIOS = $rowUsersIOS["user_id"]; | ||
$fileIOS = file_get_contents("var/www/html/game/ios.text"); | ||
sendMessage($recordUserIdIOS, "🔔 [NEW GAME]:\n$fileIOS"); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
$botToken = ""; | ||
$website = "https://api.telegram.org/bot".$botToken; | ||
|
||
$update = file_get_contents('php://input'); | ||
$update = json_decode($update, True); | ||
|
||
$config = [ | ||
'mysql_host' => '', | ||
'mysql_user' => '', | ||
'mysql_password' => '', | ||
'mysql_db' => '' | ||
]; | ||
|
||
$mysqli = new mysqli( | ||
$config['mysql_host'], | ||
$config['mysql_user'], | ||
$config['mysql_password'], | ||
$config['mysql_db'] | ||
); | ||
|
||
$mysqli->query("set names utf8mb4_general_ci"); | ||
|
||
$text = $update['message']['text']; | ||
$chatId = $update['message']['chat']['id']; | ||
$userId = $update['message']['from']['id']; | ||
|
||
function sendMessage($chatId, $text) { | ||
$url = $GLOBALS[website]."/sendMessage?chat_id=$chatId&parse_mode=HTML&text=".urlencode($text); | ||
file_get_contents($url); | ||
} | ||
|
||
include "/var/www/html/game/assets/start.php"; | ||
include "/var/www/html/game/assets/commands.php"; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# === IMPORT MODULES === # | ||
import requests | ||
from datetime import date | ||
from bs4 import BeautifulSoup | ||
|
||
today = date.today() | ||
|
||
# === MAIN PARAMETERS (PC - WINDOWS) === # | ||
html = requests.get("https://www.igdb.com/games/coming_soon?pfilter=6") | ||
soup = BeautifulSoup(html.text, "html.parser") | ||
rows = soup.findAll("div", {"class": "media-body"}) | ||
file = open("/var/www/html/game/pc.txt", "w") | ||
for row in rows: | ||
if str(today.day) in row.text: | ||
row = row.find("a").text | ||
file = open("/var/www/html/game/pc.txt", "a") | ||
file.write(f"{row}\n") | ||
print(f"{row}") | ||
|
||
html = requests.get("https://www.igdb.com/games/coming_soon?pfilter=169") | ||
soup = BeautifulSoup(html.text, "html.parser") | ||
rows = soup.findAll("div", {"class": "media-body"}) | ||
file = open("/var/www/html/game/xbox.txt", "w") | ||
for row in rows: | ||
if str(today.day) in row.text: | ||
row = row.find("a").text | ||
file = open("/var/www/html/game/xbox.txt", "a") | ||
file.write(f"{row}\n") | ||
print(f"{row}") | ||
|
||
html = requests.get("https://www.igdb.com/games/coming_soon?pfilter=130") | ||
soup = BeautifulSoup(html.text, "html.parser") | ||
rows = soup.findAll("div", {"class": "media-body"}) | ||
file = open("/var/www/html/game/switch.txt", "w") | ||
for row in rows: | ||
if str(today.day) in row.text: | ||
row = row.find("a").text | ||
file = open("/var/www/html/game/switch.txt", "a") | ||
file.write(f"{row}\n") | ||
print(f"{row}") | ||
|
||
html = requests.get("https://www.igdb.com/games/coming_soon?pfilter=48") | ||
soup = BeautifulSoup(html.text, "html.parser") | ||
rows = soup.findAll("div", {"class": "media-body"}) | ||
file = open("/var/www/html/game/ps4.txt", "w") | ||
for row in rows: | ||
if str(today.day) in row.text: | ||
row = row.find("a").text | ||
file = open("/var/www/html/game/ps4.txt", "a") | ||
file.write(f"{row}\n") | ||
print(f"{row}") | ||
|
||
html = requests.get("https://www.igdb.com/games/coming_soon?pfilter=34") | ||
soup = BeautifulSoup(html.text, "html.parser") | ||
rows = soup.findAll("div", {"class": "media-body"}) | ||
file = open("/var/www/html/game/android.txt", "w") | ||
for row in rows: | ||
if str(today.day) in row.text: | ||
row = row.find("a").text | ||
file = open("/var/www/html/game/android.txt", "a") | ||
file.write(f"{row}\n") | ||
print(f"{row}") | ||
|
||
html = requests.get("https://www.igdb.com/games/coming_soon?pfilter=39") | ||
soup = BeautifulSoup(html.text, "html.parser") | ||
rows = soup.findAll("div", {"class": "media-body"}) | ||
file = open("/var/www/html/game/ios.txt", "w") | ||
for row in rows: | ||
if str(today.day) in row.text: | ||
row = row.find("a").text | ||
file = open("/var/www/html/game/ios.txt", "a") | ||
file.write(f"{row}\n") | ||
print(f"{row}") |