feat(texts): add more texts
This commit is contained in:
parent
de4c8c549a
commit
d187177908
46 changed files with 65 additions and 15 deletions
|
@ -7,7 +7,7 @@ from discord.ext import commands
|
|||
|
||||
from bot import TuxBot
|
||||
from utils import Texts, GroupPlus
|
||||
from utils.paginator import FieldPages
|
||||
from utils import FieldPages
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@ from yarl import URL
|
|||
|
||||
from bot import TuxBot
|
||||
from utils import PollModel, ResponsesModel
|
||||
from utils import Texts, emotes as utils_emotes
|
||||
from utils import Texts
|
||||
from utils.functions import emotes as utils_emotes
|
||||
from utils import groupExtra
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# Created by romain at 04/01/2020
|
||||
|
||||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
import platform
|
||||
import random
|
||||
import re
|
||||
import socket
|
||||
import time
|
||||
|
@ -18,7 +18,7 @@ from tcp_latency import measure_latency
|
|||
|
||||
from bot import TuxBot
|
||||
from utils import Texts
|
||||
from utils import commandExtra
|
||||
from utils import commandExtra, groupExtra
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -66,6 +66,19 @@ class Useful(commands.Cog):
|
|||
return (file_amount, total_lines), (
|
||||
python_file_amount, total_python_lines)
|
||||
|
||||
@staticmethod
|
||||
def luhn_checker(number: int):
|
||||
digits = [int(x) for x in reversed(str(number))]
|
||||
|
||||
for index, digit in enumerate(digits, start=1):
|
||||
digit = digit * 2 if index % 2 == 0 else digit
|
||||
if digit >= 10:
|
||||
digit = sum(int(x) for x in list(str(digit)))
|
||||
|
||||
digits[index - 1] = digit
|
||||
|
||||
return sum(digits) % 10 == 0
|
||||
|
||||
###########################################################################
|
||||
|
||||
@commandExtra(name='iplocalise', category='network',
|
||||
|
@ -339,6 +352,43 @@ class Useful(commands.Cog):
|
|||
|
||||
await ctx.send(embed=e)
|
||||
|
||||
###########################################################################
|
||||
@groupExtra(name='cb', aliases=['cc'],
|
||||
category='misc',
|
||||
description=Texts('useful_help').get('_cb'),
|
||||
help=Texts('useful_help').get('_cb__short'))
|
||||
async def _cb(self, ctx: commands.Context):
|
||||
if ctx.invoked_subcommand is None:
|
||||
await ctx.send_help('cb')
|
||||
|
||||
@_cb.command(name='validate', aliases=['valid', 'correct'],
|
||||
category='misc',
|
||||
description=Texts('useful_help').get('_cb_validate'),
|
||||
help=Texts('useful_help').get('_cb_validate__short'))
|
||||
async def _cb_validate(self, ctx: commands.Context, *, number: int):
|
||||
valid = self.luhn_checker(number)
|
||||
|
||||
await ctx.send(
|
||||
Texts(
|
||||
'useful', ctx
|
||||
).get(
|
||||
'valid_credit_card'
|
||||
if valid
|
||||
else 'invalid_credit_card'
|
||||
)
|
||||
)
|
||||
|
||||
@_cb.command(name='generate', aliases=['new', 'get'],
|
||||
category='misc',
|
||||
description=Texts('useful_help').get('_cb_generate'),
|
||||
help=Texts('useful_help').get('_cb_generate__short'))
|
||||
async def _cb_generate(self, ctx: commands.Context):
|
||||
number = random.randint(4000_0000_0000_0000, 5999_9999_9999_9999)
|
||||
while not self.luhn_checker(number):
|
||||
number = random.randint(4000_0000_0000_0000, 5999_9999_9999_9999)
|
||||
|
||||
await ctx.send(''.join(str(digit) for digit in str(number)))
|
||||
|
||||
|
||||
def setup(bot: TuxBot):
|
||||
bot.add_cog(Useful(bot))
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -2,14 +2,14 @@
|
|||
|
||||
BASEDIR=$(pwd)
|
||||
|
||||
cd "$BASEDIR/extras/locales/en/LC_MESSAGES"
|
||||
cd "$BASEDIR/utils/locales/en/LC_MESSAGES"
|
||||
|
||||
for i in *.po ; do
|
||||
[[ -f "$i" ]] || continue
|
||||
/usr/lib/python3.8/Tools/i18n/msgfmt.py -o "${i%.po}.mo" "${i%.po}"
|
||||
done
|
||||
|
||||
cd "$BASEDIR/extras/locales/fr/LC_MESSAGES"
|
||||
cd "$BASEDIR/utils/locales/fr/LC_MESSAGES"
|
||||
|
||||
for i in *.po ; do
|
||||
[[ -f "$i" ]] || continue
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from .database import Database
|
||||
from .models import *
|
||||
|
||||
from .config import *
|
||||
from .lang import *
|
||||
from .version import *
|
||||
from utils.functions.config import *
|
||||
from utils.functions.lang import *
|
||||
from utils.functions.version import *
|
||||
|
||||
from .extra import *
|
||||
from .paginator import *
|
||||
from utils.functions.extra import *
|
||||
from utils.functions.paginator import *
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import gettext
|
||||
from .config import Config
|
||||
from utils import Database
|
||||
from .database import Database
|
||||
|
||||
from .models.lang import LangModel
|
||||
from utils.models.lang import LangModel
|
||||
from discord.ext import commands
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ class Texts:
|
|||
self.base = base
|
||||
|
||||
def get(self, text: str) -> str:
|
||||
texts = gettext.translation(self.base, localedir='extras/locales',
|
||||
texts = gettext.translation(self.base, localedir='utils/locales',
|
||||
languages=[self.locale])
|
||||
texts.install()
|
||||
return texts.gettext(text)
|
0
utils/locales/fr/LC_MESSAGES/user.po
Normal file
0
utils/locales/fr/LC_MESSAGES/user.po
Normal file
Loading…
Reference in a new issue