From 529fc0371da2ecc1afdda3f5c6a68b94c91f8f87 Mon Sep 17 00:00:00 2001 From: AAA <35992542+TNTcraftHIM@users.noreply.github.com> Date: Wed, 9 Sep 2020 17:53:32 +0800 Subject: [PATCH] =?UTF-8?q?Aff=E6=8F=92=E4=BB=B6=E5=86=99=E5=AE=8C?= =?UTF-8?q?=E8=BE=BD=EF=BC=8C=E5=8F=AF=E4=BB=A5=E8=AE=A9=E4=BD=A0=E5=81=9A?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=89=8B=E9=80=9F=E7=88=86=E8=A1=A8=E7=9A=84?= =?UTF-8?q?Affman=EF=BC=88=E6=84=8F=E4=B9=89=E4=B8=8D=E6=98=8E=E7=9A=84?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=EF=BC=89=20(#58)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: TNTcraftHIM --- aff.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ list.json | 12 +++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 aff.py diff --git a/aff.py b/aff.py new file mode 100644 index 0000000..11dff53 --- /dev/null +++ b/aff.py @@ -0,0 +1,50 @@ +from time import sleep +from os.path import exists +from os import mkdir, remove +from pagermaid import redis, log, redis_status +from pagermaid.listener import listener + +@listener(is_plugin=True, outgoing=True, command="aff", + description="在别人要打算买机场的时候光速发出自己的aff信息(请尽量配合短链接)", + parameters=" (可选,用于保存|删除aff信息)") +async def aff(context): + if not context.parameter: #发送aff信息 + try: + with open("plugins/AffExtra/aff.txt", "r") as f: + msg = f.read() + except: + msg = "" + if msg == "": + await context.edit("出错了呜呜呜 ~ Aff消息不存在。\n(你有提前保存好嘛?)") + return + try: + await context.edit(msg) + except: + await context.edit("出错了呜呜呜 ~ 信息无变化。") + sleep(3) + await context.delete() + elif context.parameter[0] == "save": #保存aff信息 + 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") + with open("plugins/AffExtra/aff.txt", "w") as f: + f.write(msg) + await context.edit("好耶 ! Aff信息保存成功。") + sleep(3) + await context.delete() + elif context.parameter[0] == "remove": #删除aff信息 + 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) + await context.delete() \ No newline at end of file diff --git a/list.json b/list.json index 20636d2..7b5292b 100644 --- a/list.json +++ b/list.json @@ -305,10 +305,20 @@ "version": "0.1", "section": "daily", "maintainer": "TNTcraftHIM", - "size": "5.3", + "size": "5.3 kb", "supported": true, "des-short": "下载YTB/B站视频", "des": "随手写的youtube/B站下载视频插件,B站的似乎因为TG编码问题不支持在线播放,先这样吧(我懒)。命令:vdl。" + }, + { + "name": "aff", + "version": "1.0", + "section": "chat", + "maintainer": "TNTcraftHIM", + "size": "2.0 kb", + "supported": true, + "des-short": "光速发Aff信息", + "des": "在别人要打算买机场的时候光速发出提前准备好的Aff信息与链接~ (尽量用短链接哦)。命令:aff。" } ] }