Beispiel #1
0
 async def translate(self, ctx, *, message):
     translator = aiogoogletrans.Translator()
     res = await translator.translate(message)
     from_lang = aiogoogletrans.LANGUAGES[res.src]
     to_lang = aiogoogletrans.LANGUAGES[res.dest]
     embed = discord.Embed(colour=self.bot.colour,
                           description=f"**{from_lang.title()}**\n{message}\n\n**{to_lang.title()}**\n{res.text}\n\n**Pronunciation**\n{res.pronunciation}").set_author(
         name='Translated Text',
         icon_url="https://cdn3.iconfinder.com/data/icons/google-suits-1/32/18_google_translate_text_language_translation-512.png")
     return await ctx.send(embed=embed.set_footer(text=f"{round(res.confidence * 100)}% confident"))
Beispiel #2
0
async def do_translation(ctx, content, dest='en'):
    tr = aiogoogletrans.Translator()
    langs = aiogoogletrans.LANGUAGES
    translated = await tr.translate(content, dest=dest)
    embed = discord.Embed(color=discord.Color.main)
    embed.add_field(
        name=f'Input: {langs.get(translated.src, "Auto-Detected").title()}',
        value=content)
    embed.add_field(
        name=f'Output: {langs.get(translated.dest, "Unknown").title()}',
        value=translated.text,
        inline=False)
    await ctx.send(embed=embed)
Beispiel #3
0
 async def to(self, ctx, target_lang, *, message):
     translator = aiogoogletrans.Translator()
     try:
         res = await translator.translate(message, dest=target_lang)
     except ValueError:
         return await ctx.send(
             f"<:warning:727013811571261540> **{ctx.author.name}**, `{target_lang}` is not a valid langauge!")
     from_lang = aiogoogletrans.LANGUAGES[res.src]
     to_lang = aiogoogletrans.LANGUAGES[res.dest]
     embed = discord.Embed(colour=self.bot.colour,
                           description=f"**{from_lang.capitalize()}**\n{message}\n\n**{to_lang.capitalize()}**\n{res.text}\n\n**Pronunciation**\n{res.pronunciation}").set_author(
         name='Translated Text',
         icon_url="https://cdn3.iconfinder.com/data/icons/google-suits-1/32/18_google_translate_text_language_translation-512.png")
     return await ctx.send(embed=embed.set_footer(text=f"{res.confidence * 100}% confident"))
Beispiel #4
0
import aiohttp
import urllib.parse
import urllib.request
import re
from forex_python.converter import CurrencyRates
from forex_python.bitcoin import BtcConverter
import sys
import asyncurban
import aiogoogletrans
import asyncio
import time

c = CurrencyRates()
b = BtcConverter()
u = asyncurban.UrbanDictionary()
t = aiogoogletrans.Translator()


class Internet(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

    @commands.command(aliases=["transfer"])
    async def currency(self, ctx, amount, currency1, currency2):
        '''Currency exchange'''
        try:
            amount = int(amount)
        except:
            return await ctx.send("Not a valid amount of money.")
        try:
            amount2 = round(c.convert(currency1, currency2, amount), 2)
Beispiel #5
0
 async def on_load(self, from_reload):
     self.translator = gt.Translator(proxies=list(self.bot.proxies.keys()) +
                                     [None])
Beispiel #6
0
 def __init__(self, bot):
     self.bot = bot
     self.color = color_functions.Colors()
     self.translator = aiogoogletrans.Translator()
     db = Database()
     self.error_handler = db.error_handler
Beispiel #7
0
 def __init__(self, bot: cc.KernBot):
     self.bot = bot
     self.translator = aiogoogletrans.Translator()