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 time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from sys import executable
|
|
||||||
from asyncio import sleep
|
from asyncio import sleep
|
||||||
from telethon.tl.types import PeerUser
|
from telethon.tl.types import PeerUser
|
||||||
from telethon.tl.custom import Message
|
from telethon.tl.custom import Message
|
||||||
from pagermaid import redis, redis_status
|
from pagermaid import redis, redis_status
|
||||||
from pagermaid.listener import listener
|
from pagermaid.listener import listener
|
||||||
from pagermaid.utils import alias_command
|
from pagermaid.utils import alias_command, pip_install
|
||||||
|
|
||||||
try:
|
pip_install("dateparser")
|
||||||
import dateparser
|
|
||||||
imported = True
|
import dateparser
|
||||||
except ImportError:
|
|
||||||
imported = False
|
|
||||||
|
|
||||||
|
|
||||||
# https://stackoverflow.com/questions/1111056/get-time-zone-information-of-the-system-in-python
|
# 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()
|
args = args.strip()
|
||||||
reply = await context.get_reply_message()
|
reply = await context.get_reply_message()
|
||||||
|
|
||||||
if not imported:
|
|
||||||
await edit(context, f"请先安装 `dateparser` 依赖: `{executable} -m pip install dateparser`")
|
|
||||||
return
|
|
||||||
if not redis_status():
|
if not redis_status():
|
||||||
await edit(context, f"出错了呜呜呜 ~ 数据库离线。")
|
await edit(context, f"出错了呜呜呜 ~ 数据库离线。")
|
||||||
return
|
return
|
||||||
|
18
autorm.py
18
autorm.py
@ -2,17 +2,14 @@
|
|||||||
|
|
||||||
# By tg @fruitymelon
|
# By tg @fruitymelon
|
||||||
# extra requirements: dateparser
|
# extra requirements: dateparser
|
||||||
|
|
||||||
try:
|
|
||||||
import dateparser
|
|
||||||
|
|
||||||
imported = True
|
|
||||||
except ImportError:
|
|
||||||
imported = False
|
|
||||||
|
|
||||||
import asyncio, time, traceback, sys
|
import asyncio, time, traceback, sys
|
||||||
from pagermaid.listener import listener
|
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
|
# 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 = context.arguments if context.arguments is not None else ""
|
||||||
args = args.strip()
|
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:
|
if len(args) == 0:
|
||||||
await edit(context, "参数不能为空。使用 -help autorm 以查看帮助。")
|
await edit(context, "参数不能为空。使用 -help autorm 以查看帮助。")
|
||||||
return
|
return
|
||||||
|
28
bc.py
28
bc.py
@ -12,14 +12,14 @@ from sys import executable
|
|||||||
import urllib.request
|
import urllib.request
|
||||||
from telethon.tl.custom.message import Message
|
from telethon.tl.custom.message import Message
|
||||||
from pagermaid.listener import listener
|
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"
|
API = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"
|
||||||
CURRENCIES = []
|
CURRENCIES = []
|
||||||
@ -49,20 +49,6 @@ def init() -> None:
|
|||||||
parameters="<num> <coin1> <coin2>")
|
parameters="<num> <coin1> <coin2>")
|
||||||
async def coin(context: Message) -> None:
|
async def coin(context: Message) -> None:
|
||||||
""" coin change """
|
""" 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()
|
init()
|
||||||
action = context.arguments.split()
|
action = context.arguments.split()
|
||||||
binanceclient = Client(BINANCE_API_KEY, BINANCE_API_SECRET)
|
binanceclient = Client(BINANCE_API_KEY, BINANCE_API_SECRET)
|
||||||
|
14
list.json
14
list.json
@ -22,7 +22,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "autorm",
|
"name": "autorm",
|
||||||
"version": "1.031",
|
"version": "1.032",
|
||||||
"section": "chat",
|
"section": "chat",
|
||||||
"maintainer": "fruitymelon",
|
"maintainer": "fruitymelon",
|
||||||
"size": "6.7 kb",
|
"size": "6.7 kb",
|
||||||
@ -32,7 +32,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sendat",
|
"name": "sendat",
|
||||||
"version": "1.32",
|
"version": "1.321",
|
||||||
"section": "chat",
|
"section": "chat",
|
||||||
"maintainer": "fruitymelon",
|
"maintainer": "fruitymelon",
|
||||||
"size": "15.0 kb",
|
"size": "15.0 kb",
|
||||||
@ -262,7 +262,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "neteaseshuffle",
|
"name": "neteaseshuffle",
|
||||||
"version": "1.111",
|
"version": "1.112",
|
||||||
"section": "daily",
|
"section": "daily",
|
||||||
"maintainer": "TNTcraftHIM",
|
"maintainer": "TNTcraftHIM",
|
||||||
"size": "3.0 kb",
|
"size": "3.0 kb",
|
||||||
@ -272,7 +272,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "neteasedown",
|
"name": "neteasedown",
|
||||||
"version": "1.224",
|
"version": "1.225",
|
||||||
"section": "daily",
|
"section": "daily",
|
||||||
"maintainer": "xtaodada",
|
"maintainer": "xtaodada",
|
||||||
"size": "11.4 kb",
|
"size": "11.4 kb",
|
||||||
@ -432,7 +432,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "bc",
|
"name": "bc",
|
||||||
"version": "1.23",
|
"version": "1.231",
|
||||||
"section": "chat",
|
"section": "chat",
|
||||||
"maintainer": "Pentacene",
|
"maintainer": "Pentacene",
|
||||||
"size": "8.0 kb",
|
"size": "8.0 kb",
|
||||||
@ -462,7 +462,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pl",
|
"name": "pl",
|
||||||
"version": "1.03",
|
"version": "1.031",
|
||||||
"section": "chat",
|
"section": "chat",
|
||||||
"maintainer": "lowking",
|
"maintainer": "lowking",
|
||||||
"size": "4.0 kb",
|
"size": "4.0 kb",
|
||||||
@ -732,7 +732,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "autodel",
|
"name": "autodel",
|
||||||
"version": "1.0",
|
"version": "1.001",
|
||||||
"section": "chat",
|
"section": "chat",
|
||||||
"maintainer": "xtaodada",
|
"maintainer": "xtaodada",
|
||||||
"size": "5.7 kb",
|
"size": "5.7 kb",
|
||||||
|
@ -4,30 +4,25 @@ import base64
|
|||||||
from asyncio import sleep
|
from asyncio import sleep
|
||||||
from os import sep, remove, listdir
|
from os import sep, remove, listdir
|
||||||
from os.path import isfile, exists
|
from os.path import isfile, exists
|
||||||
from sys import executable
|
|
||||||
from time import strftime, localtime
|
from time import strftime, localtime
|
||||||
|
|
||||||
try:
|
from pagermaid.listener import listener
|
||||||
from mutagen.mp3 import EasyMP3
|
from pagermaid.utils import alias_command, execute, pip_install
|
||||||
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
|
|
||||||
|
|
||||||
cc_imported = True
|
pip_install("pyncm")
|
||||||
except ImportError:
|
|
||||||
print(f'[!] Please run {executable} -m pip install pyncm')
|
from mutagen.mp3 import EasyMP3
|
||||||
cc_imported = False
|
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 telethon.tl.types import DocumentAttributeAudio
|
||||||
|
|
||||||
from pagermaid.listener import listener
|
|
||||||
from pagermaid.utils import alias_command, execute
|
|
||||||
|
|
||||||
|
|
||||||
def download_by_url(url, dest):
|
def download_by_url(url, dest):
|
||||||
# Downloads generic content
|
# Downloads generic content
|
||||||
@ -133,10 +128,6 @@ i.e.
|
|||||||
description=ned_help_msg,
|
description=ned_help_msg,
|
||||||
parameters="{关键词/id}/{login <账号> <密码>}/{clear}")
|
parameters="{关键词/id}/{login <账号> <密码>}/{clear}")
|
||||||
async def ned(context):
|
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:
|
if len(context.parameter) < 1:
|
||||||
# 使用方法
|
# 使用方法
|
||||||
await context.edit(ned_help_msg)
|
await context.edit(ned_help_msg)
|
||||||
|
@ -3,19 +3,17 @@ import requests
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
from pagermaid.listener import listener
|
from pagermaid.listener import listener
|
||||||
from os import remove, path
|
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"),
|
@listener(is_plugin=True, outgoing=True, command=alias_command("ns"),
|
||||||
description="随机网抑云热歌。")
|
description="随机网抑云热歌。")
|
||||||
async def ns(context):
|
async def ns(context):
|
||||||
await context.edit("获取中 . . .")
|
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
|
status = False
|
||||||
for _ in range(20): # 最多尝试20次
|
for _ in range(20): # 最多尝试20次
|
||||||
req = requests.get(
|
req = requests.get(
|
||||||
@ -49,14 +47,13 @@ async def ns(context):
|
|||||||
cap = artist + " - " + title
|
cap = artist + " - " + title
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
if imported is True:
|
tag = eyed3.load(name).tag
|
||||||
tag = eyed3.load(name).tag
|
tag.encoding = '\x01'
|
||||||
tag.encoding = '\x01'
|
tag.artist = artist
|
||||||
tag.artist = artist
|
tag.title = title
|
||||||
tag.title = title
|
tag.album = album
|
||||||
tag.album = album
|
tag.images.set(3, albumpic.content, "image/jpeg", u'')
|
||||||
tag.images.set(3, albumpic.content, "image/jpeg", u'')
|
tag.save()
|
||||||
tag.save()
|
|
||||||
await context.client.send_file(
|
await context.client.send_file(
|
||||||
context.chat_id,
|
context.chat_id,
|
||||||
name,
|
name,
|
||||||
|
17
pl.py
17
pl.py
@ -2,19 +2,15 @@
|
|||||||
|
|
||||||
# By tg @lowking0415
|
# By tg @lowking0415
|
||||||
# extra requirements: bs4
|
# extra requirements: bs4
|
||||||
|
|
||||||
imported = True
|
|
||||||
|
|
||||||
try:
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
except ImportError:
|
|
||||||
imported = False
|
|
||||||
|
|
||||||
from asyncio import sleep
|
from asyncio import sleep
|
||||||
from requests import get
|
from requests import get
|
||||||
from sys import executable
|
from sys import executable
|
||||||
from pagermaid.listener import listener
|
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
|
from urllib import parse
|
||||||
|
|
||||||
|
|
||||||
@ -22,9 +18,6 @@ from urllib import parse
|
|||||||
description="输入【-pl 食物名】查询食物嘌呤含量",
|
description="输入【-pl 食物名】查询食物嘌呤含量",
|
||||||
parameters="<食物名>")
|
parameters="<食物名>")
|
||||||
async def pl(context):
|
async def pl(context):
|
||||||
if not imported:
|
|
||||||
await context.edit(f"请先安装依赖:\n`{executable} -m pip install bs4`\n随后,请重启 pagermaid。")
|
|
||||||
return
|
|
||||||
action = context.arguments.split()
|
action = context.arguments.split()
|
||||||
status = False
|
status = False
|
||||||
if len(action) == 1:
|
if len(action) == 1:
|
||||||
|
19
sendat.py
19
sendat.py
@ -2,20 +2,16 @@
|
|||||||
|
|
||||||
# By tg @fruitymelon
|
# By tg @fruitymelon
|
||||||
# extra requirements: dateparser
|
# extra requirements: dateparser
|
||||||
|
|
||||||
imported = True
|
|
||||||
|
|
||||||
import sys, time, traceback
|
import sys, time, traceback
|
||||||
|
|
||||||
try:
|
|
||||||
import dateparser
|
|
||||||
except ImportError:
|
|
||||||
imported = False
|
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from pagermaid import log
|
from pagermaid import log
|
||||||
from pagermaid.listener import listener
|
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
|
DAY_SECS = 24 * 60 * 60
|
||||||
|
|
||||||
@ -86,9 +82,6 @@ async def sendat(context):
|
|||||||
mem.append("[NULL]")
|
mem.append("[NULL]")
|
||||||
chat = await context.get_chat()
|
chat = await context.get_chat()
|
||||||
args = " ".join(context.parameter).split("|")
|
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}")
|
await context.edit(f"debug: tz data: {time.timezone} {time.tzname} {sign}{offset}")
|
||||||
if len(args) != 2:
|
if len(args) != 2:
|
||||||
if args[0].find("rm ") == 0:
|
if args[0].find("rm ") == 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user