mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-19 21:55:06 +01:00
various improvements and new plugins
This commit is contained in:
30
bot/plugins/crypto.py
Normal file
30
bot/plugins/crypto.py
Normal 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()
|
||||
Reference in New Issue
Block a user