diff --git a/db/apps.json b/db/apps.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/db/apps.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/db/apps.py b/db/apps.py new file mode 100644 index 0000000..9254a03 --- /dev/null +++ b/db/apps.py @@ -0,0 +1,27 @@ +from lightdb import LightDB + +db = LightDB("db/apps.json") + + +def add_app(path, name): + if name in list(db): + return "The app already exists" + ex = {f"{name}": {"path": f"{path}", "name": f"{name}"}} + db.update(ex) + db.save() + + +def del_app(name): + del db[name] + db.save() + + +def get_apps(): + return list(db) + + +def get_path(name): + return db.get_key(name, "path") + +def get_commit(): + return open('db/ssha.txt', 'r').read() diff --git a/db/maindb.py b/db/maindb.py new file mode 100644 index 0000000..594b068 --- /dev/null +++ b/db/maindb.py @@ -0,0 +1,25 @@ +from lightdb import LightDB + +db = LightDB("db/mdb.json") + +def set_on_off(val: str) -> bool: + db.set_key('starter', 'restart', val) + + +def get_on_off(): + return db.get_key('starter', "restart") + + +def set_message_id(val: int): + db.set_key('starter', 'last_id', val) + + +def get_message_id(): + return db.get_key('starter', "last_id") + + +def get_status(): + return db.get_key('live', "status") + +def set_status(val: str): + db.set_key('live', 'status', val) \ No newline at end of file diff --git a/db/mdb.json b/db/mdb.json new file mode 100644 index 0000000..fa5eea5 --- /dev/null +++ b/db/mdb.json @@ -0,0 +1,6 @@ +{ + "starter": { + "restart": "true", + "last_id": 644 + } +} \ No newline at end of file diff --git a/db/ssha.txt b/db/ssha.txt new file mode 100644 index 0000000..b49ac01 --- /dev/null +++ b/db/ssha.txt @@ -0,0 +1 @@ +9cf1a60 \ No newline at end of file diff --git a/misc/commands.py b/misc/commands.py new file mode 100644 index 0000000..b1b0c69 --- /dev/null +++ b/misc/commands.py @@ -0,0 +1,10 @@ +import re + +def find_commands_in_file(file_path = 'main.py'): + commands = [] + with open(file_path, 'r', encoding='utf-8') as file: + content = file.read() + pattern = r'@dp\.message_handler.*commands=[\'"](.*?)[\'"]' + matches = re.findall(pattern, content) + commands.extend(matches) + return commands diff --git a/misc/filters.py b/misc/filters.py new file mode 100644 index 0000000..2f7f914 --- /dev/null +++ b/misc/filters.py @@ -0,0 +1,8 @@ +from aiogram.types import Message +from aiogram.dispatcher.filters import BoundFilter +from data import tg_id + + +class IsAdmin(BoundFilter): + async def check(self, message: Message): + return message.from_user.id == tg_id diff --git a/misc/markup.py b/misc/markup.py new file mode 100644 index 0000000..13517a5 --- /dev/null +++ b/misc/markup.py @@ -0,0 +1,221 @@ +from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup +from string import ascii_lowercase, ascii_uppercase, digits, punctuation, ascii_letters +from db import apps as sapps + +ru_keyboad_layout = "ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,." +ru_keyboad_layout_lower = ru_keyboad_layout.lower() +keyboard_layout = "QWERTYUIOPASDFGHJKLZXCVBNM,." +keyboard_layout_lower = keyboard_layout.lower() + + +def live(): + markup = InlineKeyboardMarkup(row_width=2) + start = InlineKeyboardButton(text="▶️ Start", callback_data="start-live") + stop = InlineKeyboardButton(text="⏹ Stop", callback_data="stop-live") + markup.add(start, stop) + return markup +def mouse_control(): + markup = InlineKeyboardMarkup(row_width=3) + none_keyb = InlineKeyboardButton(text="▪", callback_data='None') + up = InlineKeyboardButton(text="⬆️", callback_data="up-mouse") + press = InlineKeyboardButton(text="🖱", callback_data="press-mouse") + down = InlineKeyboardButton(text="⬇️", callback_data="down-mouse") + left = InlineKeyboardButton(text="⬅️", callback_data="left-mouse") + right = InlineKeyboardButton(text="➡️", callback_data="right-mouse") + markup.add(none_keyb, up, none_keyb) + markup.add(left, press, right) + markup.add(none_keyb, down, none_keyb) + return markup + +def digits_keyboard(): + buttons = [] + markup = InlineKeyboardMarkup(row_width=10) + for item in digits: + button_text = f"{item}" + button = InlineKeyboardButton(button_text, callback_data=f"{item}-keyb_typing") + buttons.append(button) + ascii = InlineKeyboardButton(text="🔠 ASCII", callback_data="ascii-keyboard") + backspace = InlineKeyboardButton(text="◀️ Backspace", callback_data="backspace-keyb_typing") + punctuation = InlineKeyboardButton(text="🔡 Punctuation", callback_data="punctuation-keyboard") + markup.add(ascii, punctuation) + markup.add(*buttons) + markup.add(backspace) + return markup + +def punctuation_keyboard(): + buttons = [] + markup = InlineKeyboardMarkup(row_width=10) + for item in punctuation: + button_text = f"{item}" + button = InlineKeyboardButton(button_text, callback_data=f"{item}-keyb_typing") + buttons.append(button) + backspace = InlineKeyboardButton(text="◀️ Backspace", callback_data="backspace-keyb_typing") + ascii = InlineKeyboardButton(text="🔠 ASCII", callback_data="ascii-keyboard") + digits = InlineKeyboardButton(text="🔢 Digits", callback_data="digits-keyboard") + markup.add(digits, ascii) + markup.add(*buttons) + markup.add(backspace) + return markup + +def ru_keyboard(): + buttons = [] + markup = InlineKeyboardMarkup(row_width=8) + for item in ru_keyboad_layout: + button_text = f"{item}" + button = InlineKeyboardButton(button_text, callback_data=f"{item}-keyb_typing") + buttons.append(button) + to_low = InlineKeyboardButton(text="🔽 To Lower", callback_data="ru-shiftlow") + backspace = InlineKeyboardButton(text="◀️ Backspace", callback_data="backspace-keyb_typing") + lang = InlineKeyboardButton(text="🇬🇧 Lang", callback_data="en-lang") + digits = InlineKeyboardButton(text="🔢 Digits", callback_data="digits-keyboard") + punctuation = InlineKeyboardButton(text="🔡 Punctuation", callback_data="punctuation-keyboard") + markup.add(digits, punctuation) + markup.add(*buttons) + markup.add(lang, to_low, backspace) + return markup + +def ru_lowercase_keyboard(): + buttons = [] + markup = InlineKeyboardMarkup(row_width=8) + for item in ru_keyboad_layout_lower: + button_text = f"{item}" + button = InlineKeyboardButton(button_text, callback_data=f"{item}-keyb_typing") + buttons.append(button) + to_up = InlineKeyboardButton(text="🔼 To Upper", callback_data="ru-shiftup") + backspace = InlineKeyboardButton(text="◀️ Backspace", callback_data="backspace-keyb_typing") + lang = InlineKeyboardButton(text="🇬🇧 Lang", callback_data="en-lang") + digits = InlineKeyboardButton(text="🔢 Digits", callback_data="digits-keyboard") + punctuation = InlineKeyboardButton(text="🔡 Punctuation", callback_data="punctuation-keyboard") + markup.add(digits, punctuation) + markup.add(*buttons) + markup.add(lang, to_up, backspace) + return markup + +def ascii_lowercase_keyboard(): + buttons = [] + markup = InlineKeyboardMarkup(row_width=8) + for item in keyboard_layout_lower: + button_text = f"{item}" + button = InlineKeyboardButton(button_text, callback_data=f"{item}-keyb_typing") + buttons.append(button) + to_up = InlineKeyboardButton(text="🔼 To Upper", callback_data="en-shiftup") + backspace = InlineKeyboardButton(text="◀️ Backspace", callback_data="backspace-keyb_typing") + lang = InlineKeyboardButton(text="🇷🇺 Lang", callback_data="ru-lang") + digits = InlineKeyboardButton(text="🔢 Digits", callback_data="digits-keyboard") + punctuation = InlineKeyboardButton(text="🔡 Punctuation", callback_data="punctuation-keyboard") + markup.add(digits, punctuation) + markup.add(*buttons) + markup.add(lang, to_up, backspace) + return markup + +def ascii_uppercase_keyboard(): + buttons = [] + markup = InlineKeyboardMarkup(row_width=10) + for item in keyboard_layout: + button_text = f"{item}" + button = InlineKeyboardButton(button_text, callback_data=f"{item}-keyb_typing") + buttons.append(button) + to_low = InlineKeyboardButton(text="🔽 To Lower", callback_data="en-shiftlow") + backspace = InlineKeyboardButton(text="◀️ Backspace", callback_data="backspace-keyb_typing") + lang = InlineKeyboardButton(text="🇷🇺 Lang", callback_data="ru-lang") + digits = InlineKeyboardButton(text="🔢 Digits", callback_data="digits-keyboard") + punctuation = InlineKeyboardButton(text="🔡 Punctuation", callback_data="punctuation-keyboard") + markup.add(digits, punctuation) + markup.add(*buttons) + markup.add(lang, to_low, backspace) + return markup + + +def settings(): + markup = InlineKeyboardMarkup() + shutdown = InlineKeyboardButton(text='🔽 Shutdown', callback_data='shutdown') + restart = InlineKeyboardButton(text='🔄 Restart', callback_data='restart') + lock = InlineKeyboardButton(text='🔒 Lock', callback_data='lock') + brightness = InlineKeyboardButton(text='🔆 Brightness', callback_data='set-br') # type: ignore + volume = InlineKeyboardButton(text='🔊 Volume', callback_data='set-vol') + screen_shot = InlineKeyboardButton(text="📺 Screenshot", callback_data='screenshot') + markup.add(brightness, volume, screen_shot) + markup.add(shutdown, restart, lock) + return markup + +def brightness(): + buttons = [] + lvlvs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] + markup = InlineKeyboardMarkup() + for item in lvlvs: + button_text = f"▫️ {item}" + button = InlineKeyboardButton(button_text, callback_data=f"{item}-brightness") + buttons.append(button) + markup.add(*buttons) + home = InlineKeyboardButton(text="🏘 Home",callback_data="home") + markup.add(home) + return markup + +def apps(): + buttons = [] + apps = sapps.get_apps() + markup = InlineKeyboardMarkup() + for item in apps: + button_text = f"▫{item}" + button = InlineKeyboardButton(button_text, callback_data=f"{item}-app") + buttons.append(button) + markup.add(*buttons) + return markup + +def delete(app): + markup = InlineKeyboardMarkup() + button = InlineKeyboardButton(f'Delete {app}', callback_data=f'{app}-rm') + markup.add(button) + return markup + +def volume(): + buttons = [] + lvlvs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] + markup = InlineKeyboardMarkup() + for item in lvlvs: + button_text = f"▫️ {item}" + button = InlineKeyboardButton(button_text, callback_data=f"{item}-volume") + buttons.append(button) + mute = button = InlineKeyboardButton("🔇 Mute", callback_data="mute-volume") + markup.add(*buttons) + home = InlineKeyboardButton(text="🏘 Home",callback_data="home") + markup.add(mute ,home) + return markup + +def back_apps(): + markup = InlineKeyboardMarkup() + home = InlineKeyboardButton(text="🔙 Back",callback_data="aplications") + markup.add(home) + return markup + +def confirmation(what): + markup = InlineKeyboardMarkup() + yes = InlineKeyboardButton(text='☑️ Yes ', callback_data=f'{what}-yes') + cancel = InlineKeyboardButton(text='🚫 Cancel', callback_data='close') + markup.add(yes, cancel) + home = InlineKeyboardButton(text="🏘 Home",callback_data="home") + markup.add(home) + return markup + +def enter_or_delete(what): + markup = InlineKeyboardMarkup() + yes = InlineKeyboardButton(text='☑️ Yes ', callback_data=f'{what}-yes') + cancel = InlineKeyboardButton(text='🚫 Delete', callback_data='delete') + markup.add(yes, cancel) + home = InlineKeyboardButton(text="🏘 Home",callback_data="home") + markup.add(home) + return markup + +def update(): + markup = InlineKeyboardMarkup() + upd = InlineKeyboardButton(text="🔄 Update", callback_data='update') + can = InlineKeyboardButton(text='🔻 Close', callback_data='close') + markup.add(upd, can) + return markup + +def log_screen(): + markup = InlineKeyboardMarkup() + clear = InlineKeyboardButton(text='🗑 Clear', callback_data='clear_logs') + screen = InlineKeyboardButton(text='📺 Screenshot', callback_data='scrn_logs') + markup.add(screen, clear) + return markup \ No newline at end of file diff --git a/misc/utils.py b/misc/utils.py new file mode 100644 index 0000000..ba0df91 --- /dev/null +++ b/misc/utils.py @@ -0,0 +1,83 @@ +import wmi +import webbrowser +import ctypes +import subprocess +import keyboard +import pyautogui +import psutil +import mouse +from ctypes import cast, POINTER +from comtypes import CLSCTX_ALL +from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume + +pyautogui.FAILSAFE = False + + +async def control_volume(percent): + devices = AudioUtilities.GetSpeakers() + interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None) + volume = cast(interface, POINTER(IAudioEndpointVolume)) + new_volume = min(percent / 100.0, 1.0) + volume.SetMasterVolumeLevelScalar(new_volume, None) + + +async def lock_screen(): + ctypes.windll.user32.LockWorkStation() + + +async def play_youtube_video(youtube_url): + webbrowser.open(youtube_url) + + +async def screenshot(): + screenshot = pyautogui.screenshot() + screenshot.save("s.png") + + +async def delete_all(): + pyautogui.click() + keyboard.press("ctrl") + keyboard.press("a") + keyboard.release("a") + keyboard.release("ctrl") + pyautogui.press("backspace") + +async def type_text(text): + if text == "backspace": + pyautogui.press("backspace") + else: + # pyautogui.write(text) + keyboard.write(text) + + +async def brightness(lvl): + c = wmi.WMI(namespace="wmi") + methods = c.WmiMonitorBrightnessMethods()[0] + methods.WmiSetBrightness(lvl, 0) + + +def open_application(application_path): + subprocess.Popen(application_path) + +def check_battery(): + return psutil.sensors_battery().percent + + +async def mouse_down(): + currentMouseX, currentMouseY = mouse.get_position() + mouse.move(currentMouseX, currentMouseY - 50) + +async def mouse_up(): + currentMouseX, currentMouseY = mouse.get_position() + mouse.move(currentMouseX, currentMouseY + 50) + +async def mouse_left(): + currentMouseX, currentMouseY = mouse.get_position() + mouse.move(currentMouseX - 50, currentMouseY) + +async def mouse_right(): + currentMouseX, currentMouseY = mouse.get_position() + mouse.move(currentMouseX + 50, currentMouseY) + +async def mouse_click(): + mouse.click() \ No newline at end of file diff --git a/misc/version.py b/misc/version.py new file mode 100644 index 0000000..7930c28 --- /dev/null +++ b/misc/version.py @@ -0,0 +1 @@ +version = "1 1 5"