various improvements and new plugins

This commit is contained in:
ned
2023-06-17 23:39:12 +02:00
parent c9d9c75d6c
commit 302cdc035d
11 changed files with 298 additions and 78 deletions

30
bot/plugins/crypto.py Normal file
View File

@@ -0,0 +1,30 @@
from typing import Dict
import requests
from bot.plugins.plugin import Plugin
# Author: https://github.com/stumpyfr
class CryptoPlugin(Plugin):
"""
A plugin to fetch the current rate of various cryptocurrencies
"""
def get_source_name(self) -> str:
return "CoinCap"
def get_spec(self) -> Dict:
return {
"name": "get_crypto_rate",
"description": "Get the current rate of various crypto currencies",
"parameters": {
"type": "object",
"properties": {
"asset": {"type": "string", "description": "Asset of the crypto"}
},
"required": ["asset"],
},
}
async def execute(self, **kwargs) -> Dict:
return requests.get(f"https://api.coincap.io/v2/rates/{kwargs['asset']}").json()