|
|
|
@ -1,22 +1,123 @@
|
|
|
|
|
import os
|
|
|
|
|
import logging
|
|
|
|
|
from flask import Flask, request, jsonify
|
|
|
|
|
#from win10toast import ToastNotifier
|
|
|
|
|
import asyncio
|
|
|
|
|
import subprocess
|
|
|
|
|
import signal
|
|
|
|
|
import psutil
|
|
|
|
|
import telegram
|
|
|
|
|
from telegram import Update
|
|
|
|
|
from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler, MessageHandler, filters
|
|
|
|
|
from telegram.ext import ApplicationBuilder, ContextTypes, CallbackContext, CommandHandler, MessageHandler, filters
|
|
|
|
|
import telegram.error
|
|
|
|
|
|
|
|
|
|
logging.basicConfig(filename='osiris_telegram.log', level=logging.DEBUG, format='%(asctime)s %(message)s')
|
|
|
|
|
|
|
|
|
|
####
|
|
|
|
|
# Telegramm Functions
|
|
|
|
|
# Nested Menu Bäume
|
|
|
|
|
####
|
|
|
|
|
main_menu = [
|
|
|
|
|
[
|
|
|
|
|
{"text": "Tool Commands", "callback_data": "tools"},
|
|
|
|
|
{"text": "Game Server", "callback_data": "game_servers"}
|
|
|
|
|
# Add neue Hauptmenu Elemente hier
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
tools_menu = [
|
|
|
|
|
[
|
|
|
|
|
{"text": "Status", "callback_data": "nuc_satus"},
|
|
|
|
|
{"text": "Shutdown", "callback_data": "nuc_shutdown"},
|
|
|
|
|
{"text": "<- Zurück", "callback_data": "nuc_back"}
|
|
|
|
|
# Add neue Tool Commands here
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
gameserver_menu = [
|
|
|
|
|
[
|
|
|
|
|
{"text": "Status Server", "callback_data": "gameservers_satus"},
|
|
|
|
|
{"text": "Minecraft", "callback_data": "gameservers_minecraft"},
|
|
|
|
|
{"text": "Ragnarok Online", "callback_data": "gameservers_ragnarok_online"},
|
|
|
|
|
{"text": "World of Warcraft", "callback_data": "gameservers_wow"},
|
|
|
|
|
{"text": "<- Zurück", "callback_data": "gameservers_back"}
|
|
|
|
|
# Add neue Gameserver Commands here
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
minecraft_menu = [
|
|
|
|
|
[
|
|
|
|
|
{"text": "Minecraft Vanilla 1.21", "callback_data": "minecraft_vanilla"},
|
|
|
|
|
{"text": "The 1.12.2 Pack (SanderPack)", "callback_data": "minecraft_sanderpack"},
|
|
|
|
|
{"text": "GT New Horizons 2.6.0 (SanderHorizons)", "callback_data": "minecraft_sanderhorizon"},
|
|
|
|
|
{"text": "RLCraft 2.9.3 (SanderHardcore)", "callback_data": "minecraft_sanderhardcore"},
|
|
|
|
|
{"text": "<- Zurück", "callback_data": "minecraft_back"}
|
|
|
|
|
# Add neue Minecraft Commands here
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
mc_vanilla_menu = [
|
|
|
|
|
[
|
|
|
|
|
{"text": "Start", "callback_data": "mc_vanilla_start"},
|
|
|
|
|
{"text": "<- Zurück", "callback_data": "mc_vanilla_back"}
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
mc_sanderpack_menu = [
|
|
|
|
|
[
|
|
|
|
|
{"text": "Start", "callback_data": "mc_sanderpack_start"},
|
|
|
|
|
{"text": "<- Zurück", "callback_data": "mc_sanderpack_back"}
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
mc_sanderhorizon_menu = [
|
|
|
|
|
[
|
|
|
|
|
{"text": "Start", "callback_data": "mc_sanderhorizon_start"},
|
|
|
|
|
{"text": "<- Zurück", "callback_data": "mc_sanderhorizon_back"}
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
mc_sanderhardcore_menu = [
|
|
|
|
|
[
|
|
|
|
|
{"text": "Start", "callback_data": "mc_sanderhardcore_start"},
|
|
|
|
|
{"text": "<- Zurück", "callback_data": "mc_sanderhardcore_back"}
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
ragnarok_online_menu = [
|
|
|
|
|
[
|
|
|
|
|
{"text": "Start", "callback_data": "ro_start"},
|
|
|
|
|
{"text": "<- Zurück", "callback_data": "ro_back"}
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
wow_menu = [
|
|
|
|
|
[
|
|
|
|
|
{"text": "Start", "callback_data": "wow_start"},
|
|
|
|
|
{"text": "<- Zurück", "callback_data": "wow_back"}
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
####
|
|
|
|
|
# Command-Verarbeitung
|
|
|
|
|
####
|
|
|
|
|
def handle_callback(update: Update, context: CallbackContext) -> None:
|
|
|
|
|
query = update.callback_query
|
|
|
|
|
data = query.data
|
|
|
|
|
|
|
|
|
|
match data:
|
|
|
|
|
# Main
|
|
|
|
|
case "tools":
|
|
|
|
|
query.edit_message_text("Wähle eine Tool Funktion:", reply_markup=telegram.InlineKeyboardMarkup(tools_menu))
|
|
|
|
|
case "game_servers":
|
|
|
|
|
query.edit_message_text("Wähle einen Gameserver Typ:", reply_markup=telegram.InlineKeyboardMarkup(gameserver_menu))
|
|
|
|
|
# Tools
|
|
|
|
|
case "game_servers":
|
|
|
|
|
query.edit_message_text("Wähle einen Gameserver Typ:", reply_markup=telegram.InlineKeyboardMarkup(gameserver_menu))
|
|
|
|
|
|
|
|
|
|
# TODO: Weiter bauen
|
|
|
|
|
# Game Servers
|
|
|
|
|
# Minecraft
|
|
|
|
|
# Ragnarok Online
|
|
|
|
|
# World of Warcraft
|
|
|
|
|
case _:
|
|
|
|
|
print()
|
|
|
|
|
####
|
|
|
|
|
# Initialize Bot
|
|
|
|
|
####
|
|
|
|
|
# Telegram bot token
|
|
|
|
|
TELEGRAM_BOT_TOKEN = '6984289827:AAHNUM4F_U6233oa75nX5jXyQY6vC0NlZvw'
|
|
|
|
|
|
|
|
|
|