|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +from __future__ import annotations |
| 3 | + |
| 4 | +from typing import TYPE_CHECKING |
| 5 | + |
| 6 | +from bot.ext import Admonitions, CommandExemples, Response, TBase, TranslationBase |
| 7 | + |
| 8 | +if TYPE_CHECKING: |
| 9 | + from bot.bot import Gorenmu |
| 10 | + from bot.ext import Context |
| 11 | + |
| 12 | + |
| 13 | +class Translations(TranslationBase): |
| 14 | + def __init__(self, bot: Gorenmu) -> None: |
| 15 | + super().__init__(bot) |
| 16 | + self.populate_subclasses() |
| 17 | + |
| 18 | + class LastSeen(TBase): |
| 19 | + def __init__(self): |
| 20 | + super().__init__() |
| 21 | + |
| 22 | + def bot(self, ctx: Context) -> Response: |
| 23 | + response = Response(ctx=ctx, success=False, handle=None, response_list=None) |
| 24 | + with self.lang_dict.once(self._cname): |
| 25 | + self.lang_dict.add_with("en", "I am everywhere, at every moment...") |
| 26 | + self.lang_dict.add_with(["pt_br", "pt"], "eu estou em todos os lugares, a todo momento...") |
| 27 | + return response.format_response(self._untangle_str(ctx, self._cname)) |
| 28 | + |
| 29 | + def author(self, ctx: Context) -> Response: |
| 30 | + response = Response(ctx=ctx, success=False, handle=None, response_list=None) |
| 31 | + with self.lang_dict.once(self._cname): |
| 32 | + self.lang_dict.add_with("en", "you were last seen here ☝️") |
| 33 | + self.lang_dict.add_with(["pt_br", "pt"], "você foi visto pela última vez aqui ☝️") |
| 34 | + return response.format_response(self._untangle_str(ctx, self._cname)) |
| 35 | + |
| 36 | + def not_found(self, ctx: Context, name) -> Response: |
| 37 | + response = Response(ctx=ctx, success=False, handle=None, response_list=None) |
| 38 | + with self.lang_dict.once(self._cname): |
| 39 | + self.lang_dict.add_with("en", "@{} has not been registered yet.") |
| 40 | + self.lang_dict.add_with(["pt_br", "pt"], "@{} ainda não foi registrado.") |
| 41 | + return response.format_response(self._untangle_str(ctx, self._cname), name) |
| 42 | + |
| 43 | + def not_authorized(self, ctx: Context, name, delta) -> Response: |
| 44 | + response = Response(ctx=ctx, success=True, handle=None, response_list=None) |
| 45 | + with self.lang_dict.once(self._cname): |
| 46 | + self.lang_dict.add_with("en", "@{} was last seen {}") |
| 47 | + self.lang_dict.add_with(["pt_br", "pt"], "@{} foi visto ultima vez {}") |
| 48 | + return response.format_response(self._untangle_str(ctx, self._cname), name, delta) |
| 49 | + |
| 50 | + def last_seen(self, ctx: Context, name, channel, content, delta) -> Response: |
| 51 | + response = Response(ctx=ctx, success=True, handle=None, response_list=None) |
| 52 | + with self.lang_dict.once(self._cname): |
| 53 | + self.lang_dict.add_with("en", "@{} was last seen in @{}: {} ({})") |
| 54 | + self.lang_dict.add_with(["pt_br", "pt"], "@{} foi visto em @{} pela última vez: {} ({})") |
| 55 | + return response.format_response(self._untangle_str(ctx, self._cname), name, channel, content, delta) |
| 56 | + |
| 57 | + def deco_helper(self, ctx: Context, *args, **kwargs) -> str: |
| 58 | + with self.lang_dict.once(self._cname): |
| 59 | + self.lang_dict.add_with("en", "Used to see the last time a user was online.") |
| 60 | + self.lang_dict.add_with(["pt_br", "pt"], "Usado para ver a ultima vez que um usuário esteve online.") |
| 61 | + return self._untangle_str(ctx, self._cname) |
| 62 | + |
| 63 | + def deco_usage(self, ctx: Context, prefix: str = None, *args, **kwargs) -> str: |
| 64 | + with self.lang_dict.once(self._cname): |
| 65 | + self.lang_dict.add_with("en", "Usage: {}lastseen (user)") |
| 66 | + self.lang_dict.add_with(["pt_br", "pt"], "Uso: {}lastseen (usuário)") |
| 67 | + return self._untangle_str(ctx, self._cname).format(prefix) |
| 68 | + |
| 69 | + # region Hide. |
| 70 | + def deco_description(self, ctx: Context, *args, **kwargs) -> str: |
| 71 | + with self.lang_dict.once(self._cname): |
| 72 | + self.lang_dict.add_with("en", "Command used to check when a user was last seen in a chat.") |
| 73 | + self.lang_dict.add_with( |
| 74 | + ["pt_br", "pt"], |
| 75 | + "Comando utilizado para verificar quando foi a ultima vez que um usuário foi visto em um chat.", |
| 76 | + ) |
| 77 | + return self._untangle_str(ctx, self._cname) |
| 78 | + |
| 79 | + def deco_commands(self, ctx: Context, *args, **kwargs) -> CommandExemples: |
| 80 | + with self.lang_dict.once(self._cname): |
| 81 | + self.lang_dict.add_with( |
| 82 | + "en", |
| 83 | + CommandExemples( |
| 84 | + [ |
| 85 | + { |
| 86 | + "args": "", |
| 87 | + "response": "@channel_name was last seen in @other_channel: " |
| 88 | + "Message content (1 day ago)", |
| 89 | + }, |
| 90 | + { |
| 91 | + "args": "user_nick", |
| 92 | + "response": "@user_nick was last seen in @other_channel: " |
| 93 | + "Message content (2 days ago)", |
| 94 | + }, |
| 95 | + ] |
| 96 | + ), |
| 97 | + ) |
| 98 | + self.lang_dict.add_with( |
| 99 | + ["pt_br", "pt"], |
| 100 | + CommandExemples( |
| 101 | + [ |
| 102 | + { |
| 103 | + "args": "", |
| 104 | + "response": "@nome_do_canal foi visto em @outro_canal pela última vez: " |
| 105 | + "Conteúdo da mensagem (ha 1 dia)", |
| 106 | + }, |
| 107 | + { |
| 108 | + "args": "user_nick", |
| 109 | + "response": "@user_nick foi visto em @outro_canal pela última vez: " |
| 110 | + "Conteúdo da mensagem (ha 2 dia)", |
| 111 | + }, |
| 112 | + ] |
| 113 | + ), |
| 114 | + ) |
| 115 | + return self._untangle_commands(ctx, self._cname) |
| 116 | + |
| 117 | + def deco_admonitions(self, ctx: Context, *args, **kwargs) -> Admonitions: |
| 118 | + with self.lang_dict.once(self._cname): |
| 119 | + self.lang_dict.add_with( |
| 120 | + "en", |
| 121 | + Admonitions( |
| 122 | + [ |
| 123 | + { |
| 124 | + "admonition_type": "info", |
| 125 | + "position": "top", |
| 126 | + "title": "User Mention", |
| 127 | + "message": "If the user has disabled mentions, the content of the last " |
| 128 | + "message and exact time will not be shown.", |
| 129 | + } |
| 130 | + ] |
| 131 | + ), |
| 132 | + ) |
| 133 | + self.lang_dict.add_with( |
| 134 | + ["pt_br", "pt"], |
| 135 | + Admonitions( |
| 136 | + [ |
| 137 | + { |
| 138 | + "admonition_type": "info", |
| 139 | + "position": "top", |
| 140 | + "title": "User Mention", |
| 141 | + "message": "Caso o usuário tenha desabilitado a menção o conteúdo da ultima " |
| 142 | + "mensagem e exato tempo não sera mostrado.", |
| 143 | + } |
| 144 | + ] |
| 145 | + ), |
| 146 | + ) |
| 147 | + return self._untangle_admonitions(ctx, self._cname) |
| 148 | + |
| 149 | + # endregion |
| 150 | + |
| 151 | + LastSeen: LastSeen |
0 commit comments