diff --git a/plugins/telegram/examples/test_telegram_game_functions.py b/plugins/telegram/examples/test_telegram_game_functions.py index b7f80fd8..4ebcf84c 100644 --- a/plugins/telegram/examples/test_telegram_game_functions.py +++ b/plugins/telegram/examples/test_telegram_game_functions.py @@ -1,12 +1,7 @@ -import os -import sys from typing import Tuple -project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../..')) -sys.path.append(project_root) - -from plugins.telegram.telegram_plugin_gamesdk.telegram_plugin import TelegramPlugin -from src.game_sdk.game.custom_types import Function, FunctionResultStatus, Argument +from game_sdk.game.custom_types import Function, FunctionResultStatus, Argument +from telegram_plugin_gamesdk.telegram_plugin import TelegramPlugin def send_message_executable(tg_plugin: TelegramPlugin, chat_id: str, text: str) -> Tuple[FunctionResultStatus, str, dict]: @@ -16,6 +11,7 @@ def send_message_executable(tg_plugin: TelegramPlugin, chat_id: str, text: str) except Exception as e: return FunctionResultStatus.FAILED, str(e), {} + def send_message_fn(bot: TelegramPlugin) -> Function: return Function( fn_name="send_message", @@ -27,6 +23,7 @@ def send_message_fn(bot: TelegramPlugin) -> Function: executable=lambda chat_id, text: send_message_executable(bot, chat_id, text), ) + def send_media_executable(tg_plugin: TelegramPlugin, chat_id: str, media_type: str, media: str, caption: str = None) -> Tuple[FunctionResultStatus, str, dict]: try: tg_plugin.send_media(chat_id=chat_id, media_type=media_type, media=media, caption=caption) @@ -34,6 +31,7 @@ def send_media_executable(tg_plugin: TelegramPlugin, chat_id: str, media_type: s except Exception as e: return FunctionResultStatus.FAILED, str(e), {} + def send_media_fn(bot: TelegramPlugin) -> Function: return Function( fn_name="send_media", @@ -47,6 +45,7 @@ def send_media_fn(bot: TelegramPlugin) -> Function: executable=lambda chat_id, media_type, media, caption=None: send_media_executable(bot, chat_id, media_type, media, caption), ) + def create_poll_executable(tg_plugin: TelegramPlugin, chat_id: str, question: str, options: list[str], is_anonymous: bool = True, allows_multiple_answers: bool = False) -> Tuple[FunctionResultStatus, str, dict]: try: tg_plugin.create_poll(chat_id=chat_id, question=question, options=options, is_anonymous=is_anonymous, allows_multiple_answers=allows_multiple_answers) @@ -54,6 +53,7 @@ def create_poll_executable(tg_plugin: TelegramPlugin, chat_id: str, question: st except Exception as e: return FunctionResultStatus.FAILED, str(e), {} + def create_poll_fn(bot: TelegramPlugin) -> Function: return Function( fn_name="create_poll", @@ -68,6 +68,7 @@ def create_poll_fn(bot: TelegramPlugin) -> Function: executable=lambda chat_id, question, options, is_anonymous=False, allows_multiple_answers=False: create_poll_executable(bot, chat_id, question, options, is_anonymous, allows_multiple_answers), ) + def pin_message_executable(tg_plugin: TelegramPlugin, chat_id: str, message_id: int) -> Tuple[FunctionResultStatus, str, dict]: try: tg_plugin.pin_message(chat_id=chat_id, message_id=message_id) @@ -75,6 +76,7 @@ def pin_message_executable(tg_plugin: TelegramPlugin, chat_id: str, message_id: except Exception as e: return FunctionResultStatus.FAILED, str(e), {} + def pin_message_fn(bot: TelegramPlugin) -> Function: return Function( fn_name="pin_message", @@ -86,6 +88,7 @@ def pin_message_fn(bot: TelegramPlugin) -> Function: executable=lambda chat_id, message_id: pin_message_executable(bot, chat_id, message_id), ) + def unpin_message_executable(tg_plugin: TelegramPlugin, chat_id: str, message_id: int) -> Tuple[FunctionResultStatus, str, dict]: try: tg_plugin.unpin_message(chat_id=chat_id, message_id=message_id) @@ -93,6 +96,7 @@ def unpin_message_executable(tg_plugin: TelegramPlugin, chat_id: str, message_id except Exception as e: return FunctionResultStatus.FAILED, str(e), {} + def unpin_message_fn(bot: TelegramPlugin) -> Function: return Function( fn_name="unpin_message", @@ -104,6 +108,7 @@ def unpin_message_fn(bot: TelegramPlugin) -> Function: executable=lambda chat_id, message_id: unpin_message_executable(bot, chat_id, message_id), ) + def delete_message_executable(tg_plugin: TelegramPlugin, chat_id: str, message_id: int) -> Tuple[FunctionResultStatus, str, dict]: try: tg_plugin.delete_message(chat_id=chat_id, message_id=message_id) @@ -111,6 +116,7 @@ def delete_message_executable(tg_plugin: TelegramPlugin, chat_id: str, message_i except Exception as e: return FunctionResultStatus.FAILED, str(e), {} + def delete_message_fn(bot: TelegramPlugin) -> Function: return Function( fn_name="delete_message",