| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- """
- MIT License
- Copyright (c) present TheHamkerCat
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- """
- from pyrogram import filters
- from wbb import app
- from wbb.core.decorators.errors import capture_err
- from wbb.core.keyboard import ikb
- from wbb.core.sections import section
- from wbb.utils.http import get
- __MODULE__ = "Crypto"
- __HELP__ = """
- /crypto [currency]
- Get Real Time value from currency given.
- """
- @app.on_message(
- filters.command("crypto")
- )
- @capture_err
- async def crypto(_, message):
- if len(message.command) < 2:
- return await message.reply("/crypto [currency]")
- currency = message.text.split(None, 1)[1].lower()
- btn = ikb(
- {"Available Currencies": "https://plotcryptoprice.herokuapp.com"},
- )
- m = await message.reply("`Processing...`")
- try:
- r = await get(
- "https://x.wazirx.com/wazirx-falcon/api/v2.0/crypto_rates",
- timeout=5,
- )
- except Exception:
- return await m.edit("[ERROR]: Something went wrong.")
- if currency not in r:
- return await m.edit(
- "[ERROR]: INVALID CURRENCY",
- reply_markup=btn,
- )
- body = {i.upper(): j for i, j in r.get(currency).items()}
- text = section(
- "Current Crypto Rates For " + currency.upper(),
- body,
- )
- await m.edit(text, reply_markup=btn)
|