async def urban_dict(event): """Output the definition of a word from Urban Dictionary""" ud = asyncurban.UrbanDictionary() await event.edit("Processing...") query = event.pattern_match.group(1) if not query: return await event.edit("`Error: Provide a word!`") template = "`Query: `{}\n\n`Definition: `{}\n\n`Example:\n`{}" try: definition = await ud.get_word(query) except asyncurban.WordNotFoundError: return await event.edit("`Error: No definition available.`") result = template.format(definition.word, definition.definition, definition.example) if len(result) >= 4096: await event.edit("`Output too large, sending as file...`") with open("output.txt", "w+") as file: file.write("Query: " + definition.word + "\n\nMeaning: " + definition.definition + "Example: \n" + definition.example) await event.client.send_file( event.chat_id, "output.txt", caption=f"Urban Dictionary's definition of {query}") if os.path.exists("output.txt"): os.remove("output.txt") return await event.delete() else: return await event.edit(result)
async def urban_dict(message: Message): word = message.input_str or message.reply_to_message.text urban = asyncurban.UrbanDictionary() try: mean = await urban.get_word(word) await message.edit( f"Text: {mean.word}**\n\nMeaning: {mean.definition}**\n\nExample: {mean.example}" ) except asyncurban.WordNotFoundError: await message.edit("No result found for " + word + "")
async def _(event): if event.fwd_from: return await event.edit("processing...") word = event.pattern_match.group(1) urban = asyncurban.UrbanDictionary() try: mean = await urban.get_word(word) await event.edit("Text: **{}**\n\nMeaning: **{}**\n\nExample: __{}__".format(mean.word, mean.definition, mean.example)) except asyncurban.WordNotFoundError: await event.edit("No result found for **" + word + "**")
async def _(event): word = event.pattern_match.group(1) urban = asyncurban.UrbanDictionary() try: mean = await urban.get_word(word) await edit_or_reply( event, "Text: **{}**\n\nMeaning: **{}**\n\nExample: __{}__".format( mean.word, mean.definition, mean.example), ) except asyncurban.WordNotFoundError: await edit_or_reply(event, "No result found for **" + word + "**")
async def urban_dict(event: NewMessage.Event) -> None: """ Looks up words in the Urban Dictionary.""" query = event.matches[0].group(2) urban_dict_helper = asyncurban.UrbanDictionary() try: urban_def = await urban_dict_helper.get_word(query) except asyncurban.WordNotFoundError: await event.answer(f"`Sorry, couldn't find any results for:` {query}") return await event.answer( f"**Text**: `{query}`\n\n**Meaning**:\n`{urban_def.definition}`\n\n**Example**:\n__{urban_def.example}__" )
async def _(event): xx = await eor(event, "`Processing...`") word = event.pattern_match.group(1) if word is None: return await xx.edit("`No word given!`") urban = asyncurban.UrbanDictionary() try: mean = await urban.get_word(word) await xx.edit( f"**Text**: `{mean.word}`\n\n**Meaning**: `{mean.definition}`\n\n**Example**: __{mean.example}__" ) except asyncurban.WordNotFoundError: await xx.edit(f"**No result found for** `{word}`")
async def handler(event): if event.fwd_from: return word = event.pattern_match.group(1) urbandict = asyncurban.UrbanDictionary() await event.edit(f"Searching UrbanDictionary for ```{word}```..") try: mean = await urbandict.get_word(word) await event.edit( "Text: **{}**\n\nMeaning: **{}**\n\nExample: __{}__".format( mean.word, mean.definition, mean.example)) except asyncurban.WordNotFoundError: await event.edit("No result found for **" + word + "**")
async def _(event): if event.fwd_from: return await event.edit("processing...") word = event.pattern_match.group(1) urban = asyncurban.UrbanDictionary() try: mean = await urban.get_word(word) await event.edit( "Text: **{}**\n\nBerarti: **{}**\n\nContoh: __{}__".format( mean.word, mean.definition, mean.example)) except asyncurban.WordNotFoundError: await event.edit("Tidak ada hasil untuk **" + word + "**")
async def _(event): if event.fwd_from: return await event.edit("**Processing...**") word = event.pattern_match.group(1) urban = asyncurban.UrbanDictionary() try: mean = await urban.get_word(word) await event.edit( "**Testo: {}**\n\n**Definizione: {}**\n\n**Esempio: {}**".format( mean.word, mean.definition, mean.example)) except asyncurban.WordNotFoundError: await event.edit("**Nessun risultato trovato per " + word + "**")
async def _(event): if event.fwd_from: return await event.edit("İşleniyor...") word = event.pattern_match.group(1) urban = asyncurban.UrbanDictionary() try: mean = await urban.get_word(word) await event.edit( "Metin: **{}**\n\nAnlamı: **{}**\n\nÖrnek: __{}__".format( mean.word, mean.definition, mean.example)) except asyncurban.WordNotFoundError: await event.edit("Şu kelime hakkında bir bilgi toplayamadım! : **" + word + "**")
async def urban_dict(event): """Output the definition of a word from Urban Dictionary""" if event.is_reply and not event.pattern_match.group(1): query = await event.get_reply_message() query = str(query.message) else: query = str(event.pattern_match.group(1)) if not query: return await event.edit("`Reply to a message or pass a query to search!`") await event.edit("Processing...") ud = asyncurban.UrbanDictionary() template = "`Query: `{}\n\n`Definition: `{}\n\n`Example:\n`{}" try: definition = await ud.get_word(query) except asyncurban.UrbanException as e: return await event.edit("**Error:** {e}.") result = template.format( definition.word, definition.definition, definition.example) if len(result) >= 4096: await event.edit("`Output too large, sending as file...`") with open("output.txt", "w+") as file: file.write( "Query: " + definition.word + "\n\nMeaning: " + definition.definition + "Example: \n" + definition.example ) await event.client.send_file( event.chat_id, "output.txt", caption=f"Urban Dictionary's definition of {query}", ) if os.path.exists("output.txt"): os.remove("output.txt") return await event.delete() else: return await event.edit(result)
async def u_d_(client, message): ms_ = await edit_or_reply(message, "`Please Wait.`") ud = asyncurban.UrbanDictionary() query_ = get_text(message) if not query_: return await ms_.edit("`Please Give Me Query As Input.`") try: u_d_ = await ud.get_word(query_) except asyncurban.UrbanException as exc: return await ms_.edit(f"`[UrbanDict - Async] : {exc}`") nice_t = f"<b>Query :</b> <code>{u_d_.word}</code> \n<b>Definition :</b> <i>{u_d_.definition}</i> \n<b>Example :</b> <i>{u_d_.example}</i>" await edit_or_send_as_file(nice_t, ms_, client, f"`[URBAN_DICT] - {query_}`", f"{query_}_ud", parse_mode="html") await ud.close()
async def urban_dict(event): """Output the definition of a word from Urban Dictionary""" if event.is_reply and not event.pattern_match.group(1): query = await event.get_reply_message() query = str(query.message) else: query = str(event.pattern_match.group(1)) if not query: return await event.edit("**Responda a uma mensagem ou passe uma consulta para pesquisar!**") await event.edit("**Processando...**") ud = asyncurban.UrbanDictionary() template = "**Consulta:** `{}`\n\n**Definição:**\n{}\n\n**Exemplo:**\n__{}__" try: definition = await ud.get_word(query) except asyncurban.UrbanException as e: return await event.edit(f"**Erro:** `{e}`") result = template.format(definition.word, definition.definition, definition.example) if len(result) < 4096: return await event.edit(result) await event.edit("**Resultado muito grande, enviando como arquivo...**") with open("output.txt", "w+") as file: file.write( "Consulta: " + definition.word + "\n\nSignificado: " + definition.definition + "Exemplo: \n" + definition.example ) await event.client.send_file( event.chat_id, "output.txt", caption=f"Urban Dictionary's definition of {query}", ) if os.path.exists("output.txt"): os.remove("output.txt") return await event.delete()
async def urban_dict(ud_e): """ For .ud command, fetch content from Urban Dictionary. """ if environ.get("isSuspended") == "True": return await ud_e.edit("Processing...") query = ud_e.pattern_match.group(1) urban_dict_helper = asyncurban.UrbanDictionary() try: urban_def = await urban_dict_helper.get_word(query) except asyncurban.WordNotFoundError: await ud_e.edit(f"Sorry, couldn't find any results for: {query}") return deflen = sum(len(i) for i in urban_def.definition) exalen = sum(len(i) for i in urban_def.example) meanlen = deflen + exalen if int(meanlen) >= 0: if int(meanlen) >= 4096: await ud_e.edit("`Output too large, sending as file.`") file = open("output.txt", "w+") file.write("Text: " + query + "\n\nMeaning: " + urban_def.definition + "\n\n" + "Example: \n" + urban_def.example) file.close() await ud_e.client.send_file( ud_e.chat_id, "output.txt", caption="`Output was too large, sent it as a file.`") if os.path.exists("output.txt"): os.remove("output.txt") await ud_e.delete() return await ud_e.edit("Text: **" + query + "**\n\nMeaning: **" + urban_def.definition + "**\n\n" + "Example: \n__" + urban_def.example + "__") if BOTLOG: await ud_e.client.send_message( BOTLOG_CHATID, "UrbanDictionary query for `" + query + "` executed successfully.") else: await ud_e.edit("No result found for **" + query + "**")
async def urban_dict(ud_e): lazy = ud_e sender = await lazy.get_sender() me = await lazy.client.get_me() if not sender.id == me.id: rkp = await lazy.reply("`processing...`") else: rkp = await lazy.edit("`processing...`") query = ud_e.pattern_match.group(1) urban_dict_helper = asyncurban.UrbanDictionary() try: urban_def = await urban_dict_helper.get_word(query) except asyncurban.WordNotFoundError: await rkp.edit(f"Sorry, couldn't find any results for: {query}") return deflen = sum(len(i) for i in urban_def.definition) exalen = sum(len(i) for i in urban_def.example) meanlen = deflen + exalen if int(meanlen) >= 0: if int(meanlen) >= 4096: await rkp.edit("`Output too large, sending as file.`") file = open("output.txt", "w+") file.write("Text: " + query + "\n\nMeaning: " + urban_def.definition + "\n\n" + "Example: \n" + urban_def.example) file.close() await ud_e.client.send_file( ud_e.chat_id, "output.txt", caption="`Output was too large, sent it as a file.`") if os.path.exists("output.txt"): os.remove("output.txt") await ud_e.delete() return return await rkp.edit("Text: **" + query + "**\n\nMeaning: **" + urban_def.definition + "**\n\n" + "Example: \n__" + urban_def.example + "__") else: return await rkp.edit("No result found for **" + query + "**")
async def urban_dict(ud_e): """ For .ud command, fetch content from Urban Dictionary. """ await ud_e.edit("`Processing...`") query = ud_e.text.split(" ")[1] urban_dict_helper = asyncurban.UrbanDictionary() try: urban_def = await urban_dict_helper.get_word(query) except asyncurban.WordNotFoundError: await ud_e.edit(f"Sorry, couldn't find any results for: {query}") return deflen = sum(len(i) for i in urban_def.definition) exalen = sum(len(i) for i in urban_def.example) meanlen = deflen + exalen if int(meanlen) >= 0: if int(meanlen) >= 4096: await ud_e.edit("`Output too large, sending as file.`") file = open("output.txt", "w+") file.write("Text: " + query + "\n\nMeaning: " + urban_def.definition + "\n\n" + "Example: \n" + urban_def.example) file.close() await ud_e.client.send_file( ud_e.chat_id, "output.txt", caption="`Output was too large, sent it as a file.`") if os.path.exists("output.txt"): os.remove("output.txt") await ud_e.delete() return await ud_e.edit("Text: **" + query + "**\n\nMeaning: **" + urban_def.definition + "**\n\n" + "Example: \n__" + urban_def.example + "__") if LOGGING: await event_log(event, "SCRAPERS (HYPERBOT++)", custom_text="UrbanDictionary query for `" + query + "` executed successfully.") else: await ud_e.edit("No result found for **" + query + "**")
def __init__(self, plugin): super().__init__() self.plugin = plugin self.urban = asyncurban.UrbanDictionary()
def __init__(self): self.urban = asyncurban.UrbanDictionary()
def __init__(self, bot): self.bot = bot self.u = asyncurban.UrbanDictionary() self.t = aiogoogletrans.Translator self.bot_start_time = datetime.datetime.now()
def __init__(self): self.name = _("Urban Dictionary") self.urban = asyncurban.UrbanDictionary()
from googleapiclient.discovery import build 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: