import os
from zlapi.models import Message, ThreadType
from config import PREFIX

des = {
    'version': "1.0.0",
    'credits': "HVHVZ",
    'description': "Thanh Toán",
    'power': "Thành viên"
}

def handle_stk_command(message, message_object, thread_id, thread_type, author_id, client):
    try:
        image_path = 'modules/cache/qrthanhtoan.png'
        if not os.path.exists(image_path):
            error_msg = "❌ Không tìm thấy ảnh QR thanh toán. Vui lòng kiểm tra file modules/cache/qrthanhtoan.png!"
            client.replyMessage(Message(text=error_msg), message_object, thread_id, thread_type, ttl=60000)
            return
        
        reply_text = (
            "NGÂN HÀNG: MBBANK\n"
            "STK: 9999032902\n"
            "CTK: Le Chi Quoc Hung"
        )
        
        client.sendLocalImage(
            imagePath=image_path,
            message=Message(text=reply_text),
            thread_id=thread_id,
            thread_type=thread_type,
            width=512,
            height=512
            
        )
        
    except Exception as e:
        error_msg = f"❌ Lỗi khi thực hiện lệnh stk: {str(e)}. Vui lòng thử lại!"
        client.replyMessage(Message(text=error_msg), message_object, thread_id, thread_type, ttl=60000)

def ft_vxkiue():
    return {
        'stk': handle_stk_command
    }