2020-09-09 09:53:32 +00:00
|
|
|
|
from time import sleep
|
|
|
|
|
from os.path import exists
|
|
|
|
|
from os import mkdir, remove
|
2022-01-18 08:47:20 +00:00
|
|
|
|
from pagermaid import version
|
2021-06-16 07:09:40 +00:00
|
|
|
|
from pagermaid.utils import alias_command
|
2020-09-09 09:53:32 +00:00
|
|
|
|
from pagermaid.listener import listener
|
|
|
|
|
|
2021-06-16 07:09:40 +00:00
|
|
|
|
|
|
|
|
|
@listener(is_plugin=True, outgoing=True, command=alias_command("aff"),
|
2020-09-09 09:53:32 +00:00
|
|
|
|
description="在别人要打算买机场的时候光速发出自己的aff信息(请尽量配合短链接)",
|
|
|
|
|
parameters="<save|remove> (可选,用于保存|删除aff信息)")
|
|
|
|
|
async def aff(context):
|
2021-06-16 07:09:40 +00:00
|
|
|
|
if not context.parameter: # 发送aff信息
|
2020-09-09 09:53:32 +00:00
|
|
|
|
try:
|
2020-11-30 06:47:34 +00:00
|
|
|
|
with open("plugins/AffExtra/aff.txt", "r", encoding="UTF-8") as f:
|
2020-09-09 09:53:32 +00:00
|
|
|
|
msg = f.read()
|
|
|
|
|
except:
|
|
|
|
|
msg = ""
|
|
|
|
|
if msg == "":
|
|
|
|
|
await context.edit("出错了呜呜呜 ~ Aff消息不存在。\n(你有提前保存好嘛?)")
|
|
|
|
|
return
|
|
|
|
|
try:
|
2020-09-09 11:18:31 +00:00
|
|
|
|
await context.edit(msg, link_preview=True)
|
2020-09-09 09:53:32 +00:00
|
|
|
|
except:
|
|
|
|
|
await context.edit("出错了呜呜呜 ~ 信息无变化。")
|
|
|
|
|
sleep(3)
|
|
|
|
|
await context.delete()
|
2021-06-16 07:09:40 +00:00
|
|
|
|
elif context.parameter[0] == "save": # 保存aff信息
|
2020-09-09 09:53:32 +00:00
|
|
|
|
reply = await context.get_reply_message()
|
|
|
|
|
if not reply:
|
|
|
|
|
await context.edit("出错了呜呜呜 ~ 请回复一条消息以保存新的Aff信息。")
|
|
|
|
|
return
|
|
|
|
|
msg = reply.message
|
|
|
|
|
if not exists("plugins/AffExtra"):
|
|
|
|
|
mkdir("plugins/AffExtra")
|
2020-11-30 06:47:34 +00:00
|
|
|
|
with open("plugins/AffExtra/aff.txt", "w", encoding="UTF-8") as f:
|
2020-09-09 09:53:32 +00:00
|
|
|
|
f.write(msg)
|
|
|
|
|
await context.edit("好耶 ! Aff信息保存成功。")
|
|
|
|
|
sleep(3)
|
|
|
|
|
await context.delete()
|
2021-06-16 07:09:40 +00:00
|
|
|
|
elif context.parameter[0] == "remove": # 删除aff信息
|
2020-09-09 09:53:32 +00:00
|
|
|
|
try:
|
|
|
|
|
remove("plugins/AffExtra/aff.txt")
|
|
|
|
|
await context.edit("好耶 ! Aff信息删除成功。")
|
|
|
|
|
except:
|
|
|
|
|
await context.edit("出错了呜呜呜 ~ Aff信息删除失败。")
|
|
|
|
|
sleep(3)
|
|
|
|
|
await context.delete()
|
|
|
|
|
else:
|
|
|
|
|
await context.edit("出错了呜呜呜 ~ 无效的参数。")
|
|
|
|
|
sleep(3)
|
2021-06-16 07:09:40 +00:00
|
|
|
|
await context.delete()
|