# Proprietary License Agreement
# Copyright (c) 2024-29 CodWiz
# Permission is hereby granted to any person obtaining a copy of this software and associated documentation files (the "Software"), to use the Software for personal and non-commercial purposes, subject to the following conditions:
# 1. The Software may not be modified, altered, or otherwise changed in any way without the explicit written permission of the author.
# 2. Redistribution of the Software, in original or modified form, is strictly prohibited without the explicit written permission of the author.
# 3. The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the author or copyright holder be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the Software or the use or other dealings in the Software.
# 4. Any use of the Software must include the above copyright notice and this permission notice in all copies or substantial portions of the Software.
# 5. By using the Software, you agree to be bound by the terms and conditions of this license.
# For any inquiries or requests for permissions, please contact codwiz@yandex.ru.
# ---------------------------------------------------------------------------------
# Name: InlineButton
# Description: Create inline button
# Author: @hikka_mods
# ---------------------------------------------------------------------------------
# meta developer: @hikka_mods
# scope: InlineButton
# scope: InlineButton 0.0.1
# ---------------------------------------------------------------------------------
import logging
from .. import loader, utils
from ..inline.types import InlineQuery
logger = logging.getLogger(__name__)
@loader.tds
class InlineButtonMod(loader.Module):
"""Create inline buttons with enhanced functionality"""
strings = {
"name": "InlineButton",
"titles": "π Create message with Inline Button",
"error_title": "β Error",
"error_description": "β Invalid input format. Please provide exactly three comma-separated values: message, name, url.",
"error_message": "β Make sure your input is formatted as: message, name, url.",
"button_created": "β
Button created successfully!",
"no_args": "β Please provide arguments: message, name, url.",
}
strings_ru = {
"titles": "π Π‘ΠΎΠ·Π΄Π°ΡΡ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ Ρ Inline ΠΠ½ΠΎΠΏΠΊΠΎΠΉ",
"error_title": "β ΠΡΠΈΠ±ΠΊΠ°",
"error_description": "β ΠΠ΅Π²Π΅ΡΠ½ΡΠΉ ΡΠΎΡΠΌΠ°Ρ Π²Π²ΠΎΠ΄Π°. ΠΠΎΠΆΠ°Π»ΡΠΉΡΡΠ°, ΡΠΊΠ°ΠΆΠΈΡΠ΅ ΡΠΎΠ²Π½ΠΎ ΡΡΠΈ Π·Π½Π°ΡΠ΅Π½ΠΈΡ, ΡΠ°Π·Π΄Π΅Π»Π΅Π½Π½ΡΡ
Π·Π°ΠΏΡΡΡΠΌΠΈ: ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅, ΠΈΠΌΡ, url.",
"error_message": "β Π£Π±Π΅Π΄ΠΈΡΠ΅ΡΡ, ΡΡΠΎ Π²Π°Ρ Π²Π²ΠΎΠ΄ ΠΈΠΌΠ΅Π΅Ρ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΉ ΡΠΎΡΠΌΠ°Ρ: ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅, ΠΈΠΌΡ, url.",
"button_created": "β
ΠΠ½ΠΎΠΏΠΊΠ° ΡΡΠΏΠ΅ΡΠ½ΠΎ ΡΠΎΠ·Π΄Π°Π½Π°!",
"no_args": "β Π£ΠΊΠ°ΠΆΠΈΡΠ΅ Π°ΡΠ³ΡΠΌΠ΅Π½ΡΡ: ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅, ΠΈΠΌΡ, url.",
}
@loader.command(
ru_doc="Π‘ΠΎΠ·Π΄Π°ΡΡ inline ΠΊΠ½ΠΎΠΏΠΊΡ\nΠΠ°ΠΏΡΠΈΠΌΠ΅Ρ: @username_bot crinl Π’Π΅ΠΊΡΡ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΡ, Π’Π΅ΠΊΡΡ ΠΊΠ½ΠΎΠΏΠΊΠΈ, Π‘ΡΡΠ»ΠΊΠ° Π² ΠΊΠ½ΠΎΠΏΠΊΠ΅",
en_doc="Create an inline button\nexample: @username_bot crinl Message text, Button text, Link in the button",
)
async def crinl_inline_handler(self, query: InlineQuery):
args = utils.get_args_raw(query.query)
if not args:
return {
"title": self.strings("error_title"),
"description": self.strings("error_description"),
"message": self.strings("no_args"),
}
args_list = [arg.strip() for arg in args.split(",")]
if len(args_list) != 3:
return {
"title": self.strings("error_title"),
"description": self.strings("error_description"),
"message": self.strings("error_message"),
}
message, name, url = args_list
return True, {
"message": message,
"reply_markup": [{"text": name, "url": url}],
"description": self.strings("button_created"),
}