Merge branch 'master' into master

This commit is contained in:
Pentacene 2021-03-21 15:39:16 +08:00 committed by GitHub
commit 975d5b0845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 2279 additions and 318 deletions

34
.github/workflows/python beta.yml vendored Normal file
View File

@ -0,0 +1,34 @@
name: Github Beta commit to telegram
on:
push:
branches:
- beta
jobs:
build:
runs-on: ubuntu-latest
steps:
# 此步骤使用 GitHub 的 https://github.com/actions/checkout
- name: checkout actions
uses: actions/checkout@v1
# 设置python环境
# 此步骤使用 GitHub 的 https://github.com/actions/setup-python
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
# 安装依赖
- name: Install dependencies
run: |
mkdir tmp && cd tmp
python -m pip install --upgrade pip
pip install requests
# 发送通知
- name: Send notice
run: |
cd tmp
cp ../telegram_update_beta.py ./
python telegram_update_beta.py ${{ secrets.TG_BOT_TOKEN }}

View File

@ -23,9 +23,13 @@ jobs:
# 安装依赖 # 安装依赖
- name: Install dependencies - name: Install dependencies
run: | run: |
mkdir tmp && cd tmp
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install requests pip install requests
# 发送通知 # 发送通知
- name: Send notice - name: Send notice
run: python telegram_update.py ${{ secrets.TG_BOT_TOKEN }} run: |
cd tmp
cp ../telegram_update.py ./
python telegram_update.py ${{ secrets.TG_BOT_TOKEN }}

View File

@ -56,22 +56,38 @@
- `denyu` : 在某群中强制禁言某用户。 - `denyu` : 在某群中强制禁言某用户。
- `nthmsg` : 获取你发送的第 n 条消息。 - `nthmsg` : 获取你发送的第 n 条消息。
- `portball` : 回复你要临时禁言的人的消息来实现XX秒的禁言。 - `portball` : 回复你要临时禁言的人的消息来实现XX秒的禁言。
- `da` : 删除所有信息。
- `diss` : 祖安对线语录。
- `shangliu` : 上流对话工具。
- `killallmembers` : 一键扬了群。
- `aff` : 光速发Aff信息。
- `stickertopic` : 贴纸转图片。
- `vip` : vip 捐赠用户功能。
- `calculator` : 小型计算器。
- `paolu` : 一键跑路(删所有消息并禁言)。
- `keyword` : 群组关键词自动回复插件。
- `msgst` : 每天定时发送消息。
- profile (资料类) - profile (资料类)
- `autochangename` : 自动更新 last_name 为时间等。 - `autochangename` : 自动更新 last_name 为时间等。
- `throwit` : 生成一张 扔头像 图片。 - `throwit` : 生成一张 扔头像 图片。
- `mjx` : 随机带评价买家秀,随机涩气买家秀。
- `eat` : 生成一张 吃头像 图片。 - `eat` : 生成一张 吃头像 图片。
- `mjx` : 随机发一张淘宝买家秀
- daily (便民类) - daily (便民类)
- `weather` : 查询天气。 - `weather` : 查询天气。
- `xtao-some` : 一大堆便民功能。 - `xtao-some` : 一大堆便民功能。
- `yb-dl` : 上传 Youtube、Bilibili 视频到 telegram。 - `yb-dl` : 上传 Youtube、Bilibili 视频到 telegram。
- `rate` : 汇率转换。 - `rate` : 汇率转换。
- `netease` : 网易云热评。 - `netease` : 随机一条网易云音乐热评。
- `hyperlink` : 生成隐藏链接。 - `hyperlink` : 生成隐藏链接。
- `whois` : 查询域名信息 - `resou` : 微博知乎抖音实时热搜B站实时排行榜。
- `resou` : 知乎,抖音,微博实时热搜 - `tel` : 查询手机号码归属地等信息。
- `tel` : 查询手机号码归属地等信息 - `whois` : 查询域名whois信息。
- `neteaseshuffle` : 随即一首网易云热门曲目 - `cosplay-multi` : 多网站随机获取Cos图。
- `neteasemusic` : 发送一首来自网易云的音乐 - `meizi` : 多网站随机获取写真。
- `shangliu` : 彩虹屁生成器,毒鸡汤生成器,营销号生成器 - `acg-multi` : 多网站随机获取ACG图。
- `diss` : 祖安语言生成器 - `neteaseshuffle` : 随机网抑热歌。
- `neteasemusic` : 网易云搜歌/随机热歌/点歌。
- `videodl` : 下载YTB/B站视频。
- `transfer` : 上传和下载文件。
- `xjj` : 随机小姐姐写真。
- `zpr` : 随机小姐姐或纸片人写真。

4
aff.py
View File

@ -10,7 +10,7 @@ from pagermaid.listener import listener
async def aff(context): async def aff(context):
if not context.parameter: #发送aff信息 if not context.parameter: #发送aff信息
try: try:
with open("plugins/AffExtra/aff.txt", "r") as f: with open("plugins/AffExtra/aff.txt", "r", encoding="UTF-8") as f:
msg = f.read() msg = f.read()
except: except:
msg = "" msg = ""
@ -31,7 +31,7 @@ async def aff(context):
msg = reply.message msg = reply.message
if not exists("plugins/AffExtra"): if not exists("plugins/AffExtra"):
mkdir("plugins/AffExtra") mkdir("plugins/AffExtra")
with open("plugins/AffExtra/aff.txt", "w") as f: with open("plugins/AffExtra/aff.txt", "w", encoding="UTF-8") as f:
f.write(msg) f.write(msg)
await context.edit("好耶 Aff信息保存成功。") await context.edit("好耶 Aff信息保存成功。")
sleep(3) sleep(3)

2
eat.py
View File

@ -48,7 +48,7 @@ async def eat(context):
await context.edit("正在生成 吃头像 图片中 . . .") await context.edit("正在生成 吃头像 图片中 . . .")
if context.reply_to_msg_id: if context.reply_to_msg_id:
reply_message = await context.get_reply_message() reply_message = await context.get_reply_message()
user_id = reply_message.from_id user_id = reply_message.sender_id
target_user = await context.client(GetFullUserRequest(user_id)) target_user = await context.client(GetFullUserRequest(user_id))
if len(context.parameter) == 1: if len(context.parameter) == 1:
diu_round = True diu_round = True

34
forcesend.py Normal file
View File

@ -0,0 +1,34 @@
""" 在不进群的情况下,向频道的附属群内强制发送消息。 """
# By tg @fruitymelon
from pagermaid import log
from pagermaid.listener import listener
helpmsg = """在不进群的情况下,强制向频道的附属群内发送消息。需要事先关注频道。
用法`-forcesend 消息内容`
本插件用途狭窄主要用于让别人以为你在群里该群必须是频道的附属群且你必须已经关注了对应的频道
在该频道的任意一条消息的评论区发送 `-forcesend 消息内容`即可强行将文字发送到附属群内但不出现在原频道消息的评论区中
在普通群内使用 -forcesend 效果与直接发送消息基本没有区别因此不做特殊判断
"""
async def sendmsg(context, chat, origin_text):
text = origin_text.strip()
msg = await context.client.send_message(chat, text)
return msg
@listener(is_plugin=True, outgoing=True, command="forcesend", diagnostics=True, ignore_edited=True,
description=helpmsg,
parameters="<text>")
async def forcesend(context):
if not context.parameter:
await context.edit(helpmsg)
return
chat = await context.get_chat()
text = " ".join(context.parameter)
await context.delete()
await sendmsg(context, chat, text)
return

41
ghs.py Normal file
View File

@ -0,0 +1,41 @@
import random
from time import sleep
from requests import get
from pagermaid.listener import listener
from os import remove
@listener(is_plugin=True, outgoing=True, command="ghs",
description="随机获取涩情写真")
async def ghs(context):
await context.edit("搞颜色中 . . .")
status = False
for _ in range (20): #最多重试20次
website = random.randint(0,0)
filename = "ghs" + str(random.random())[2:] + ".png"
try:
if website == 0:
img = get("https://se.jiba.xyz/api.php")
if img.status_code == 200:
with open(filename, 'wb') as f:
f.write(img.content)
await context.edit("传颜色中 . . .")
await context.client.send_file(context.chat_id,filename,caption="#NSFW ⚠️色图警告⚠️")
status = True
break #成功了就赶紧结束啦!
except:
try:
remove(filename)
except:
pass
continue
try:
remove(filename)
except:
pass
try:
await context.delete()
except:
pass
if not status:
await context.client.send_message(context.chat_id,"出错了呜呜呜 ~ 试了好多好多次都无法访问到服务器(没有颜色搞啦!) 。")

1047
keyword.py Normal file

File diff suppressed because it is too large Load Diff

356
keyword_func/advanced.py Normal file
View File

@ -0,0 +1,356 @@
import re, time, asyncio, requests, os, json
from io import BytesIO
from os import path, mkdir, remove, makedirs, chdir
from shutil import copyfile, move, rmtree
from uuid import uuid4
from base64 import b64encode, b64decode
from importlib import import_module
from pagermaid import bot, redis, log, redis_status, working_dir
from pagermaid.listener import listener
msg_freq = 1
group_last_time = {}
read_context = {}
def is_num(x: str):
try:
x = int(x)
return isinstance(x, int)
except ValueError:
return False
def encode(s: str):
return str(b64encode(s.encode('utf-8')), 'utf-8')
def decode(s: str):
return str(b64decode(s.encode('utf-8')), 'utf-8')
def random_str():
return str(uuid4()).replace('-', '')
def parse_rules(rules: str):
n_rules = {}
rules_parse = rules.split(";")
for p in rules_parse:
d = p.split(":")
if len(d) == 2:
key = decode(d[0])
value = decode(d[1])
n_rules[key] = value
return n_rules
def save_rules(rules: dict, placeholder: str):
n_rules = ""
for k, v in rules.items():
if placeholder:
k = k.replace(placeholder, "'")
v = v.replace(placeholder, "'")
n_rules += encode(k) + ":" + encode(v) + ";"
return n_rules
def validate(user_id: str, mode: int, user_list: list):
if mode == 0:
return user_id not in user_list
elif mode == 1:
return user_id in user_list
else:
return False
def get_redis(db_key: str):
byte_data = redis.get(db_key)
byte_data = byte_data if byte_data else b""
byte_data = str(byte_data, "ascii")
return parse_rules(byte_data)
def parse_multi(rule: str):
sep_ph = random_str()
col_ph = random_str()
rule = rule.replace(r"\||", sep_ph)
rule = rule.replace(r"\::", col_ph)
rule = rule.split("||")
n_rule = []
for r in rule:
p = r.split("::")
p = [i.replace(sep_ph, "||") for i in p]
p = [i.replace(col_ph, "::") for i in p]
data = ['plain', '']
if len(p) == 2:
data = p
else:
data[1] = p[0]
n_rule.append(data)
return n_rule
def get_capture(search_data, group_name: str):
try:
capture_data = search_data.group(group_name)
return capture_data
except:
return None
def get_rule(chat_id, rule_type, rule_index):
rule_index = int(rule_index)
rule_data = get_redis(f"keyword.{chat_id}.{rule_type}")
index = 0
for k in rule_data.keys():
if index == rule_index:
return encode(k)
index += 1
return None
def valid_time(chat_id):
global msg_freq, group_last_time
cus_freq = get_redis(f"keyword.{chat_id}.settings").get("freq", msg_freq)
try:
cus_freq = float(cus_freq)
except:
cus_freq = msg_freq
n_time = time.time()
chat_id = int(chat_id)
if chat_id in group_last_time:
if n_time - group_last_time[chat_id] >= cus_freq:
return True
else:
return False
else:
return True
def has_cache(chat_id, mode, trigger, filename):
basepath = f"data/keyword_cache/{chat_id}/{mode}:{encode(trigger)}"
filepath = f"{basepath}/{filename}"
if not path.exists(basepath):
makedirs(basepath)
return (False, filepath)
if not path.exists(filepath):
return (False, filepath)
return (True, filepath)
def cache_opened(chat_id, mode, trigger):
rule_data = get_redis(f"keyword.{chat_id}.single"
f".{mode}.{encode(trigger)}").get("cache", None)
chat_data = get_redis(f"keyword.{chat_id}.settings").get("cache", None)
global_data = get_redis("keyword.settings").get("cache", None)
if rule_data:
return True if rule_data == "1" else False
elif chat_data:
return True if chat_data == "1" else False
elif global_data:
return True if global_data == "1" else False
return False
async def del_msg(context, t_lim):
await asyncio.sleep(t_lim)
try:
await context.delete()
except:
pass
async def send_reply(chat_id, trigger, mode, reply_msg, context):
try:
real_chat_id = chat_id
chat = context.chat
sender = context.sender
replace_data = {}
if chat_id < 0:
replace_data = {
"chat_id": chat.id,
"chat_name": chat.title
}
if sender:
replace_data["user_id"] = sender.id
replace_data["first_name"] = sender.first_name
replace_data["last_name"] = sender.last_name if sender.last_name else ""
else:
replace_data["user_id"] = chat_id
if sender:
replace_data["first_name"] = sender.first_name
replace_data["last_name"] = sender.last_name if sender.last_name else ""
if chat:
replace_data["chat_id"] = chat.id
last_name = chat.last_name
if not last_name:
last_name = ""
replace_data["chat_name"] = f"{chat.first_name} {last_name}"
update_last_time = False
could_send_msg = valid_time(chat_id)
for re_type, re_msg in reply_msg:
try:
for k, v in replace_data.items():
re_type = re_type.replace(f"${k}", str(v))
re_msg = re_msg.replace(f"${k}", str(v))
type_parse = re_type.split(",")
type_parse = [(p[4:] if p[0:3] == "adv" else "") for p in type_parse]
for s in type_parse:
if len(s) >= 5 and "ext_" == s[0:4] and is_num(s[4:]):
chat_id = int(s[4:])
type_parse.remove(s)
break
if ("file" in type_parse or "photo" in type_parse) and len(re_msg.split()) >= 2:
if could_send_msg:
update_last_time = True
re_data = re_msg.split(" ")
cache_exists, cache_path = has_cache(chat_id, mode, trigger, re_data[0])
is_opened = cache_opened(chat_id, mode, trigger)
filename = "/tmp/" + re_data[0]
if is_opened:
filename = cache_path
if not cache_exists:
if re_data[1][0:7] == "file://":
re_data[1] = re_data[1][7:]
copyfile(" ".join(re_data[1:]), filename)
else:
fileget = requests.get(" ".join(re_data[1:]))
with open(filename, "wb") as f:
f.write(fileget.content)
else:
if re_data[1][0:7] == "file://":
re_data[1] = re_data[1][7:]
copyfile(" ".join(re_data[1:]), filename)
else:
fileget = requests.get(" ".join(re_data[1:]))
with open(filename, "wb") as f:
f.write(fileget.content)
reply_to = None
if "reply" in type_parse:
reply_to = context.id
await bot.send_file(chat_id, filename,
reply_to=reply_to, force_document=("file" in type_parse))
if not is_opened:
remove(filename)
elif ("tgfile" in type_parse or "tgphoto" in type_parse) and len(re_msg.split()) >= 2:
if could_send_msg:
update_last_time = True
if not path.exists("/tmp"):
mkdir("/tmp")
re_data = re_msg.split()
file_name = "/tmp/" + re_data[0]
_data = BytesIO()
re_data[1] = re_data[1].split("/")[-2:]
try:
msg_chat_id = int(re_data[1][0])
except:
async with bot.conversation(re_data[1][0]) as conversation:
msg_chat_id = conversation.chat_id
msg_id_inchat = int(re_data[1][1])
await bot.send_message(chat_id, f"{msg_chat_id, msg_id_inchat}")
media_msg = (await bot.get_messages(msg_chat_id, msg_id_inchat))[0]
_data = BytesIO()
if media_msg and media_msg.media:
if "tgfile" in type_parse:
await bot.download_file(media_msg.media.document, _data)
else:
await bot.download_file(media_msg.photo, _data)
with open(file_name, "wb") as f:
f.write(_data.getvalue())
reply_to = None
if "reply" in type_parse:
reply_to = context.id
await bot.send_file(chat_id, file_name, reply_to=reply_to,
force_document=("tgfile" in type_parse))
remove(file_name)
elif "plain" in type_parse:
if could_send_msg:
update_last_time = True
await bot.send_message(chat_id, re_msg,
link_preview=("nopreview" not in type_parse))
elif "reply" in type_parse and chat_id == real_chat_id:
if could_send_msg:
update_last_time = True
await bot.send_message(chat_id, re_msg, reply_to=context.id,
link_preview=("nopreview" not in type_parse))
elif "op" in type_parse:
if re_msg == "delete":
await context.delete()
elif re_msg.split()[0] == "sleep" and len(re_msg.split()) == 2:
sleep_time = re_msg.split()[1]
await asyncio.sleep(float(sleep_time))
except:
pass
chat_id = real_chat_id
if update_last_time:
global group_last_time
group_last_time[int(chat_id)] = time.time()
except:
pass
async def main(context):
if not redis_status():
return
try:
chat_id = context.chat_id
sender_id = context.sender_id
if f"{chat_id}:{context.id}" not in read_context:
plain_dict = get_redis(f"keyword.{chat_id}.plain")
regex_dict = get_redis(f"keyword.{chat_id}.regex")
g_settings = get_redis("keyword.settings")
n_settings = get_redis(f"keyword.{chat_id}.settings")
g_mode = g_settings.get("mode", None)
n_mode = n_settings.get("mode", None)
mode = "0"
g_list = g_settings.get("list", None)
n_list = n_settings.get("list", None)
user_list = []
if g_mode and n_mode:
mode = n_mode
elif g_mode or n_mode:
mode = g_mode if g_mode else n_mode
if g_list and n_list:
user_list = n_list
elif g_list or n_list:
user_list = g_list if g_list else n_list
send_text = context.text
if not send_text:
send_text = ""
for k, v in plain_dict.items():
if k in send_text:
tmp = get_redis(f"keyword.{chat_id}.single.plain.{encode(k)}")
could_reply = validate(str(sender_id), int(mode), user_list)
if tmp:
could_reply = validate(str(sender_id), int(tmp.get("mode", "0")), tmp.get("list", []))
if could_reply:
read_context[f"{chat_id}:{context.id}"] = None
await send_reply(chat_id, k, "plain", parse_multi(v), context)
for k, v in regex_dict.items():
pattern = re.compile(k)
if pattern.search(send_text):
tmp = get_redis(f"keyword.{chat_id}.single.regex.{encode(k)}")
could_reply = validate(str(sender_id), int(mode), user_list)
if tmp:
could_reply = validate(str(sender_id), int(tmp.get("mode", "0")), tmp.get("list", []))
if could_reply:
read_context[f"{chat_id}:{context.id}"] = None
catch_pattern = r"\$\{regex_(?P<str>((?!\}).)+)\}"
count = 0
while re.search(catch_pattern, v) and count < 20:
search_data = re.search(k, send_text)
group_name = re.search(catch_pattern, v).group("str")
capture_data = get_capture(search_data, group_name)
if not capture_data:
capture_data = ""
if re.search(catch_pattern, capture_data):
capture_data = ""
v = v.replace("${regex_%s}" % group_name, capture_data)
count += 1
await send_reply(chat_id, k, "regex", parse_multi(v), context)
else:
del read_context[f"{chat_id}:{context.id}"]
except:
pass
return ""

1
keyword_func/list.json Normal file
View File

@ -0,0 +1 @@
{"list": ["ranstr", "newkeyword", "advanced", "maf"]}

33
keyword_func/maf.py Normal file
View File

@ -0,0 +1,33 @@
from asyncio import sleep
async def del_msg(context, t):
await sleep(t)
try:
await context.delete()
except:
pass
async def main(context, text, tgurl, mode=0, re=1, t=-1):
ids = tgurl.split("/")[-2:]
try:
ids[0] = int(ids[0])
except:
async with context.client.conversation(ids[0]) as conv:
ids[0] = conv.chat_id
message = await context.client.get_messages(ids[0], ids=int(ids[1]))
re_id = context.id
if message.photo:
data = message.photo
else:
data = message.media.document
if context.is_reply:
me = await context.client.get_me()
if context.sender.id == me.id:
msg = await context.get_reply_message()
re_id = msg.id
sent = await context.client.send_message(context.chat_id, text, file=data, force_document=mode, reply_to=(re_id if re else None))
if t >= 0:
await del_msg(sent, t)
return ""

View File

@ -0,0 +1,94 @@
import json
from os import remove, mkdir
from os.path import isfile, exists
from telethon.tl.types import ChannelParticipantsAdmins
extra_path = "plugins/keyword_func/extra"
def get_data(filename):
filepath = f"{extra_path}/{filename}"
if exists(filepath):
with open(filepath, "r") as f:
data = f.read()
return data
else:
return ""
def write_data(filename, data):
filepath = f"{extra_path}/{filename}"
with open(filepath, "w") as f:
f.write(data)
def init_file(filename):
if exists(extra_path):
if isfile(extra_path):
remove(extra_path)
mkdir(extra_path)
else:
mkdir(extra_path)
if not exists(f"{extra_path}/{filename}"):
with open(f"{extra_path}/{filename}", "w") as f:
f.write("{}")
async def main(context):
try:
chat_id = context.chat_id
if chat_id < 0:
admins = await context.client.get_participants(context.chat, filter=ChannelParticipantsAdmins)
text = context.text
if not text:
text = ""
if text.split()[0] == "/add":
if context.sender in admins:
try:
parse = text.split("\n")
parse[0] = " ".join(parse[0].split()[1:])
init_file(f"newkeyword_{chat_id}.json")
data = json.loads(get_data(f"newkeyword_{chat_id}.json"))
data[parse[0]] = parse[1]
write_data(f"newkeyword_{chat_id}.json", json.dumps(data))
await context.client.send_message(chat_id, "设置成功", reply_to=context.id)
except:
await context.client.send_message(chat_id, "设置失败", reply_to=context.id)
else:
await context.client.send_message(chat_id, "您无权进行此操作", reply_to=context.id)
elif text.split()[0] == "/del":
if context.sender in admins:
try:
init_file(f"newkeyword_{chat_id}.json")
data = json.loads(get_data(f"newkeyword_{chat_id}.json"))
del data[" ".join(text.split(" ")[1:])]
write_data(f"newkeyword_{chat_id}.json", json.dumps(data))
await context.client.send_message(chat_id, "删除成功", reply_to=context.id)
except:
await context.client.send_message(chat_id, "删除失败", reply_to=context.id)
else:
await context.client.send_message(chat_id, "您无权进行此操作", reply_to=context.id)
elif text.split()[0] == "/list":
if context.sender in admins:
try:
init_file(f"newkeyword_{chat_id}.json")
data = json.loads(get_data(f"newkeyword_{chat_id}.json"))
message = ""
count = 1
for k, v in data.items():
message += f"`{count}` : `{k}` -> `{v}`\n"
count += 1
await context.client.send_message(context.sender_id, message)
await context.client.send_message(chat_id, "已发送私聊", reply_to=context.id)
except:
await context.client.send_message(chat_id, "获取失败", reply_to=context.id)
else:
await context.client.send_message(chat_id, "您无权进行此操作", reply_to=context.id)
else:
data = json.loads(get_data(f"newkeyword_{chat_id}.json"))
for k, v in data.items():
if k in text:
await context.client.send_message(chat_id, v, reply_to=context.id)
return ""
except:
return ""

14
keyword_func/ranstr.py Normal file
View File

@ -0,0 +1,14 @@
import random
import string
async def main(context):
try:
length = int(context.text.split()[1])
except:
length = 8
if length > 1000:
length = 100
s = ""
for i in range(length):
s += random.choice(string.ascii_letters + string.digits)
return f"`{s}`"

108
list.json
View File

@ -42,33 +42,33 @@
}, },
{ {
"name": "sendat", "name": "sendat",
"version": "1.2", "version": "1.3",
"section": "chat", "section": "chat",
"maintainer": "fruitymelon", "maintainer": "fruitymelon",
"size": "13.1 kb", "size": "15.0 kb",
"supported": true, "supported": true,
"des-short": "定时发送消息。", "des-short": "定时发送消息。",
"des": "这个人很懒,什么都没有留下。" "des": "命令sendat详情见 -help sendat"
}, },
{ {
"name": "weather", "name": "weather",
"version": "1.0", "version": "1.1",
"section": "daily", "section": "daily",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "1.5 kb", "size": "2.9 kb",
"supported": true, "supported": true,
"des-short": "查询天气。", "des-short": "查询天气。",
"des": "这个人很懒,什么都没有留下。" "des": "这个人很懒,什么都没有留下。"
}, },
{ {
"name": "xtao-some", "name": "xtao-some",
"version": "1.11", "version": "1.154",
"section": "daily", "section": "daily",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "18.8 kb", "size": "18.8 kb",
"supported": true, "supported": true,
"des-short": "一大堆便民功能。", "des-short": "一大堆便民功能。",
"des": "超多功能 例如 -ip -pixiv -guess 等。" "des": "超多功能 例如 -ip -ipping -guess -t -getdel 等。"
}, },
{ {
"name": "yb-dl", "name": "yb-dl",
@ -82,7 +82,7 @@
}, },
{ {
"name": "throwit", "name": "throwit",
"version": "1.6", "version": "1.61",
"section": "profile", "section": "profile",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "6.9 kb", "size": "6.9 kb",
@ -152,10 +152,10 @@
}, },
{ {
"name": "portball", "name": "portball",
"version": "1.41", "version": "1.42",
"section": "chat", "section": "chat",
"maintainer": "Pentacene", "maintainer": "Pentacene",
"size": "4.3 kb", "size": "2.8 kb",
"supported": true, "supported": true,
"des-short": "回复你要临时禁言的人的消息来实现XX秒的禁言。", "des-short": "回复你要临时禁言的人的消息来实现XX秒的禁言。",
"des": "portball <原因> <秒数>" "des": "portball <原因> <秒数>"
@ -192,7 +192,7 @@
}, },
{ {
"name": "whois", "name": "whois",
"version": "1.1", "version": "1.12",
"section": "daily", "section": "daily",
"maintainer": "KorenKrita", "maintainer": "KorenKrita",
"size": "1.1 kb", "size": "1.1 kb",
@ -202,7 +202,7 @@
}, },
{ {
"name": "eat", "name": "eat",
"version": "1.0", "version": "1.01",
"section": "profile", "section": "profile",
"maintainer": "SF_PICK", "maintainer": "SF_PICK",
"size": "6.4 kb", "size": "6.4 kb",
@ -222,7 +222,7 @@
}, },
{ {
"name": "meizi", "name": "meizi",
"version": "1.7", "version": "1.8",
"section": "daily", "section": "daily",
"maintainer": "TNTcraftHIM", "maintainer": "TNTcraftHIM",
"size": "4.0 kb", "size": "4.0 kb",
@ -282,10 +282,10 @@
}, },
{ {
"name": "neteasemusic", "name": "neteasemusic",
"version": "4.2", "version": "4.3",
"section": "daily", "section": "daily",
"maintainer": "TNTcraftHIM", "maintainer": "TNTcraftHIM",
"size": "29.1 kb", "size": "28.8 kb",
"supported": true, "supported": true,
"des-short": "网易云搜歌/随机热歌/点歌", "des-short": "网易云搜歌/随机热歌/点歌",
"des": "可以在线搜索并且快速点歌可回复信息点歌也支持随机热歌功能支持解锁VIP/灰色歌曲。命令nem。" "des": "可以在线搜索并且快速点歌可回复信息点歌也支持随机热歌功能支持解锁VIP/灰色歌曲。命令nem。"
@ -302,7 +302,7 @@
}, },
{ {
"name": "videodl", "name": "videodl",
"version": "0.1", "version": "0.1.1",
"section": "daily", "section": "daily",
"maintainer": "TNTcraftHIM", "maintainer": "TNTcraftHIM",
"size": "5.3 kb", "size": "5.3 kb",
@ -312,7 +312,7 @@
}, },
{ {
"name": "aff", "name": "aff",
"version": "1.1", "version": "1.2",
"section": "chat", "section": "chat",
"maintainer": "TNTcraftHIM", "maintainer": "TNTcraftHIM",
"size": "2.0 kb", "size": "2.0 kb",
@ -332,13 +332,13 @@
}, },
{ {
"name": "vip", "name": "vip",
"version": "0.1", "version": "0.2",
"section": "chat", "section": "chat",
"maintainer": "xtaodada", "maintainer": "xtaodada",
"size": "4.0 kb", "size": "4.0 kb",
"supported": true, "supported": true,
"des-short": "vip 捐赠用户功能", "des-short": "vip 捐赠用户功能",
"des": "命令天气weather 。" "des": "命令天气weather Pixivpixiv与 weather 插件冲突"
}, },
{ {
"name": "calculator", "name": "calculator",
@ -369,6 +369,76 @@
"supported": true, "supported": true,
"des-short": "自动回复sticker", "des-short": "自动回复sticker",
"des": "-ars" "des": "-ars"
},
{
"name": "keyword",
"version": "2.61",
"section": "chat",
"maintainer": "c3b2a,xtaodada",
"size": "44.0 kb",
"supported": true,
"des-short": "关键词自动回复插件。",
"des": "命令: keyword, keydata, replyset, funcset。"
},
{
"name": "msgst",
"version": "1.1",
"section": "chat",
"maintainer": "c3b2a",
"size": "3.1 kb",
"supported": true,
"des-short": "每天定时发送消息",
"des": "命令: msgst, msgset。"
},
{
"name": "transfer",
"version": "1.0",
"section": "daily",
"maintainer": "c3b2a",
"size": "2.7 kb",
"supported": true,
"des-short": "上传和下载文件。",
"des": "命令: transfer"
},
{
"name": "xjj",
"version": "1.0",
"section": "daily",
"maintainer": "Moriarty-989",
"size": "1.4 kb",
"supported": true,
"des-short": "随机小姐姐写真。",
"des": "命令: xjj"
},
{
"name": "zpr",
"version": "1.0",
"section": "daily",
"maintainer": "Moriarty-989",
"size": "1.4 kb",
"supported": true,
"des-short": "随机小姐姐或纸片人写真。",
"des": "命令: xjj"
},
{
"name": "forcesend",
"version": "1.0",
"section": "chat",
"maintainer": "fruitymelon",
"size": "1.3 kb",
"supported": true,
"des-short": "无需进群,向频道附属群内发送消息",
"des": "命令forcesend"
},
{
"name": "ghs",
"version": "1.0",
"section": "chat",
"maintainer": "akun",
"size": "1.3 kb",
"supported": true,
"des-short": "发送ghs获取一张色图",
"des": "命令ghs"
} }
] ]
} }

View File

@ -21,25 +21,25 @@ async def mz(context):
elif website == 2: elif website == 2:
img = get("https://api.66mz8.com/api/rand.tbimg.php") img = get("https://api.66mz8.com/api/rand.tbimg.php")
elif website == 3: elif website == 3:
img = get("https://api.isoyu.com/mm_images.php") img = get("https://api.nmb.show/xiaojiejie2.php")
elif website == 4: elif website == 4:
img = get("https://uploadbeta.com/api/pictures/random/?key=%E5%A5%B3") img = get("https://uploadbeta.com/api/pictures/random/?key=%E5%A5%B3")
elif website == 5: elif website == 5:
img = get("https://uploadbeta.com/api/pictures/random/?key=%E5%A6%B9%E5%AD%90") img = get("https://uploadbeta.com/api/pictures/random/?key=%E5%86%85%E8%A1%A3")
elif website == 6: elif website == 6:
img = get("https://uploadbeta.com/api/pictures/random/?key=%E6%8E%A8%E5%A5%B3%E9%83%8E") img = get("https://uploadbeta.com/api/pictures/random/?key=%E6%8E%A8%E5%A5%B3%E9%83%8E")
elif website == 7: elif website == 7:
img = get("https://uploadbeta.com/api/pictures/random/?key=%E7%BE%8E%E5%A5%B3") img = get("https://tvv.tw/xjj/meinv/img-ct.php")
elif website == 8: elif website == 8:
img = get("https://api.diskgirl.com/image/api.php?t=xinggan&v=" + str(random.uniform(0, 100))) img = get("https://api.diskgirl.com/image/api.php?t=xinggan&v=" + str(random.uniform(0, 100)))
elif website == 9: elif website == 9:
img = get("https://api.lyiqk.cn/sexylady") img = get("https://api.lyiqk.cn/sexylady")
elif website == 10: elif website == 10:
img = get("https://api.pingping6.com/tools/acg3/index.php") img = get("https://tvv.tw/xjj/meinv/img.php")
elif website == 11: elif website == 11:
img = get("https://api.uomg.com/api/rand.img3") img = get("https://api.uomg.com/api/rand.img3")
elif website == 12: elif website == 12:
img = get("https://api.diskgirl.com/image/api.php?t=&v=0.9451485087333713") img = get("https://api.nmb.show/xiaojiejie1.php")
elif website == 13: elif website == 13:
img = get("https://uploadbeta.com/api/pictures/random/?key=%E6%80%A7%E6%84%9F") img = get("https://uploadbeta.com/api/pictures/random/?key=%E6%80%A7%E6%84%9F")
if img.status_code == 200: if img.status_code == 200:

83
msgst.py Normal file
View File

@ -0,0 +1,83 @@
import time, asyncio
from pagermaid import bot, redis, redis_status
from pagermaid.listener import listener
def is_num(x: str):
try:
x = int(x)
return isinstance(x, int)
except ValueError:
return False
def get_bot():
data = [1527463252, "msg_schedule_bot"]
if redis_status():
n_id = redis.get("msgst.bot_id")
n_un = redis.get("msgst.bot_un")
if n_id and is_num(str(n_id, "ascii")): data[0] = int(str(n_id, "ascii"))
if n_un: data[1] = str(n_un, "ascii")
return data
async def del_msg(context, t_lim):
await asyncio.sleep(t_lim)
await context.delete()
@listener(is_plugin=True, outgoing=True, command="msgst",
description="消息每天定时发送",
parameters="new 时:分:秒 消息` 或 `del <msg_id>` 或 `list")
async def process(context):
params = []
for p in context.parameter:
if len(p.split()) != 0:
params.append(p)
bot_data = get_bot()
if len(params) == 1 and params[0] == "bot":
await context.edit(str(bot_data))
await del_msg(context, 10)
return
if len(params) >= 3 and params[0] == "new": params.insert(2, str(context.chat_id))
async with bot.conversation(bot_data[1]) as conversation:
await conversation.send_message("/" + " ".join(params))
response = await conversation.get_response()
await bot.send_read_acknowledge(conversation.chat_id)
await context.edit(response.text)
if len(params) > 0 and params[0] != "list": await del_msg(context, 10)
@listener(is_plugin=True, outgoing=True, command="msgset",
description="定时发送 bot 服务端设置",
parameters="bot <bot_id> <bot_username>` 或 `bot clear")
async def settings(context):
if not redis_status():
await context.edit("出错了呜呜呜 ~ Redis 离线,无法运行")
await del_msg(context, 10)
return
params = []
for p in context.parameter:
if len(p.split()) != 0:
params.append(p)
if len(params) > 0 and params[0] == "bot":
if len(params) == 3 and is_num(params[1]):
redis.set("msgst.bot_id", params[1])
redis.set("msgst.bot_un", params[2])
await context.edit("设置成功")
await del_msg(context, 10)
elif len(params) == 2 and params[1] == "clear":
redis.delete("msgst.bot_id")
redis.delete("msgst.bot_un")
await context.edit("清除成功")
await del_msg(context, 10)
else:
await context.edit("参数错误")
await del_msg(context, 10)
@listener(incoming=True, ignore_edited=True)
async def sendmsg(context):
bot_data = get_bot()
if context.sender_id == bot_data[0]:
parse = context.text.split("|")
if parse[0] == "send_msg":
async with bot.conversation(bot_data[1]) as conversation:
await bot.send_read_acknowledge(conversation.chat_id)
s_time = int(time.time() + 1) - time.time()
await asyncio.sleep(s_time)
await bot.send_message(int(parse[1]), "|".join(parse[2:]))

View File

@ -28,8 +28,7 @@ async def nem(context):
proxynum = 0 proxynum = 0
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063', headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063',
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "X-Real-IP": "223.252.199.66"} "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "X-Real-IP": "223.252.199.66"}
proxy = [{'http': 'http://192.210.137.108:8080', 'https': 'http://192.210.137.108:8080'}, {'http': 'http://music.lolico.me:39000', 'https': 'http://music.lolico.me:39000'}, {'http': 'http://aimer.one:2333', proxy = [{'http': 'http://music.lolico.me:39000', 'https': 'http://music.lolico.me:39000'}, {'http': 'http://netease.unlock.feiwuis.me:6958', 'https': 'https://netease.unlock.feiwuis.me:6958'}]
'https': 'http://aimer.one:2333'}, {'http': 'http://fs2.ilogic.net.cn:5200', 'https': 'http://fs2.ilogic.net.cn:5200'}, {'http': 'http://64.64.250.246:8080', 'https': 'http://64.64.250.246:8080'}]
helptext = "**使用方法:** `-nem` `<指令>` `<关键词>`\n\n指令s为搜索p为点歌id为歌曲ID点歌r为随机热歌(无关键词)\n搜索在s后添加数字如`-nem` `s8` `<关键词>`调整结果数量\n搜索灰色歌曲请尽量**指定歌手**\n可回复搜索结果消息`-nem` `p` `<歌曲数字序号>`点歌" helptext = "**使用方法:** `-nem` `<指令>` `<关键词>`\n\n指令s为搜索p为点歌id为歌曲ID点歌r为随机热歌(无关键词)\n搜索在s后添加数字如`-nem` `s8` `<关键词>`调整结果数量\n搜索灰色歌曲请尽量**指定歌手**\n可回复搜索结果消息`-nem` `p` `<歌曲数字序号>`点歌"
apifailtext = "出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器 。" apifailtext = "出错了呜呜呜 ~ 试了好多好多次都无法访问到 API 服务器 。"

View File

@ -5,25 +5,20 @@ from asyncio import sleep
from datetime import timedelta from datetime import timedelta
from telethon.tl.types import ChannelParticipantsAdmins from telethon.tl.types import ChannelParticipantsAdmins
@listener(is_plugin=True, outgoing=True, command="portball",
@listener(is_plugin=True, outgoing=True, incoming=True, command="portball",
description="回复你要临时禁言的人的消息来实现XX秒的禁言", description="回复你要临时禁言的人的消息来实现XX秒的禁言",
parameters="<理由>(空格)<时间/秒>") parameters="<理由>(空格)<时间/秒>")
async def portball(context): async def portball(context):
if context.is_group: if context.is_group:
admins = await context.client.get_participants(context.chat, filter=ChannelParticipantsAdmins)
reply = await context.get_reply_message() reply = await context.get_reply_message()
# if message sender is one of admins or group anonymous bot
if (context.sender in admins) or (context.sender_id == 1087968824):
# if this msg reply to a message
if reply: if reply:
action = context.arguments.split() action = context.arguments.split()
# get sender's last_name
if reply.sender.last_name == None: if reply.sender.last_name == None:
last_name='' last_name=''
else: else:
last_name = reply.sender.last_name last_name = reply.sender.last_name
# if something wrong with the command
if len(action) < 2: if len(action) < 2:
notification = await bot.send_message(context.chat_id, '格式是\n-portball 理由 秒数\n真蠢', reply_to = context.id) notification = await bot.send_message(context.chat_id, '格式是\n-portball 理由 秒数\n真蠢', reply_to = context.id)
await sleep(10) await sleep(10)
@ -33,7 +28,6 @@ async def portball(context):
except: except:
pass pass
return False return False
# if time of portball less than 60 seconds
if int(action[1]) < 60: if int(action[1]) < 60:
notification = await bot.send_message(context.chat_id, '诶呀不要小于60秒啦', reply_to = context.id) notification = await bot.send_message(context.chat_id, '诶呀不要小于60秒啦', reply_to = context.id)
await sleep(10) await sleep(10)
@ -43,7 +37,6 @@ async def portball(context):
except: except:
pass pass
return False return False
# portball
try: try:
await bot.edit_permissions(context.chat_id, reply.sender.id, timedelta(seconds=int(action[1].replace(' ',''))), send_messages=False, send_media=False, send_stickers=False, send_gifs=False, send_games=False, send_inline=False, send_polls=False, invite_users=False, change_info=False, pin_messages=False) await bot.edit_permissions(context.chat_id, reply.sender.id, timedelta(seconds=int(action[1].replace(' ',''))), send_messages=False, send_media=False, send_stickers=False, send_gifs=False, send_games=False, send_inline=False, send_polls=False, invite_users=False, change_info=False, pin_messages=False)
portball_message = await bot.send_message( portball_message = await bot.send_message(
@ -63,15 +56,10 @@ async def portball(context):
notification = await bot.send_message(context.chat_id, '错误:我没有管理员权限或我的权限比被封禁的人要小', reply_to = context.id) notification = await bot.send_message(context.chat_id, '错误:我没有管理员权限或我的权限比被封禁的人要小', reply_to = context.id)
await sleep(10) await sleep(10)
await notification.delete() await notification.delete()
# if not reply to any message
else: else:
notification = await bot.send_message(context.chat_id, '你好蠢诶,都没有回复人,我哪知道你要搞谁的事情……', reply_to = context.id) notification = await bot.send_message(context.chat_id, '你好蠢诶,都没有回复人,我哪知道你要搞谁的事情……', reply_to = context.id)
await sleep(10) await sleep(10)
await notification.delete() await notification.delete()
# if sender is not admin
else:
return
else: else:
notification = await bot.send_message(context.chat_id, '你好蠢诶,又不是群组,怎么禁言啦!', reply_to = context.id) notification = await bot.send_message(context.chat_id, '你好蠢诶,又不是群组,怎么禁言啦!', reply_to = context.id)
await sleep(10) await sleep(10)
@ -80,3 +68,4 @@ async def portball(context):
await context.delete() await context.delete()
except: except:
pass pass

View File

@ -5,7 +5,7 @@
imported = True imported = True
import os, sys, time, traceback import sys, time, traceback
try: try:
import dateparser import dateparser
@ -15,9 +15,8 @@ except ImportError:
import asyncio import asyncio
from pagermaid import log from pagermaid import log
from pagermaid.listener import listener from pagermaid.listener import listener
from datetime import datetime
from dateutil import parser
DAY_SECS = 24 * 60 * 60
def logsync(message): def logsync(message):
sys.stdout.writelines(f"{message}\n") sys.stdout.writelines(f"{message}\n")
@ -81,9 +80,9 @@ async def sendat(context):
chat = await context.get_chat() chat = await context.get_chat()
args = " ".join(context.parameter).split("|") args = " ".join(context.parameter).split("|")
if not imported: if not imported:
await context.edit("Please install dateparser first: python3 -m pip install dateparser\nAnd restart your pagermaid process") await context.edit("请先安装依赖:`python3 -m pip install dateparser`\n随后,请重启 pagermaid。")
return return
await context.edit(f"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:
# clear timer # clear timer
@ -92,7 +91,7 @@ async def sendat(context):
if target_id.isnumeric(): if target_id.isnumeric():
if len(mem) > int(target_id): if len(mem) > int(target_id):
mem[int(target_id)] = "" mem[int(target_id)] = ""
await context.edit(f"id {target_id} removed.") await context.edit(f"id {target_id} successfully removed.")
else: else:
await context.edit("id out of range.") await context.edit("id out of range.")
return return
@ -112,26 +111,35 @@ async def sendat(context):
time_str = args[0][6:] time_str = args[0][6:]
if time_str.find(":") != -1: if time_str.find(":") != -1:
# then it should be absolute time # then it should be absolute time
sleep_times = [abs(dateparser.parse(time_str, settings=settings).timestamp() - time.time()), 24 * 60 * 60] target = dateparser.parse(time_str, settings=settings).timestamp() % DAY_SECS
index = 0 if target >= DAY_SECS - 6:
# 太接近午夜,小概率直接 sleep 过头,特殊处理
target = 0
mem[mem_id] = "|".join(args) mem[mem_id] = "|".join(args)
await sendmsg(context, chat, f"{args[0]} -> {target} sec after 00:00:00 UTC+0")
await context.edit(f"Registered: id {mem_id}. You can use this id to cancel the timer.") await context.edit(f"Registered: id {mem_id}. You can use this id to cancel the timer.")
while True and mem[mem_id] != "": last_sent = 0
last_time = time.time() while mem[mem_id] != "":
while time.time() < last_time + sleep_times[index] and mem[mem_id] != "": if time.time() % DAY_SECS < target:
# 时间没到
await asyncio.sleep(2) await asyncio.sleep(2)
continue
if time.time() % DAY_SECS >= target and time.time() - last_sent < DAY_SECS - 10:
# 时间过了,第二天的没到
await asyncio.sleep(2)
continue
if mem[mem_id] != "": if mem[mem_id] != "":
await sendmsg(context, chat, args[1]) await sendmsg(context, chat, args[1])
index = 1 last_sent = time.time()
mem[mem_id] = "" mem[mem_id] = ""
return return
sleep_time = abs(dateparser.parse(time_str, settings=settings).timestamp() - time.time()) sleep_time = time.time() - dateparser.parse(time_str, settings=settings).timestamp()
if sleep_time < 5: if sleep_time < 5:
await context.edit(f"Sleep time too short. Should be longer than 5 seconds. Got {sleep_time}") await context.edit(f"Sleep time too short. Should be longer than 5 seconds. Got {sleep_time}")
return return
mem[mem_id] = "|".join(args) mem[mem_id] = "|".join(args)
await context.edit(f"Registered: id {mem_id}. You can use this id to cancel the timer.") await context.edit(f"Registered: id {mem_id}. You can use this id to cancel the timer.")
while True and mem[mem_id] != "": while mem[mem_id] != "":
last_time = time.time() last_time = time.time()
while time.time() < last_time + sleep_time and mem[mem_id] != "": while time.time() < last_time + sleep_time and mem[mem_id] != "":
await asyncio.sleep(2) await asyncio.sleep(2)
@ -144,22 +152,32 @@ async def sendat(context):
rest = " ".join(args[0][1:].split(" ")[1:]) rest = " ".join(args[0][1:].split(" ")[1:])
if rest.find(":") != -1: if rest.find(":") != -1:
# then it should be absolute time # then it should be absolute time
sleep_times = [abs(dateparser.parse(rest, settings=settings).timestamp() - time.time()), 24 * 60 * 60] target = dateparser.parse(rest, settings=settings).timestamp() % DAY_SECS
if target >= DAY_SECS - 6:
# 太接近午夜,小概率直接 sleep 过头,特殊处理
target = 0
count = 0 count = 0
mem[mem_id] = "|".join(args) mem[mem_id] = "|".join(args)
await context.edit(f"Registered: id {mem_id}. You can use this id to cancel the timer.") await context.edit(f"Registered: id {mem_id}. You can use this id to cancel the timer.")
last_sent = 0
while count <= times and mem[mem_id] != "": while count <= times and mem[mem_id] != "":
last_time = time.time() if time.time() % DAY_SECS < target:
while time.time() < last_time + sleep_times[0 if count == 0 else 1] and mem[mem_id] != "": # 时间没到
await asyncio.sleep(2) await asyncio.sleep(2)
continue
if time.time() % DAY_SECS >= target and time.time() - last_sent < DAY_SECS - 10:
# 时间过了,第二天的没到
await asyncio.sleep(2)
continue
if mem[mem_id] != "": if mem[mem_id] != "":
await sendmsg(context, chat, args[1]) await sendmsg(context, chat, args[1])
count += 1 count += 1
last_sent = time.time()
mem[mem_id] = "" mem[mem_id] = ""
return return
sleep_time = abs(dateparser.parse(rest, settings=settings).timestamp() - time.time()) sleep_time = time.time() - dateparser.parse(rest, settings=settings).timestamp()
if sleep_time < 5: if sleep_time < 5:
await context.edit("Sleep time too short. Should be longer than 5 seconds.") await context.edit(f"Sleep time too short. Should be longer than 5 seconds. got {sleep_time}")
return return
count = 0 count = 0
mem[mem_id] = "|".join(args) mem[mem_id] = "|".join(args)
@ -191,15 +209,14 @@ async def sendat(context):
return return
# absolute time # absolute time
dt = parser.parse(args[0]) target_time = dateparser.parse(args[0], settings=settings).timestamp()
delta = dt.timestamp() - time.time() if target_time - time.time() < 3:
if delta < 3:
await context.edit("Target time before now.") await context.edit("Target time before now.")
return return
mem[mem_id] = "|".join(args) mem[mem_id] = "|".join(args)
await context.edit(f"Registered: id {mem_id}. You can use this id to cancel the timer.") await context.edit(f"Registered: id {mem_id}. You can use this id to cancel the timer.")
while delta > 0 and mem[mem_id] != "": while target_time - time.time() > 0 and mem[mem_id] != "":
delta = dt.timestamp() - time.time()
await asyncio.sleep(2) await asyncio.sleep(2)
if mem[mem_id] != "": if mem[mem_id] != "":
await sendmsg(context, chat, args[1]) await sendmsg(context, chat, args[1])

View File

@ -3,14 +3,11 @@ from requests import get, post
token = str(sys.argv[1]) token = str(sys.argv[1])
main = json.loads(get("https://api.github.com/repos/xtaodada/PagerMaid_Plugins/commits/master").content) main = json.loads(get("https://api.github.com/repos/xtaodada/PagerMaid_Plugins/commits/master").content)
push_content = {} text = "#更新日志 #" + main['commit']['author']['name'].replace('_', '') + \
push_content['chat_id'] = '-1001441461877' ' \n\n🔨 [' + main['sha'][0:7] + '](https://github.com/Xtao-Labs/PagerMaid_Plugins/commit/' + \
push_content['disable_web_page_preview'] = 'True' main['sha'] + '): ' + main['commit']['message']
push_content['parse_mode'] = 'markdown' push_content = {'chat_id': '-1001441461877', 'disable_web_page_preview': 'True', 'parse_mode': 'markdown',
push_content['text'] = "#更新日志 #" + main['commit']['author'][ 'text': text}
'name'].replace('_', '') + ' \n\n🔨 [' + main['sha'][0:7] + '](https://github.com/xtaodada/PagerMaid_Plugins/compare/' + \
main[
'sha'] + '): ' + main['commit']['message']
url = 'https://api.telegram.org/bot' + token + '/sendMessage' url = 'https://api.telegram.org/bot' + token + '/sendMessage'
try: try:
main_req = post(url, data=push_content) main_req = post(url, data=push_content)

22
telegram_update_beta.py Normal file
View File

@ -0,0 +1,22 @@
import json, time, sys
from requests import get, post
token = str(sys.argv[1])
main = json.loads(get("https://api.github.com/repos/xtaodada/PagerMaid_Plugins/commits/beta").content)
text = "#更新日志 #beta #" + main['commit']['author']['name'].replace('_', '') + \
' \n\n🔨 [' + main['sha'][0:7] + '](https://github.com/Xtao-Labs/PagerMaid_Plugins/commit/' + \
main['sha'] + '): ' + main['commit']['message']
push_content = {'chat_id': '-1001441461877', 'disable_web_page_preview': 'True', 'parse_mode': 'markdown',
'text': text}
url = 'https://api.telegram.org/bot' + token + '/sendMessage'
try:
main_req = post(url, data=push_content)
except:
pass
push_content['chat_id'] = '-1001319957857'
time.sleep(1)
try:
main_req = get(url, data=push_content)
except:
pass
print(main['sha'] + " ok")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 KiB

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 254 KiB

After

Width:  |  Height:  |  Size: 199 KiB

71
transfer.py Normal file
View File

@ -0,0 +1,71 @@
import asyncio, zipfile, os
from io import BytesIO
from uuid import uuid4
from os.path import exists, isfile
from pagermaid import bot
from pagermaid.listener import listener
async def make_zip(source_dir, output_filename):
zipf = zipfile.ZipFile(output_filename, "w")
pre_len = len(os.path.dirname(source_dir))
for parent, dirnames, filenames in os.walk(source_dir):
for filename in filenames:
pathfile = os.path.join(parent, filename)
arcname = pathfile[pre_len:].strip(os.path.sep)
zipf.write(pathfile, arcname)
zipf.close()
async def del_msg(context, t_lim):
await asyncio.sleep(t_lim)
try:
await context.delete()
except:
pass
@listener(is_plugin=True, outgoing=True, command="transfer",
description="上传 / 下载文件",
parameters="upload <filepath>` 或 `download <filepath>")
async def transfer(context):
params = context.parameter
if len(params) < 2:
await context.edit("参数缺失")
await del_msg(context, 3)
return
params[1] = " ".join(params[1:])
file_list = params[1].split("\n")
chat_id = context.chat_id
if params[0] == "upload":
index = 1
for file_path in file_list:
await context.edit(f"正在上传第 {index} 个文件")
if exists(file_path):
if isfile(file_path):
await bot.send_file(chat_id, file_path, force_document=True)
else:
token = file_path.split("/")
token = token[len(token) - 1]
await make_zip(file_path, f"/tmp/{token}.zip")
await bot.send_file(chat_id, f"/tmp/{token}.zip", force_document=True)
os.remove(f"/tmp/{token}.zip")
index += 1
await context.edit("上传完毕")
await del_msg(context, 3)
elif params[0] == "download":
message = await context.get_reply_message()
if message and message.media:
_file = BytesIO()
await bot.download_file(message.media.document, _file)
if not exists(file_list[0]):
with open(file_list[0], "wb") as f:
f.write(_file.getvalue())
await context.edit(f"保存成功, 保存路径 {file_list[0]}")
await del_msg(context, 5)
else:
await context.edit("路径已存在文件")
await del_msg(context, 3)
else:
await context.edit("未回复消息或回复消息中不包含文件")
await del_msg(context, 3)
else:
await context.edit("未知命令")
await del_msg(context, 3)

View File

@ -8,7 +8,6 @@ from pagermaid import bot, log
from pagermaid.listener import listener from pagermaid.listener import listener
from telethon.tl.types import DocumentAttributeVideo from telethon.tl.types import DocumentAttributeVideo
from time import sleep from time import sleep
from re import search
@listener(outgoing=True, command="vdl", @listener(outgoing=True, command="vdl",
@ -33,7 +32,9 @@ async def vdl(context):
try: try:
from pytube import YouTube from pytube import YouTube
except ImportError: except ImportError:
await context.edit('(`pytube3`支持库未安装YouTube视频无法下载\n请使用 `-sh` `pip3` `install` `pytube3` 安装或自行ssh安装)') await context.edit('`pytube`支持库未安装YouTube视频无法下载\n请使用 `-sh pip3 install --user '
'git+https://github.com/nficano/pytube 或 -sh pip3 install pytube --upgrade ` 安装或自行ssh安装\n\n已安装过 `pytube3` 的用户请使用 `-sh pip3 '
'uninstall pytube3 -y` 进行卸载')
return return
url = url.replace('www.youtube.com/watch?v=', 'youtu.be/') url = url.replace('www.youtube.com/watch?v=', 'youtu.be/')
if not await youtube_dl(url, context, reply_id): if not await youtube_dl(url, context, reply_id):
@ -68,7 +69,8 @@ async def youtube_dl(url, context, reply_id):
async def bilibili_dl(url, context, reply_id): async def bilibili_dl(url, context, reply_id):
url = 'https://tenapi.cn/bilivideo/?url=' + url url = 'https://tenapi.cn/bilivideo/?url=' + url
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063', "X-Real-IP": "223.252.199.66"} headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063', "X-Real-IP": "223.252.199.66"}
for _ in range(20): # 最多尝试20次 for _ in range(20): # 最多尝试20次
status = False status = False
try: try:
@ -101,7 +103,8 @@ async def upload(as_file, filename, context, reply_id, caption, duration=0):
if not exists("plugins/VideoDLExtra"): if not exists("plugins/VideoDLExtra"):
mkdir("plugins/VideoDLExtra") mkdir("plugins/VideoDLExtra")
faster = requests.request( faster = requests.request(
"GET", "https://gist.githubusercontent.com/TNTcraftHIM/ca2e6066ed5892f67947eb2289dd6439/raw/86244b02c7824a3ca32ce01b2649f5d9badd2e49/FastTelethon.py") "GET", "https://gist.githubusercontent.com/TNTcraftHIM/ca2e6066ed5892f67947eb2289dd6439/raw"
"/86244b02c7824a3ca32ce01b2649f5d9badd2e49/FastTelethon.py")
for _ in range(6): # 最多尝试6次 for _ in range(6): # 最多尝试6次
if faster.status_code == 200: if faster.status_code == 200:
with open("plugins/VideoDLExtra/FastTelethon.py", "wb") as f: with open("plugins/VideoDLExtra/FastTelethon.py", "wb") as f:

39
vip.py
View File

@ -1,3 +1,5 @@
from requests import get
from os import remove
from pagermaid import bot from pagermaid import bot
from pagermaid.listener import listener from pagermaid.listener import listener
from pagermaid.utils import obtain_message from pagermaid.utils import obtain_message
@ -18,3 +20,40 @@ async def weather(context):
await bot.send_read_acknowledge(conversation.chat_id) await bot.send_read_acknowledge(conversation.chat_id)
weather_text = chat_response.text weather_text = chat_response.text
await context.edit(weather_text) await context.edit(weather_text)
@listener(is_plugin=True, outgoing=True, command="pixiv",
description="查询插画信息 (或者回复一条消息)",
parameters="[<图片链接>] <图片序号>")
async def pixiv(context):
await context.edit("获取中 . . .")
try:
message = await obtain_message(context)
except ValueError:
await context.edit("出错了呜呜呜 ~ 无效的参数。")
return
async with bot.conversation('PagerMaid_Modify_bot') as conversation:
await conversation.send_message('/pixiv_api ' + message)
chat_response = await conversation.get_response()
await bot.send_read_acknowledge(conversation.chat_id)
pixiv_text = chat_response.text
pixiv_list = pixiv_text.split('|||||')
if len(pixiv_list) == 2:
pixiv_albums = pixiv_list[1].split('|||')
pixiv_album = []
await context.edit("下载图片中 . . .")
for i in range(0, len(pixiv_albums)):
r = get(pixiv_albums[i])
with open("pixiv." + str(i) + ".jpg", "wb") as code:
code.write(r.content)
pixiv_album.extend(["pixiv." + str(i) + ".jpg"])
await context.client.send_file(context.chat_id, pixiv_album,
caption=pixiv_list[0])
await context.delete()
for i in pixiv_album:
try:
remove(i)
except:
pass
else:
await context.edit(pixiv_text)

View File

@ -1,4 +1,5 @@
import json import json
import datetime
from requests import get from requests import get
from pagermaid.listener import listener from pagermaid.listener import listener
from pagermaid.utils import obtain_message from pagermaid.utils import obtain_message
@ -24,6 +25,14 @@ icons = {
"50n": "🌫", "50n": "🌫",
} }
def timestamp_to_time(timestamp, timeZoneShift):
timeArray = datetime.datetime.utcfromtimestamp(timestamp) + datetime.timedelta(seconds=timeZoneShift)
return timeArray.strftime("%H:%M")
def calcWindDirection(windDirection):
dirs = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']
ix = round(windDirection / (360. / len(dirs)))
return dirs[ix % len(dirs)]
@listener(is_plugin=True, outgoing=True, command="weather", @listener(is_plugin=True, outgoing=True, command="weather",
description="查询天气", description="查询天气",
parameters="<城市>") parameters="<城市>")
@ -34,17 +43,33 @@ async def weather(context):
except ValueError: except ValueError:
await context.edit("出错了呜呜呜 ~ 无效的参数。") await context.edit("出错了呜呜呜 ~ 无效的参数。")
return return
try:
req = get("http://api.openweathermap.org/data/2.5/weather?appid=973e8a21e358ee9d30b47528b43a8746&units=metric&lang=zh_cn&q=" + message) req = get("http://api.openweathermap.org/data/2.5/weather?appid=973e8a21e358ee9d30b47528b43a8746&units=metric&lang=zh_cn&q=" + message)
if req.status_code == 200: if req.status_code == 200:
data = json.loads(req.text) data = json.loads(req.text)
cityName = "{}, {}".format(data["name"], data["sys"]["country"]) cityName = "{}, {}".format(data["name"], data["sys"]["country"])
timeZoneShift = data["timezone"]
temp_Max = round(data["main"]["temp_max"], 2)
temp_Min = round(data["main"]["temp_min"], 2)
pressure = data["main"]["pressure"]
humidity = data["main"]["humidity"]
windSpeed = data["wind"]["speed"]
windDirection = calcWindDirection(data["wind"]["deg"])
sunriseTimeunix = data["sys"]["sunrise"]
sunriseTime = timestamp_to_time(sunriseTimeunix, timeZoneShift)
sunsetTimeunix = data["sys"]["sunset"]
sunsetTime = timestamp_to_time(sunsetTimeunix, timeZoneShift)
fellsTemp = data["main"]["feels_like"]
tempInC = round(data["main"]["temp"], 2) tempInC = round(data["main"]["temp"], 2)
tempInF = round((1.8 * tempInC) + 32, 2) tempInF = round((1.8 * tempInC) + 32, 2)
icon = data["weather"][0]["icon"] icon = data["weather"][0]["icon"]
desc = data["weather"][0]["description"] desc = data["weather"][0]["description"]
res = "{}\n🌡{}℃ ({}F)\n{} {}".format( res = "{} {}{} 💨{} {}m/s\n大气🌡 {}℃ ({}℉) 💦 {}% \n体感🌡 {}\n气压 {}hpa\n🌅{} 🌇{} ".format(
cityName, tempInC, tempInF, icons[icon], desc cityName, icons[icon], desc, windDirection, windSpeed, tempInC, tempInF, humidity, fellsTemp, pressure, sunriseTime, sunsetTime
) )
await context.edit(res) await context.edit(res)
else: if req.status_code == 404:
await context.edit("出错了呜呜呜 ~ 无效的城市名,请使用拼音输入 ~ ")
return
except Exception:
await context.edit("出错了呜呜呜 ~ 无法访问到 openweathermap.org 。") await context.edit("出错了呜呜呜 ~ 无法访问到 openweathermap.org 。")

View File

@ -1,6 +1,6 @@
import json import json
import os,sys,codecs import os,sys,codecs
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
from requests import get from requests import get
from pagermaid.listener import listener from pagermaid.listener import listener
from pagermaid.utils import obtain_message from pagermaid.utils import obtain_message
@ -16,8 +16,8 @@ async def whois(context):
return return
req = get("https://tenapi.cn/whois/?url=" + message) req = get("https://tenapi.cn/whois/?url=" + message)
if req.status_code == 200: if req.status_code == 200:
data = json.loads(req.text) data = json.loads(req.text)['data']
res = '网址: ' + data['data']['url'] + '\n注册商: ' + str(data['data']['registrar']) + '\n联系人: ' + str(data['data']['registrant']) + '\n联系邮箱: ' + str(data['data']['mail']) + '\n注册时间: ' + str(data['data']['registration']) + '\n过期时间: ' + str(data['data']['expiration']) + '\nDNS ' + str(data['data']['dns']) res = '域名: `' + data['url'] + '`\n注册商: `' + str(data['registrar']) + '`\n联系人: `' + str(data['registrant']) + '`\n联系邮箱: `' + str(data['mail']) + '`\n注册时间: `' + str(data['registration']) + '`\n过期时间: `' + str(data['expiration']) + '`\nDNS ' + str(data['dns']).replace('<br/>', '\n')
await context.edit(res) await context.edit(res)
else: else:
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。") await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")

41
xjj.py Normal file
View File

@ -0,0 +1,41 @@
import random
from time import sleep
from requests import get
from pagermaid.listener import listener
from os import remove
@listener(is_plugin=True, outgoing=True, command="xjj",
description="随机小姐姐写真")
async def ghs(context):
await context.edit("拍小姐姐写真中 . . .")
status = False
for _ in range (10): #最多重试10次
website = random.randint(0,0)
filename = "xjj" + str(random.random())[2:] + ".png"
try:
if website == 0:
img = get("https://api.pixivweb.com/api.php?return=img")
if img.status_code == 200:
with open(filename, 'wb') as f:
f.write(img.content)
await context.edit("写真我拍好辣,上传中 . . .")
await context.client.send_file(context.chat_id,filename,caption="小姐姐来辣~( ⁄•⁄ω⁄•⁄ ))")
status = True
break #成功了就赶紧结束啦!
except:
try:
remove(filename)
except:
pass
continue
try:
remove(filename)
except:
pass
try:
await context.delete()
except:
pass
if not status:
await context.client.send_message(context.chat_id,"出错了呜呜呜 ~ 试了好多好多次都无法访问到服务器(没有颜色搞啦!) 。")

View File

@ -1,11 +1,10 @@
""" Pagermaid plugin base. """ """ Pagermaid plugin base. """
import json, requests, re import json, requests, re
from googletrans import Translator
from urllib.parse import urlparse from urllib.parse import urlparse
from pagermaid import bot, log from pagermaid import bot, log
from pagermaid.listener import listener, config from pagermaid.listener import listener, config
from pagermaid.utils import clear_emojis, obtain_message, attach_log from pagermaid.utils import clear_emojis, obtain_message, attach_log
from telethon.tl.types import ChannelParticipantsAdmins from telethon.errors import ChatAdminRequiredError
from os import remove from os import remove
@ -38,29 +37,11 @@ async def guess(context):
await context.edit("没有匹配到拼音首字母缩写") await context.edit("没有匹配到拼音首字母缩写")
@listener(is_plugin=True, outgoing=True, command="admin",
description="一键 AT 本群管理员(仅在群组中有效)")
async def admin(context):
await context.edit('正在获取管理员列表中...')
chat = await context.get_chat()
try:
admins = await context.client.get_participants(chat, filter=ChannelParticipantsAdmins)
except:
await context.edit('请在群组中使用。')
return True
admin_list = []
for admin in admins:
if admin.first_name is not None:
admin_list.extend(['[' + admin.first_name + '](tg://user?id=' + str(admin.id) + ')'])
await context.edit(' , '.join(admin_list))
@listener(is_plugin=True, outgoing=True, command="wiki", @listener(is_plugin=True, outgoing=True, command="wiki",
description="查询维基百科词条", description="查询维基百科词条",
parameters="<词组>") parameters="<词组>")
async def wiki(context): async def wiki(context):
translator = Translator() lang = config['application_language'].replace('zh-cn', 'zh')
lang = config['application_language']
await context.edit("获取中 . . .") await context.edit("获取中 . . .")
try: try:
message = await obtain_message(context) message = await obtain_message(context)
@ -68,19 +49,26 @@ async def wiki(context):
await context.edit("出错了呜呜呜 ~ 无效的参数。") await context.edit("出错了呜呜呜 ~ 无效的参数。")
return return
try: try:
wiki_json = json.loads(requests.get("https://zh.wikipedia.org/w/api.php?action=query&list=search&format=json&formatversion=2&srsearch=" + message).content.decode( wiki_json = json.loads(requests.get("https://zh.wikipedia.org/w/api.php?action=query&list=search&format=json"
"&formatversion=2&srsearch=" + message).content.decode(
"utf-8")) "utf-8"))
except: except:
await context.edit("出错了呜呜呜 ~ 无法访问到维基百科。") await context.edit("出错了呜呜呜 ~ 无法访问到维基百科。")
return return
if not len(wiki_json['query']['search']) == 0: if not len(wiki_json['query']['search']) == 0:
wiki_title = wiki_json['query']['search'][0]['title'] wiki_title = wiki_json['query']['search'][0]['title']
wiki_content = wiki_json['query']['search'][0]['snippet'].replace('<span class=\"searchmatch\">', '**').replace('</span>', '**') wiki_content = wiki_json['query']['search'][0]['snippet'].replace('<span class=\"searchmatch\">', '**').replace(
'</span>', '**')
wiki_time = wiki_json['query']['search'][0]['timestamp'].replace('T', ' ').replace('Z', ' ') wiki_time = wiki_json['query']['search'][0]['timestamp'].replace('T', ' ').replace('Z', ' ')
try: try:
await context.edit("正在生成翻译中 . . .") await context.edit("正在生成翻译中 . . .")
wiki_content = translator.translate(clear_emojis(wiki_content), dest=lang) USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:65.0) Gecko/20100101 Firefox/65.0"
message = '词条: [' + wiki_title + '](https://zh.wikipedia.org/zh-cn/' + wiki_title + ')\n\n' + wiki_content.text + '...\n\n此词条最后修订于 ' + wiki_time headers = {"user-agent": USER_AGENT}
wiki_content = json.loads(requests.get("https://xtaolink.cn/git/m/t.php?lang=" + lang + '&text=' +
clear_emojis(wiki_content), headers=headers)
.content.decode("utf-8"))['data']['target_text']
message = '词条: [' + wiki_title + '](https://zh.wikipedia.org/zh-cn/' + wiki_title + ')\n\n' + \
wiki_content + '...\n\n此词条最后修订于 ' + wiki_time
except ValueError: except ValueError:
await context.edit("出错了呜呜呜 ~ 找不到目标语言,请更正配置文件中的错误。") await context.edit("出错了呜呜呜 ~ 找不到目标语言,请更正配置文件中的错误。")
return return
@ -105,7 +93,8 @@ async def ipinfo(context):
else: else:
url = url.path url = url.path
ipinfo_json = json.loads(requests.get( ipinfo_json = json.loads(requests.get(
"http://ip-api.com/json/" + url + "?fields=status,message,country,regionName,city,lat,lon,isp,org,as,mobile,proxy,hosting,query").content.decode( "http://ip-api.com/json/" + url + "?fields=status,message,country,regionName,city,lat,lon,isp,"
"org,as,mobile,proxy,hosting,query").content.decode(
"utf-8")) "utf-8"))
if ipinfo_json['status'] == 'fail': if ipinfo_json['status'] == 'fail':
pass pass
@ -142,7 +131,8 @@ async def ipinfo(context):
else: else:
url = url.path url = url.path
ipinfo_json = json.loads(requests.get( ipinfo_json = json.loads(requests.get(
"http://ip-api.com/json/" + url + "?fields=status,message,country,regionName,city,lat,lon,isp,org,as,mobile,proxy,hosting,query").content.decode( "http://ip-api.com/json/" + url + "?fields=status,message,country,regionName,city,lat,lon,isp,org,as,"
"mobile,proxy,hosting,query").content.decode(
"utf-8")) "utf-8"))
if ipinfo_json['status'] == 'fail': if ipinfo_json['status'] == 'fail':
pass pass
@ -196,8 +186,7 @@ async def ipping(context):
else: else:
url = url.path url = url.path
pinginfo = requests.get( pinginfo = requests.get(
"https://helloacm.com/api/ping/?cached&host=" + url).content.decode( "https://steakovercooked.com/api/ping/?host=" + url).content.decode("utf-8")
"utf-8")
if pinginfo == 'null': if pinginfo == 'null':
pass pass
elif not pinginfo == 'null': elif not pinginfo == 'null':
@ -214,8 +203,7 @@ async def ipping(context):
await context.edit('没有找到要查询的 ip/域名 ...') await context.edit('没有找到要查询的 ip/域名 ...')
return True return True
pinginfo = requests.get( pinginfo = requests.get(
"https://helloacm.com/api/ping/?cached&host=" + url).content.decode( "https://steakovercooked.com/api/ping/?host=" + url).content.decode("utf-8")
"utf-8")
if pinginfo == 'null': if pinginfo == 'null':
pass pass
elif not pinginfo == 'null': elif not pinginfo == 'null':
@ -227,126 +215,6 @@ async def ipping(context):
await context.edit('没有找到要查询的 ip/域名 ...') await context.edit('没有找到要查询的 ip/域名 ...')
@listener(is_plugin=True, outgoing=True, command="pixiv",
description="查询插画信息 (或者回复一条消息)",
parameters="[<图片链接>] <图片序号>")
async def pixiv(context):
reply = await context.get_reply_message()
await context.edit('正在查询中...')
try:
if reply:
try:
if context.arguments.strip() == '':
pixiv_page = 1
else:
try:
pixiv_page = int(context.arguments.strip())
except:
await context.edit('呜呜呜出错了...可能参数不是数字')
return True
except:
pass
for num in range(0, len(reply.entities)):
url = reply.message[reply.entities[num].offset:reply.entities[num].offset + reply.entities[num].length]
url = urlparse(url)
try:
url = str(re.findall(r"\d+\.?\d*", url.path)[0])
pixiv_json = json.loads(requests.get(
"https://api.imjad.cn/pixiv/v2/?type=illust&id=" + url).content.decode(
"utf-8"))
except:
await context.edit('呜呜呜出错了...可能是链接不上 API 服务器')
return True
try:
pixiv_tag = pixiv_json['error']['user_message']
await context.edit('没有找到要查询的 pixiv 作品...')
return True
except:
if pixiv_page > pixiv_json['illust']['page_count']:
await context.edit('呜呜呜出错了...可能是参数指定的页数大于插画页数')
return True
else:
pass
pixiv_tag = []
pixiv_num = str(pixiv_json['illust']['page_count'])
pixiv_list = '[' + pixiv_json['illust']['title'] + '](https://www.pixiv.net/artworks/' + str(
pixiv_json['illust']['id']) + ')' + ' (' + str(pixiv_page) + '/' + pixiv_num + ')'
for nums in range(0, len(pixiv_json['illust']['tags'])):
pixiv_tag.extend(['#' + pixiv_json['illust']['tags'][nums]['name']])
try:
await context.edit('正在下载图片中 ...')
try:
r = requests.get(pixiv_json['illust']['meta_single_page']['original_image_url'].replace('i.pximg.net','i.pixiv.cat'))
except:
r = requests.get(pixiv_json['illust']['meta_pages'][pixiv_page - 1]['image_urls']['original'].replace('i.pximg.net','i.pixiv.cat'))
with open("pixiv.jpg", "wb") as code:
code.write(r.content)
await context.edit('正在上传图片中 ...')
await context.client.send_file(context.chat_id, 'pixiv.jpg',
caption=pixiv_list + '\nTags: ' + ' , '.join(pixiv_tag),
reply_to=reply.id)
await context.delete()
remove('pixiv.jpg')
except:
pass
return True
else:
try:
url = urlparse(context.arguments.split()[0])
if len(context.arguments.split()) == 1:
pixiv_page = 1
else:
try:
pixiv_page = int(context.arguments.split()[1])
except:
await context.edit('呜呜呜出错了...可能参数不是数字')
return True
except:
pass
try:
url = str(re.findall(r"\d+\.?\d*", url.path)[0])
pixiv_json = json.loads(requests.get(
"https://api.imjad.cn/pixiv/v2/?type=illust&id=" + url).content.decode(
"utf-8"))
except:
await context.edit('呜呜呜出错了...可能是链接不上 API 服务器')
try:
pixiv_tag = pixiv_json['error']['user_message']
await context.edit('没有找到要查询的 pixiv 作品...')
return True
except:
if pixiv_page > pixiv_json['illust']['page_count']:
await context.edit('呜呜呜出错了...可能是参数指定的页数大于插画页数')
return True
else:
pass
pixiv_tag = []
pixiv_num = str(pixiv_json['illust']['page_count'])
pixiv_list = '[' + pixiv_json['illust']['title'] + '](https://www.pixiv.net/artworks/' + str(
pixiv_json['illust']['id']) + ')' + ' (' + str(pixiv_page) + '/' + pixiv_num + ')'
for nums in range(0, len(pixiv_json['illust']['tags'])):
pixiv_tag.extend(['#' + pixiv_json['illust']['tags'][nums]['name']])
try:
await context.edit('正在下载图片中 ...')
try:
r = requests.get(pixiv_json['illust']['meta_single_page']['original_image_url'].replace('i.pximg.net','i.pixiv.cat'))
except:
r = requests.get(pixiv_json['illust']['meta_pages'][pixiv_page - 1]['image_urls']['original'].replace('i.pximg.net','i.pixiv.cat'))
with open("pixiv.jpg", "wb") as code:
code.write(r.content)
await context.edit('正在上传图片中 ...')
await context.client.send_file(context.chat_id, 'pixiv.jpg',
caption=pixiv_list + '\nTags: ' + ' , '.join(pixiv_tag))
await context.delete()
remove('pixiv.jpg')
except:
pass
return True
await context.edit('没有找到要查询的 pixiv 作品 ...')
except:
await context.edit('没有找到要查询的 pixiv 作品 ...')
@listener(is_plugin=True, outgoing=True, command="t", @listener(is_plugin=True, outgoing=True, command="t",
description="通过腾讯AI开放平台将目标消息翻译成指定的语言。", description="通过腾讯AI开放平台将目标消息翻译成指定的语言。",
parameters="<文本>") parameters="<文本>")
@ -368,7 +236,8 @@ async def tx_t(context):
try: try:
await context.edit("正在生成翻译中 . . .") await context.edit("正在生成翻译中 . . .")
tx_json = json.loads(requests.get( tx_json = json.loads(requests.get(
"https://xtaolink.cn/git/m/t.php?lang=" + lang + '&text=' + clear_emojis(message), headers=headers).content.decode( "https://xtaolink.cn/git/m/t.php?lang=" + lang + '&text=' + clear_emojis(message),
headers=headers).content.decode(
"utf-8")) "utf-8"))
if not tx_json['msg'] == 'ok': if not tx_json['msg'] == 'ok':
context.edit("出错了呜呜呜 ~ 翻译出错") context.edit("出错了呜呜呜 ~ 翻译出错")
@ -384,3 +253,24 @@ async def tx_t(context):
await attach_log(result, context.chat_id, "translation.txt", context.id) await attach_log(result, context.chat_id, "translation.txt", context.id)
return return
await context.edit(result) await context.edit(result)
@listener(is_plugin=True, outgoing=True, command="getdel",
description="获取当前群组/频道的死号数。")
async def getdel(context):
""" PagerMaid getdel. """
cid = str(context.chat_id)
pri = cid.startswith('-100')
if pri:
member_count = 0
try:
await context.edit('遍历成员中。。。')
chat = await context.get_chat()
async for member in bot.iter_participants(chat):
if member.deleted:
member_count += 1
await context.edit(f'此频道/群组的死号数:`{member_count}`')
except ChatAdminRequiredError:
await context.edit('未加入此频道。')
else:
await context.edit("请在在群组/频道发送。")

41
zpr.py Normal file
View File

@ -0,0 +1,41 @@
import random
from time import sleep
from requests import get
from pagermaid.listener import listener
from os import remove
@listener(is_plugin=True, outgoing=True, command="zpr",
description="随机小姐姐或纸片人写真")
async def ghs(context):
await context.edit("拍小姐姐或纸片人写真中 . . .")
status = False
for _ in range (10): #最多重试10次
website = random.randint(0,0)
filename = "zpr" + str(random.random())[2:] + ".png"
try:
if website == 0:
img = get("https://api.pixivweb.com/anime18r.php?return=img")
if img.status_code == 200:
with open(filename, 'wb') as f:
f.write(img.content)
await context.edit("写真我拍好辣,上传中 . . .")
await context.client.send_file(context.chat_id,filename,caption="来辣~( ⁄•⁄ω⁄•⁄ ))")
status = True
break #成功了就赶紧结束啦!
except:
try:
remove(filename)
except:
pass
continue
try:
remove(filename)
except:
pass
try:
await context.delete()
except:
pass
if not status:
await context.client.send_message(context.chat_id,"出错了呜呜呜 ~ 试了好多好多次都无法访问到服务器(没有颜色搞啦!) 。")