mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-24 21:13:36 +00:00
Support auto install extra pypi packages
This commit is contained in:
parent
25ea5775ab
commit
6b0c9c09d3
14
autodel.py
14
autodel.py
@ -4,19 +4,16 @@
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from sys import executable
|
||||
from asyncio import sleep
|
||||
from telethon.tl.types import PeerUser
|
||||
from telethon.tl.custom import Message
|
||||
from pagermaid import redis, redis_status
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import alias_command
|
||||
from pagermaid.utils import alias_command, pip_install
|
||||
|
||||
try:
|
||||
import dateparser
|
||||
imported = True
|
||||
except ImportError:
|
||||
imported = False
|
||||
pip_install("dateparser")
|
||||
|
||||
import dateparser
|
||||
|
||||
|
||||
# https://stackoverflow.com/questions/1111056/get-time-zone-information-of-the-system-in-python
|
||||
@ -84,9 +81,6 @@ async def auto_del(context: Message):
|
||||
args = args.strip()
|
||||
reply = await context.get_reply_message()
|
||||
|
||||
if not imported:
|
||||
await edit(context, f"请先安装 `dateparser` 依赖: `{executable} -m pip install dateparser`")
|
||||
return
|
||||
if not redis_status():
|
||||
await edit(context, f"出错了呜呜呜 ~ 数据库离线。")
|
||||
return
|
||||
|
18
autorm.py
18
autorm.py
@ -2,17 +2,14 @@
|
||||
|
||||
# By tg @fruitymelon
|
||||
# extra requirements: dateparser
|
||||
|
||||
try:
|
||||
import dateparser
|
||||
|
||||
imported = True
|
||||
except ImportError:
|
||||
imported = False
|
||||
|
||||
import asyncio, time, traceback, sys
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import alias_command
|
||||
from pagermaid.utils import alias_command, pip_install
|
||||
|
||||
|
||||
pip_install("dateparser")
|
||||
|
||||
import dateparser
|
||||
|
||||
|
||||
# https://stackoverflow.com/questions/1111056/get-time-zone-information-of-the-system-in-python
|
||||
@ -110,9 +107,6 @@ async def autorm(context):
|
||||
args = context.arguments if context.arguments is not None else ""
|
||||
args = args.strip()
|
||||
|
||||
if not imported:
|
||||
await edit(context, f"Please install dateparser first: {sys.executable} -m pip install dateparser")
|
||||
return
|
||||
if len(args) == 0:
|
||||
await edit(context, "参数不能为空。使用 -help autorm 以查看帮助。")
|
||||
return
|
||||
|
28
bc.py
28
bc.py
@ -12,14 +12,14 @@ from sys import executable
|
||||
import urllib.request
|
||||
from telethon.tl.custom.message import Message
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import execute, alias_command
|
||||
from pagermaid.utils import execute, alias_command, pip_install
|
||||
|
||||
pip_install("python-binance", alias="binance")
|
||||
pip_install("xmltodict")
|
||||
|
||||
from binance.client import Client
|
||||
import xmltodict
|
||||
|
||||
imported = True
|
||||
try:
|
||||
from binance.client import Client
|
||||
import xmltodict
|
||||
except ImportError:
|
||||
imported = False
|
||||
|
||||
API = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"
|
||||
CURRENCIES = []
|
||||
@ -49,20 +49,6 @@ def init() -> None:
|
||||
parameters="<num> <coin1> <coin2>")
|
||||
async def coin(context: Message) -> None:
|
||||
""" coin change """
|
||||
if not imported:
|
||||
await context.edit("支持库 `python-binance` `xmltodict` 未安装...\n正在尝试自动安装...")
|
||||
await execute(f'{executable} -m pip install python-binance')
|
||||
await execute(f'{executable} -m pip install xmltodict')
|
||||
await sleep(10)
|
||||
result = await execute(f'{executable} -m pip show python-binance')
|
||||
result1 = await execute(f'{executable} -m pip show xmltodict')
|
||||
if len(result) > 0 and len(result1) > 0:
|
||||
await context.edit('支持库 `python-binance` `xmltodict` 安装成功...\n正在尝试自动重启...')
|
||||
await context.client.disconnect()
|
||||
else:
|
||||
await context.edit(f"自动安装失败..请尝试手动安装 `{executable} -m pip install python-binance`\n\n`"
|
||||
f"{executable} -m pip install xmltodict`\n随后,请重启 PagerMaid")
|
||||
return
|
||||
init()
|
||||
action = context.arguments.split()
|
||||
binanceclient = Client(BINANCE_API_KEY, BINANCE_API_SECRET)
|
||||
|
14
list.json
14
list.json
@ -22,7 +22,7 @@
|
||||
},
|
||||
{
|
||||
"name": "autorm",
|
||||
"version": "1.031",
|
||||
"version": "1.032",
|
||||
"section": "chat",
|
||||
"maintainer": "fruitymelon",
|
||||
"size": "6.7 kb",
|
||||
@ -32,7 +32,7 @@
|
||||
},
|
||||
{
|
||||
"name": "sendat",
|
||||
"version": "1.32",
|
||||
"version": "1.321",
|
||||
"section": "chat",
|
||||
"maintainer": "fruitymelon",
|
||||
"size": "15.0 kb",
|
||||
@ -262,7 +262,7 @@
|
||||
},
|
||||
{
|
||||
"name": "neteaseshuffle",
|
||||
"version": "1.111",
|
||||
"version": "1.112",
|
||||
"section": "daily",
|
||||
"maintainer": "TNTcraftHIM",
|
||||
"size": "3.0 kb",
|
||||
@ -272,7 +272,7 @@
|
||||
},
|
||||
{
|
||||
"name": "neteasedown",
|
||||
"version": "1.224",
|
||||
"version": "1.225",
|
||||
"section": "daily",
|
||||
"maintainer": "xtaodada",
|
||||
"size": "11.4 kb",
|
||||
@ -432,7 +432,7 @@
|
||||
},
|
||||
{
|
||||
"name": "bc",
|
||||
"version": "1.23",
|
||||
"version": "1.231",
|
||||
"section": "chat",
|
||||
"maintainer": "Pentacene",
|
||||
"size": "8.0 kb",
|
||||
@ -462,7 +462,7 @@
|
||||
},
|
||||
{
|
||||
"name": "pl",
|
||||
"version": "1.03",
|
||||
"version": "1.031",
|
||||
"section": "chat",
|
||||
"maintainer": "lowking",
|
||||
"size": "4.0 kb",
|
||||
@ -732,7 +732,7 @@
|
||||
},
|
||||
{
|
||||
"name": "autodel",
|
||||
"version": "1.0",
|
||||
"version": "1.001",
|
||||
"section": "chat",
|
||||
"maintainer": "xtaodada",
|
||||
"size": "5.7 kb",
|
||||
|
@ -4,30 +4,25 @@ import base64
|
||||
from asyncio import sleep
|
||||
from os import sep, remove, listdir
|
||||
from os.path import isfile, exists
|
||||
from sys import executable
|
||||
from time import strftime, localtime
|
||||
|
||||
try:
|
||||
from mutagen.mp3 import EasyMP3
|
||||
from mutagen.id3 import ID3, APIC
|
||||
from mutagen.flac import FLAC, Picture
|
||||
from mutagen.oggvorbis import OggVorbis
|
||||
from pyncm import GetCurrentSession, apis, DumpSessionAsString, SetCurrentSession, LoadSessionFromString
|
||||
from pyncm.utils.helper import TrackHelper
|
||||
from pyncm.apis import LoginFailedException
|
||||
from pyncm.apis.cloudsearch import CloudSearchType
|
||||
from pyncm.apis.login import LoginLogout
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import alias_command, execute, pip_install
|
||||
|
||||
cc_imported = True
|
||||
except ImportError:
|
||||
print(f'[!] Please run {executable} -m pip install pyncm')
|
||||
cc_imported = False
|
||||
pip_install("pyncm")
|
||||
|
||||
from mutagen.mp3 import EasyMP3
|
||||
from mutagen.id3 import ID3, APIC
|
||||
from mutagen.flac import FLAC, Picture
|
||||
from mutagen.oggvorbis import OggVorbis
|
||||
from pyncm import GetCurrentSession, apis, DumpSessionAsString, SetCurrentSession, LoadSessionFromString
|
||||
from pyncm.utils.helper import TrackHelper
|
||||
from pyncm.apis import LoginFailedException
|
||||
from pyncm.apis.cloudsearch import CloudSearchType
|
||||
from pyncm.apis.login import LoginLogout
|
||||
|
||||
from telethon.tl.types import DocumentAttributeAudio
|
||||
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import alias_command, execute
|
||||
|
||||
|
||||
def download_by_url(url, dest):
|
||||
# Downloads generic content
|
||||
@ -133,10 +128,6 @@ i.e.
|
||||
description=ned_help_msg,
|
||||
parameters="{关键词/id}/{login <账号> <密码>}/{clear}")
|
||||
async def ned(context):
|
||||
if not cc_imported:
|
||||
await context.edit(f"[!] Please run `-sh {executable} -m pip install pyncm` "
|
||||
f"and then restart pagermaid.")
|
||||
return
|
||||
if len(context.parameter) < 1:
|
||||
# 使用方法
|
||||
await context.edit(ned_help_msg)
|
||||
|
@ -3,19 +3,17 @@ import requests
|
||||
from time import sleep
|
||||
from pagermaid.listener import listener
|
||||
from os import remove, path
|
||||
from pagermaid.utils import alias_command
|
||||
from pagermaid.utils import alias_command, pip_install
|
||||
|
||||
pip_install("eyed3")
|
||||
|
||||
import eyed3
|
||||
|
||||
|
||||
@listener(is_plugin=True, outgoing=True, command=alias_command("ns"),
|
||||
description="随机网抑云热歌。")
|
||||
async def ns(context):
|
||||
await context.edit("获取中 . . .")
|
||||
try:
|
||||
import eyed3
|
||||
imported = True
|
||||
except ImportError:
|
||||
imported = False
|
||||
await context.edit("获取中 . . .\n(eyeD3支持库未安装,歌曲文件信息将无法导入\n请使用-sh pip3 install eyed3安装,或自行ssh安装)")
|
||||
status = False
|
||||
for _ in range(20): # 最多尝试20次
|
||||
req = requests.get(
|
||||
@ -49,7 +47,6 @@ async def ns(context):
|
||||
cap = artist + " - " + title
|
||||
else:
|
||||
continue
|
||||
if imported is True:
|
||||
tag = eyed3.load(name).tag
|
||||
tag.encoding = '\x01'
|
||||
tag.artist = artist
|
||||
|
17
pl.py
17
pl.py
@ -2,19 +2,15 @@
|
||||
|
||||
# By tg @lowking0415
|
||||
# extra requirements: bs4
|
||||
|
||||
imported = True
|
||||
|
||||
try:
|
||||
from bs4 import BeautifulSoup
|
||||
except ImportError:
|
||||
imported = False
|
||||
|
||||
from asyncio import sleep
|
||||
from requests import get
|
||||
from sys import executable
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import alias_command
|
||||
from pagermaid.utils import alias_command, pip_install
|
||||
|
||||
pip_install("bs4")
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from urllib import parse
|
||||
|
||||
|
||||
@ -22,9 +18,6 @@ from urllib import parse
|
||||
description="输入【-pl 食物名】查询食物嘌呤含量",
|
||||
parameters="<食物名>")
|
||||
async def pl(context):
|
||||
if not imported:
|
||||
await context.edit(f"请先安装依赖:\n`{executable} -m pip install bs4`\n随后,请重启 pagermaid。")
|
||||
return
|
||||
action = context.arguments.split()
|
||||
status = False
|
||||
if len(action) == 1:
|
||||
|
19
sendat.py
19
sendat.py
@ -2,20 +2,16 @@
|
||||
|
||||
# By tg @fruitymelon
|
||||
# extra requirements: dateparser
|
||||
|
||||
imported = True
|
||||
|
||||
import sys, time, traceback
|
||||
|
||||
try:
|
||||
import dateparser
|
||||
except ImportError:
|
||||
imported = False
|
||||
|
||||
import asyncio
|
||||
from pagermaid import log
|
||||
from pagermaid.listener import listener
|
||||
from pagermaid.utils import alias_command
|
||||
from pagermaid.utils import alias_command, pip_install
|
||||
|
||||
pip_install("dateparser")
|
||||
|
||||
import dateparser
|
||||
|
||||
|
||||
DAY_SECS = 24 * 60 * 60
|
||||
|
||||
@ -86,9 +82,6 @@ async def sendat(context):
|
||||
mem.append("[NULL]")
|
||||
chat = await context.get_chat()
|
||||
args = " ".join(context.parameter).split("|")
|
||||
if not imported:
|
||||
await context.edit(f"请先安装依赖:`{sys.executable} -m pip install dateparser`\n随后,请重启 pagermaid。")
|
||||
return
|
||||
await context.edit(f"debug: tz data: {time.timezone} {time.tzname} {sign}{offset}")
|
||||
if len(args) != 2:
|
||||
if args[0].find("rm ") == 0:
|
||||
|
Loading…
Reference in New Issue
Block a user