From 6c21b735d6da276fafdf543b647d95b086e5b7b3 Mon Sep 17 00:00:00 2001 From: GodSaveTheDoge Date: Fri, 2 Oct 2020 18:04:31 +0200 Subject: [PATCH 1/4] Updated to v 1.0.7 and updated copyright --- .gitignore | 1 + plugins/eval/eval.py | 18 ++++++------------ plugins/haste/haste.py | 12 +++++------- plugins/replace/replace.py | 17 +++++++++++------ plugins/welcome/welcome.py | 10 +++++----- 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/.gitignore b/.gitignore index 894a44c..8a9b319 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,4 @@ venv.bak/ # mypy .mypy_cache/ +.idea/ diff --git a/plugins/eval/eval.py b/plugins/eval/eval.py index e96d108..6662ead 100644 --- a/plugins/eval/eval.py +++ b/plugins/eval/eval.py @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2018 Furoin +# Copyright (c) 2020 Furoin # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from pyrogram import Client, Filters +from pyrogram import Client, filters RUNNING = "**Eval Expression:**\n```{}```\n**Running...**" ERROR = "**Eval Expression:**\n```{}```\n**Error:**\n```{}```" @@ -28,7 +28,7 @@ RESULT = "**Eval Expression:**\n```{}```\n**Result:**\n```{}```" -@Client.on_message(Filters.command("eval", prefix="!")) +@Client.on_message(filters.command("eval", prefixes=("!",))) def eval_expression(client, message): expression = " ".join(message.command[1:]) @@ -39,20 +39,14 @@ def eval_expression(client, message): result = eval(expression) except Exception as error: client.edit_message_text( - m.chat.id, - m.message_id, - ERROR.format(expression, error) + m.chat.id, m.message_id, ERROR.format(expression, error) ) else: if result is None: client.edit_message_text( - m.chat.id, - m.message_id, - SUCCESS.format(expression) + m.chat.id, m.message_id, SUCCESS.format(expression) ) else: client.edit_message_text( - m.chat.id, - m.message_id, - RESULT.format(expression, result) + m.chat.id, m.message_id, RESULT.format(expression, result) ) diff --git a/plugins/haste/haste.py b/plugins/haste/haste.py index 45a742d..611eac0 100644 --- a/plugins/haste/haste.py +++ b/plugins/haste/haste.py @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2018 Dan Tès +# Copyright (c) 2020 Dan Tès # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,12 +22,12 @@ import requests -from pyrogram import Client, Filters +from pyrogram import Client, filters BASE = "https://hastebin.com" -@Client.on_message(Filters.command("haste", prefix="!") & Filters.reply) +@Client.on_message(filters.command("haste", prefixes=("!",)) & filters.reply) def haste(client, message): reply = message.reply_to_message @@ -37,11 +37,9 @@ def haste(client, message): message.delete() result = requests.post( - "{}/documents".format(BASE), - data=reply.text.encode("UTF-8") + "{}/documents".format(BASE), data=reply.text.encode("UTF-8") ).json() message.reply( - "{}/{}.py".format(BASE, result["key"]), - reply_to_message_id=reply.message_id + "{}/{}.py".format(BASE, result["key"]), reply_to_message_id=reply.message_id ) diff --git a/plugins/replace/replace.py b/plugins/replace/replace.py index 8b11b3d..9338618 100644 --- a/plugins/replace/replace.py +++ b/plugins/replace/replace.py @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2018 BrightSide +# Copyright (c) 2020 BrightSide # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,13 +20,18 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from pyrogram import Client, Filters - -@Client.on_message(Filters.command("r", prefix="!") & Filters.reply & ~Filters.edited & Filters.group) +from pyrogram import Client, filters + + +@Client.on_message( + filters.command("r", prefixes=("!",)) & filters.reply & ~filters.edited & filters.group +) def r(client, message): if len(message.command) > 1: colength = len("r") + len("!") query = str(message.text)[colength:].lstrip() - eventsplit=query.split("/") - result="**You mean:**\n{}".format(message.reply_to_message.text.replace(eventsplit[0],eventsplit[1])) + eventsplit = query.split("/") + result = "**You mean:**\n{}".format( + message.reply_to_message.text.replace(eventsplit[0], eventsplit[1]) + ) client.edit_message_text(message.chat.id, message.message_id, result) diff --git a/plugins/welcome/welcome.py b/plugins/welcome/welcome.py index d875ece..59f45bd 100644 --- a/plugins/welcome/welcome.py +++ b/plugins/welcome/welcome.py @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2018 Dan Tès +# Copyright (c) 2020 Dan Tès # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,16 +20,16 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from pyrogram import Client, Emoji, Filters +from pyrogram import Client, emoji, filters MENTION = "[{}](tg://user?id={})" MESSAGE = "{} Welcome to [Pyrogram](https://docs.pyrogram.ml/)'s group chat {}!" -chats_filter = Filters.chat(["PyrogramChat", "PyrogramLounge"]) +chats_filter = filters.chat(["PyrogramChat", "PyrogramLounge"]) -@Client.on_message(chats_filter & Filters.new_chat_members) +@Client.on_message(chats_filter & filters.new_chat_members) def welcome(client, message): new_members = [MENTION.format(i.first_name, i.id) for i in message.new_chat_members] - text = MESSAGE.format(Emoji.SPARKLES, ", ".join(new_members)) + text = MESSAGE.format(emoji.SPARKLES, ", ".join(new_members)) message.reply(text, disable_web_page_preview=True) From 2aa5a4a5f7318ff6e0d9cbf86af16c1b5ecd9d90 Mon Sep 17 00:00:00 2001 From: GodSaveTheDoge Date: Fri, 2 Oct 2020 18:13:50 +0200 Subject: [PATCH 2/4] Added !neko --- plugins/nekobin/neko.py | 47 ++++++++++++++++++++++++++++++++ plugins/nekobin/requirements.txt | 1 + plugins/replace/replace.py | 5 +++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 plugins/nekobin/neko.py create mode 100644 plugins/nekobin/requirements.txt diff --git a/plugins/nekobin/neko.py b/plugins/nekobin/neko.py new file mode 100644 index 0000000..33006b7 --- /dev/null +++ b/plugins/nekobin/neko.py @@ -0,0 +1,47 @@ +# MIT License +# +# Copyright (c) 2020 Dan Tès +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +import requests + +from pyrogram import Client, filters +from pyrogram.types import Message + +BASE = "https://nekobin.com" + + +@Client.on_message(filters.command("neko", prefixes=("!",)) & filters.reply) +def haste(client: Client, message: Message): + reply = message.reply_to_message + + if reply.text is None: + return + + message.delete() + + result = requests.post( + "{}/api/documents".format(BASE), data=dict(content=reply.text.encode("UTF-8")) + ).json() + + message.reply( + "{}/{}.py".format(BASE, result["result"]["key"]), + reply_to_message_id=reply.message_id, + ) diff --git a/plugins/nekobin/requirements.txt b/plugins/nekobin/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/plugins/nekobin/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file diff --git a/plugins/replace/replace.py b/plugins/replace/replace.py index 9338618..8cc3613 100644 --- a/plugins/replace/replace.py +++ b/plugins/replace/replace.py @@ -24,7 +24,10 @@ @Client.on_message( - filters.command("r", prefixes=("!",)) & filters.reply & ~filters.edited & filters.group + filters.command("r", prefixes=("!",)) + & filters.reply + & ~filters.edited + & filters.group ) def r(client, message): if len(message.command) > 1: From 26d613fd5d07df721da85bdaa6c050db0a13d0ab Mon Sep 17 00:00:00 2001 From: GodSaveTheDoge Date: Fri, 2 Oct 2020 18:21:33 +0200 Subject: [PATCH 3/4] Added !neko to README.md --- README.md | 1 + plugins/{nekobin => neko}/neko.py | 2 +- plugins/{nekobin => neko}/requirements.txt | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename plugins/{nekobin => neko}/neko.py (95%) rename plugins/{nekobin => neko}/requirements.txt (100%) diff --git a/README.md b/README.md index d831146..53239d9 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,4 @@ Name | Description | Usage [**welcome**](plugins/welcome), by [delivrance](//github.com/delivrance) | Greet new members with a welcome message | Run and wait for new members to join your groups [**eval**](plugins/eval), by [Furoin](//github.com/Furoin) | Evaluate a Python expression and send the result | Example: `!eval 1+2+3` [**replace**](plugins/replace), by [brightside](//github.com/bright5ide) | Search and Replace a part of a message to suggest user if he meant something else | Reply to a group chat text message with `!r /` +[**neko**](plugins/neko), by [GodSaveTheDoge](//github.com/GodSaveTheDoge) | Paste something to nekobin.com and send the link | Reply to a text message with `!neko` diff --git a/plugins/nekobin/neko.py b/plugins/neko/neko.py similarity index 95% rename from plugins/nekobin/neko.py rename to plugins/neko/neko.py index 33006b7..50c530a 100644 --- a/plugins/nekobin/neko.py +++ b/plugins/neko/neko.py @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2020 Dan Tès +# Copyright (c) 2020 GodSaveTheDoge # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/plugins/nekobin/requirements.txt b/plugins/neko/requirements.txt similarity index 100% rename from plugins/nekobin/requirements.txt rename to plugins/neko/requirements.txt From 63cfdccc74e680432a35c2adee4e2132b48b38f8 Mon Sep 17 00:00:00 2001 From: GodSaveTheDoge <51802433+GodSaveTheDoge@users.noreply.github.com> Date: Thu, 8 Oct 2020 19:29:37 +0200 Subject: [PATCH 4/4] Fixed function name --- plugins/neko/neko.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/neko/neko.py b/plugins/neko/neko.py index 50c530a..561f91f 100644 --- a/plugins/neko/neko.py +++ b/plugins/neko/neko.py @@ -29,7 +29,7 @@ @Client.on_message(filters.command("neko", prefixes=("!",)) & filters.reply) -def haste(client: Client, message: Message): +def neko(client: Client, message: Message): reply = message.reply_to_message if reply.text is None: