__version__ = (1, 7, 0, 0)
# This file is a part of Hikka Userbot
# Code is NOT licensed under CC-BY-NC-ND 4.0 unless otherwise specified.
# 🌐 https://github.com/hikariatama/Hikka
# You CAN edit this file without direct permission from the author.
# You can redistribute this file with any modifications.
# meta developer: @yg_modules
# scope: hikka_only
# scope: hikka_min 1.6.3
# Changelog v1.7.0:
# - Добавлена поддержка веб аппа
# - Обновлен класс GameeHacker, теперь работает с новым API
# - кок
# █▄█ █░█ █▀▄▀█ █▀▄▀█ █▄█ █▀▄▀█ █▀█ █▀▄ █▀
# ░█░ █▄█ █░▀░█ █░▀░█ ░█░ █░▀░█ █▄█ █▄▀ ▄█
import json
import base64
from hashlib import md5
from random import randint
from uuid import uuid4
from datetime import datetime, timezone, timedelta
from urllib.parse import unquote, urlparse, parse_qs
import requests
from telethon.tl.functions.messages import RequestAppWebViewRequest
from telethon.tl.types import InputBotAppShortName
from .. import loader, utils
class GameeHacker:
API_URL = "https://api.gamee.com/"
SALT = "crmjbjm3lczhlgnek9uaxz2l9svlfjw14npauhen"
def __init__(self, client, score: int, play_time: int):
self.client = client
self.score = score
self.play_time = play_time
self.session = requests.Session()
self.session.headers.update({
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36",
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.5",
"Client-Language": "en",
"Content-Type": "text/plain;charset=UTF-8",
"Origin": "https://prizes.gamee.com",
"Referer": "https://prizes.gamee.com/",
"X-Bot-Header": "gamee",
"X-Install-Uuid": str(uuid4()),
})
async def _get_init_data(self, chat, start_param: str):
bot = await self.client.get_input_entity("gamee")
app = InputBotAppShortName(bot_id=bot, short_name="game")
web_view = await self.client(RequestAppWebViewRequest(
peer=chat,
app=app,
platform='android',
start_param=start_param,
))
auth_url = web_view.url
return unquote(auth_url.split('tgWebAppData=')[1].split('&tgWebAppVersion')[0])
def _login(self, init_data: str):
payload = [{"jsonrpc": "2.0",
"id": "user.authentication.loginUsingTelegram",
"method": "user.authentication.loginUsingTelegram",
"params": {"initData": init_data}}]
res = self.session.post(self.API_URL, data=json.dumps(payload)).json()
for item in res:
if item.get("id") == "user.authentication.loginUsingTelegram":
if "error" in item:
raise RuntimeError(f"Login error: {item['error'].get('message', 'Unknown error')}")
token = item["result"]["tokens"]["authenticate"]
self.session.headers["Authorization"] = f"Bearer {token}"
return
raise RuntimeError("Authentication token not found in login response.")
def _get_game_details(self, game_slug: str):
payload = [{"jsonrpc": "2.0",
"id": "game.get",
"method": "game.get",
"params": {"slug": game_slug}}]
res = self.session.post(self.API_URL, data=json.dumps(payload)).json()
for item in res:
if item.get("id") == "game.get":
if "error" in item:
raise RuntimeError(f"Get game details error: {item['error'].get('message', 'Unknown error')}")
game_data = item["result"]["game"]
return game_data["id"], game_data["release"]["number"]
raise RuntimeError("Game details not found in response.")
def _create_checksum(self, game_id: int, game_uuid: str) -> str:
raw_data = f"{self.score}:{self.play_time}:{game_id}::{game_uuid}:{__class__.SALT}"
return md5(raw_data.encode()).hexdigest()
def _send_score(
self,
game_id: int,
release_number: int,
chat_instance: str,
chat_type: str,
):
game_uuid = str(uuid4())
checksum = self._create_checksum(game_id, game_uuid)
payload = {
"jsonrpc": "2.0",
"id": "game.saveTelegramGameplay",
"method": "game.saveTelegramGameplay",
"params": {
"gameplayData": {
"gameId": game_id,
"score": self.score,
"playTime": self.play_time,
"releaseNumber": release_number,
"createdTime": datetime.now(timezone(timedelta(hours=2))).replace(microsecond=0).isoformat(),
"metadata": {"gameplayId": randint(1, 500)},
"isSaveState": False,
"gameStateData": None,
"gameplayOrigin": "game",
"replayData": None,
"replayVariant": None,
"replayDataChecksum": None,
"checksum": checksum,
"uuid": game_uuid,
},
"chatInstance": chat_instance,
"chatType": chat_type,
}
}
response = self.session.post(self.API_URL, data=json.dumps(payload)).json()
return response
async def kok(self, chat, msg):
try:
btn = msg.reply_markup.rows[0].buttons[0]
parsed_url = urlparse(btn.url)
start_param = parse_qs(parsed_url.query).get('startapp', [None])[0]
if not start_param:
raise ValueError("startapp param not found in button URL")
except Exception:
raise ValueError("Failed to get game button from the message. Make sure it's a message with a game.")
game_slug = json.loads(base64.b64decode(start_param))['game']['slug']
init_data = await self._get_init_data(chat, start_param)
self._login(init_data)
chat_params = {q.split("=")[0]: q.split("=")[1] for q in init_data.split("&")}
chat_instance = chat_params.get("chat_instance")
chat_type = chat_params.get("chat_type")
if not chat_instance or not chat_type:
raise ValueError("Could not parse chat_instance or chat_type from init_data")
game_id, release_number = self._get_game_details(game_slug)
return self._send_score(game_id, release_number, chat_instance, chat_type)
@loader.tds
class yg_gamee(loader.Module):
"""Module to cheat score in @gamee"""
strings = {
"name": "yg_gamee",
"args": "⚠️ Specify a link or reply to the message with the game!",
"processing": "⌛",
"button": "❓ Failed to click the button.. Make sure this is a message with a game!",
"usage": "🙂 Use: {prefix}gamee <score> <time in seconds> in a reply to the message with the game!",
"error": "⚠️ Error: {error}",
"success": "✨ Score boosted!\nℹ️ New record: {score}",
}
strings_ru = {
"args": "⚠️ Укажи ссылку или сделай реплай на сообщение с игрой!",
"processing": "⌛",
"button": "❓ Не удалось кликнуть по кнопке.. Убедись, что это сообщение с игрой!",
"usage": "🙂 Используй: {prefix}gamee <score> <time in seconds> в реплае на сообщение с игрой!",
"error": "⚠️ Ошибка: {error}",
"success": "✨ Рекорд накручен!\nℹ️ Новый рекорд: {score}",
}
strings_ua = {
"args": "⚠️ Вкажи посилання або зроби реплай на повідомлення з грою!",
"processing": "⌛",
"button": "❓ Не вдалося натиснути на кнопку.. Переконайся, що це повідомлення з грою!",
"usage": "🙂 Використовуй: {prefix}gamee <score> <time in seconds> у відповіді на повідомлення з грою!",
"error": "⚠️ Помилка: {error}",
"success": "✨ Рекорд накручено!\nℹ️ Новий рекорд: {score}",
}
@loader.command(
ru_doc="