mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-22 07:08:19 +00:00
部分插件支持 Pagermaid_Pyro (#5)
* Add README.md * Modify an description error * Plugin bc,bin,tel adaptive fit Pagermaid_Pyro * Plugin news adaptive fit Pagermaid_Pyro
This commit is contained in:
parent
8bcc781ce8
commit
3007f68f07
10
README.md
Normal file
10
README.md
Normal file
@ -0,0 +1,10 @@
|
||||
# PagerMaid-Plugins
|
||||
PagerMaid-Pyro 的插件。
|
||||
|
||||
## 关于分支
|
||||
`master` 分支用来存放 PagerMaid-Modify 的插件。
|
||||
`v2` 分支用来存放 PagerMaid-Pyro 的插件。
|
||||
|
||||
⚠ **请注意,不同版本的插件不通用。**
|
||||
|
||||
⚠ **当前分支为 `v2` ,PagerMaid-Modify 版插件请前往 [master 分支](https://github.com/TeamPGM/PagerMaid_Plugins/tree/master)**。
|
112
bc/main.py
Normal file
112
bc/main.py
Normal file
@ -0,0 +1,112 @@
|
||||
""" PagerMaid Plugin Coin by Pentacene """
|
||||
# ______ _
|
||||
# | ___ \ | |
|
||||
# | |_/ /__ _ __ | |_ __ _ ___ ___ _ __ ___
|
||||
# | __/ _ \ '_ \| __/ _` |/ __/ _ \ '_ \ / _ \
|
||||
# | | | __/ | | | || (_| | (_| __/ | | | __/
|
||||
# \_| \___|_| |_|\__\__,_|\___\___|_| |_|\___|
|
||||
#
|
||||
|
||||
from asyncio import sleep
|
||||
from sys import executable
|
||||
import urllib.request
|
||||
from pyrogram import Client
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import Message, pip_install
|
||||
|
||||
pip_install("python-binance", alias="binance")
|
||||
pip_install("xmltodict")
|
||||
|
||||
from binance.client import Client
|
||||
import xmltodict
|
||||
|
||||
|
||||
API = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"
|
||||
CURRENCIES = []
|
||||
DATA = {}
|
||||
BINANCE_API_KEY = '8PDfQ2lSIyHPWdNAHNIaIoNy3MiiMuvgwYADbmtsKo867B0xnIhIGjPULsOtvMRk'
|
||||
BINANCE_API_SECRET = 'tbUiyZ94l0zpYOlKs3eO1dvLNMOSbOb2T1T0eT0I1eogH9Fh8Htvli05eZ1iDvra'
|
||||
|
||||
|
||||
def init() -> None:
|
||||
""" INIT """
|
||||
with urllib.request.urlopen(API) as response:
|
||||
result = response.read()
|
||||
try:
|
||||
global CURRENCIES, DATA
|
||||
rate_data = xmltodict.parse(result)
|
||||
rate_data = rate_data['gesmes:Envelope']['Cube']['Cube']['Cube']
|
||||
for i in rate_data:
|
||||
CURRENCIES.append(i['@currency'])
|
||||
DATA[i['@currency']] = float(i['@rate'])
|
||||
CURRENCIES.sort()
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
|
||||
@listener(command="bc",
|
||||
description="coins",
|
||||
parameters="<num> <coin1> <coin2>")
|
||||
async def coin(_: Client, message: Message) -> None:
|
||||
""" coin change """
|
||||
init()
|
||||
action = message.arguments.split()
|
||||
binanceclient = Client(BINANCE_API_KEY, BINANCE_API_SECRET)
|
||||
if len(action) < 3:
|
||||
await message.edit('输入错误.\n-bc 数量 币种1 币种2')
|
||||
return
|
||||
else:
|
||||
prices = binanceclient.get_all_tickers()
|
||||
try:
|
||||
number = float(action[0])
|
||||
except ValueError:
|
||||
await message.edit('输入错误.\n-bc 数量 币种1 币种2')
|
||||
return
|
||||
_from = action[1].upper().strip()
|
||||
_to = action[2].upper().strip()
|
||||
front_text = ''
|
||||
text = ''
|
||||
rear_text = ''
|
||||
price = 0.0
|
||||
_to_USD_rate = 0.0
|
||||
|
||||
if (CURRENCIES.count(_from) != 0) and (CURRENCIES.count(_to) != 0):
|
||||
# both are real currency
|
||||
text = f'{action[0]} {action[1].upper().strip()} = {float(action[0])*DATA[_to]/DATA[_from]:.2f} {action[2].upper().strip()}'
|
||||
|
||||
else:
|
||||
if CURRENCIES.count(_from) != 0:
|
||||
# from virtual currency to real currency
|
||||
number = number * DATA["USD"] / DATA[_from]
|
||||
_from = 'USDT'
|
||||
front_text = f'{action[0]} {action[1]} = \n'
|
||||
|
||||
if CURRENCIES.count(_to) != 0:
|
||||
# from real currency to virtual currency
|
||||
_to_USD_rate = DATA[_to] / DATA["USD"]
|
||||
_to = 'USDT'
|
||||
|
||||
for _a in prices:
|
||||
if _a['symbol'] == str(f'{_from}{_to}'):
|
||||
price = _a['price']
|
||||
if _to == 'USDT':
|
||||
if action[2].upper().strip() == 'USDT':
|
||||
rear_text = f'\n= {number * float(price) * DATA["CNY"]/DATA["USD"]:.2f} CNY'
|
||||
else:
|
||||
rear_text = f'\n= {number * float(price) * _to_USD_rate:.2f} {action[2].upper().strip()}'
|
||||
if float(price) < 1:
|
||||
text = f'{number} {_from} = {number * float(price):.8f} {_to}'
|
||||
else:
|
||||
text = f'{number} {_from} = {number * float(price):.2f} {_to}'
|
||||
break
|
||||
elif _a['symbol'] == str(f'{_to}{_from}'):
|
||||
price = 1 / float(_a['price'])
|
||||
text = f'{number} {_from} = {number * float(price):.8f} {_to}'
|
||||
break
|
||||
else:
|
||||
price = None
|
||||
|
||||
if price is None:
|
||||
text = f'Cannot find coinpair {action[1].upper().strip()}{action[2].upper().strip()} or {action[2].upper().strip()}{action[1].upper().strip()}'
|
||||
|
||||
await message.edit(f'{front_text}{text}{rear_text}')
|
66
bin/main.py
Normal file
66
bin/main.py
Normal file
@ -0,0 +1,66 @@
|
||||
import json
|
||||
import requests
|
||||
from json.decoder import JSONDecodeError
|
||||
from pyrogram import Client
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import Message
|
||||
|
||||
|
||||
@listener(command="bin",
|
||||
description="查询信用卡信息",
|
||||
parameters="<bin(4到8位数字)>")
|
||||
async def card(_: Client, message: Message):
|
||||
await message.edit('正在查询中...')
|
||||
try:
|
||||
card_bin = message.arguments
|
||||
except ValueError:
|
||||
await message.edit("出错了呜呜呜 ~ 无效的参数。")
|
||||
return
|
||||
try:
|
||||
r = requests.get("https://lookup.binlist.net/" + card_bin)
|
||||
except:
|
||||
await message.edit("出错了呜呜呜 ~ 无法访问到binlist。")
|
||||
return
|
||||
if r.status_code == 404:
|
||||
await message.edit("出错了呜呜呜 ~ 目标卡头不存在")
|
||||
return
|
||||
if r.status_code == 429:
|
||||
await message.edit("出错了呜呜呜 ~ 每分钟限额超过,请等待一分钟再试")
|
||||
return
|
||||
|
||||
try:
|
||||
bin_json = json.loads(r.content.decode("utf-8"))
|
||||
except JSONDecodeError:
|
||||
await message.edit("出错了呜呜呜 ~ 无效的参数。")
|
||||
return
|
||||
|
||||
msg_out = []
|
||||
msg_out.extend(["BIN:" + card_bin])
|
||||
try:
|
||||
msg_out.extend(["卡品牌:" + bin_json['scheme']])
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
try:
|
||||
msg_out.extend(["卡类型:" + bin_json['type']])
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
try:
|
||||
msg_out.extend(["卡种类:" + bin_json['brand']])
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
try:
|
||||
msg_out.extend(["发卡行:" + bin_json['bank']["name"]])
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
try:
|
||||
if bin_json['prepaid']:
|
||||
msg_out.extend(["是否预付:是"])
|
||||
else:
|
||||
msg_out.extend(["是否预付:否"])
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
try:
|
||||
msg_out.extend(["发卡国家:" + bin_json['country']['name']])
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
await message.edit("\n".join(msg_out))
|
@ -4,7 +4,7 @@ from pagermaid.utils import Message, execute
|
||||
|
||||
|
||||
@listener(command="cal",
|
||||
description="计算\n示例:\n`-cal 1+1`加法\n`-cal 2-1`减法\n`-cal 1*2`乘法\n`-cal 4/2`除法\n`-cal 4^2`幂运算\n`-cal sqrt(4)`开方",
|
||||
description="计算\n示例:\n`,cal 1+1`加法\n`,cal 2-1`减法\n`,cal 1*2`乘法\n`,cal 4/2`除法\n`,cal 4^2`幂运算\n`,cal sqrt(4)`开方",
|
||||
parameters="<基本运算>")
|
||||
async def cal(_: Client, message: Message):
|
||||
command = message.arguments
|
||||
@ -22,7 +22,7 @@ async def cal(_: Client, message: Message):
|
||||
return
|
||||
|
||||
@listener(command="con",
|
||||
description="换算\n示例:\n`-con 2 99`将99转换为2进制",
|
||||
description="换算\n示例:\n`,con 2 99`将99转换为2进制",
|
||||
parameters="<进制(数字)> <数值>")
|
||||
async def con(_: Client, message: Message):
|
||||
command = message.arguments.split()
|
||||
|
40
list.json
40
list.json
@ -69,6 +69,46 @@
|
||||
"supported": true,
|
||||
"des-short": "Base64编码/解码。",
|
||||
"des": "Base64编码/解码。\n命令:,b64e ,b64d"
|
||||
},
|
||||
{
|
||||
"name": "bc",
|
||||
"version": "1.232",
|
||||
"section": "chat",
|
||||
"maintainer": "Pentacene",
|
||||
"size": "4.2 kb",
|
||||
"supported": true,
|
||||
"des-short": "查询含虚拟货币在内的货币价格",
|
||||
"des": "命令:bc 数量 货币1 货币2"
|
||||
},
|
||||
{
|
||||
"name": "bin",
|
||||
"version": "1.021",
|
||||
"section": "daily",
|
||||
"maintainer": "paulkm",
|
||||
"size": "2.09 kb",
|
||||
"supported": true,
|
||||
"des-short": "查询信用卡bin信息。",
|
||||
"des": "使用binlist api查询,1分钟限额10次否则报错。使用方法:-bin xxx (xxx为信用卡卡号前4-8位,推荐6位)"
|
||||
},
|
||||
{
|
||||
"name": "tel",
|
||||
"version": "1.111",
|
||||
"section": "daily",
|
||||
"maintainer": "KorenKrita、xtaodada",
|
||||
"size": "1 kb",
|
||||
"supported": true,
|
||||
"des-short": "查询手机号码归属地等信息",
|
||||
"des": "查询电话号码归属地,号码段,卡类型,运营商及通信标准。命令:tel。"
|
||||
},
|
||||
{
|
||||
"name": "news",
|
||||
"version": "1.0",
|
||||
"section": "daily",
|
||||
"maintainer": "xtaodada",
|
||||
"size": "1.3 kb",
|
||||
"supported": true,
|
||||
"des-short": "每日新闻、历史上的今天、天天成语、慧语香风、诗歌天地",
|
||||
"des": "每日新闻、历史上的今天、天天成语、慧语香风、诗歌天地。\n指令:-news"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
34
news/main.py
Normal file
34
news/main.py
Normal file
@ -0,0 +1,34 @@
|
||||
from pyrogram import Client
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import Message, client
|
||||
|
||||
|
||||
@listener(command="news",
|
||||
description="每日新闻、历史上的今天、天天成语、慧语香风、诗歌天地")
|
||||
async def news(_: Client, context: Message):
|
||||
msg = context.arguments
|
||||
if not msg:
|
||||
await context.edit("获取中 . . .")
|
||||
try:
|
||||
data = await client.get("https://news.topurl.cn/api")
|
||||
data = data.json()["data"]
|
||||
text = "📮 每日新闻 📮\n"
|
||||
for i in range(12):
|
||||
text += f"{i + 1}. [{data['newsList'][i]['title']}]({data['newsList'][i]['url']})\n"
|
||||
|
||||
text += "\n🎬 历史上的今天 🎬\n"
|
||||
for i in data["historyList"]:
|
||||
text += f"{i['event']}\n"
|
||||
|
||||
text += "\n🧩 天天成语 🧩\n"
|
||||
text += f"{data['phrase']['phrase']} ----{data['phrase']['explain']}\n"
|
||||
|
||||
text += "\n🎻 慧语香风 🎻\n"
|
||||
text += f"{data['sentence']['sentence']} ----{data['sentence']['author']}\n"
|
||||
|
||||
text += "\n🎑 诗歌天地 🎑\n"
|
||||
text += f"{''.join(data['poem']['content'])} " \
|
||||
f"----《{data['poem']['title']}》{data['poem']['author']}"
|
||||
await context.edit(text)
|
||||
except Exception as e:
|
||||
await context.edit(f"获取失败\n{e}")
|
30
tel/main.py
Normal file
30
tel/main.py
Normal file
@ -0,0 +1,30 @@
|
||||
import json
|
||||
import sys, codecs
|
||||
|
||||
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
|
||||
from requests import get
|
||||
from pyrogram import Client
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import Message
|
||||
|
||||
|
||||
@listener(command="tel",
|
||||
description="手机号码归属地等信息查询。")
|
||||
async def tel(_: Client, context: Message):
|
||||
await context.edit("获取中 . . .")
|
||||
try:
|
||||
message = context.arguments
|
||||
except ValueError:
|
||||
await context.edit("出错了呜呜呜 ~ 无效的参数。")
|
||||
return
|
||||
req = get("https://tenapi.cn/tel?tel=" + message)
|
||||
if req.status_code == 200:
|
||||
data = json.loads(req.text)
|
||||
if not 'msg' in data:
|
||||
res = '电话号码:' + str(data['tel']) + '\n' + str(data['local']) + '\n' + str(data['duan']) + '\n' + str(
|
||||
data['type']) + '\n' + str(data['yys']) + '\n' + str(data['bz'])
|
||||
else:
|
||||
res = data['msg']
|
||||
await context.edit(res)
|
||||
else:
|
||||
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
Loading…
Reference in New Issue
Block a user