from __future__ import annotations
from . import command
from typing import Sequence, Any, List, TYPE_CHECKING
import telegram as tg

if TYPE_CHECKING:
    from main import Bea, Command

wtab = str.maketrans("0123456789:-/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ",
        "０１２３４５６７８９：－／ａｂｃｄｅｆｇｈｉｊｋｌｍｎｏｐｑｒｓｔｕｖｗｘｙｚＡＢＣＤＥＦＧＨＩＪＫＬＭＮＯＰＱＲＳＴＵＶＷＸＹＺ\u3000")

@command('fullwidth (.+)', pass_groups=True, inline=True)
def fullwidth(bea: Bea, bot: tg.Bot, update: tg.Update, groups: Sequence[str]) -> None:
    """ Turn the given text into fullwidth text. """
    if update.inline_query is not None:
        bea.inline_reply_text(groups[0].translate(wtab))
    else:
        update.message.reply_text("%s" % groups[0].translate(wtab), quote=False)

def init(bea: Bea, config_: Any) -> List[Command]:
    return [fullwidth]
