8000 Added !neko and migrated to 1.0 by ligix · Pull Request #5 · pyrogram/plugins · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Added !neko and migrated to 1.0 #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Updated to v 1.0.7 and updated copyright
  • Loading branch information
GodSaveTheDoge committed Oct 2, 2020
commit 6c21b735d6da276fafdf543b647d95b086e5b7b3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,4 @@ venv.bak/

# mypy
.mypy_cache/
.idea/
18 changes: 6 additions & 12 deletions plugins/eval/eval.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018 Furoin <https://github.com/furoin>
# Copyright (c) 2020 Furoin <https://github.com/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
Expand All @@ -20,15 +20,15 @@
# 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```{}```"
SUCCESS = "**Eval Expression:**\n```{}```\n**Success**"
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:])

Expand All @@ -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)
)
12 changes: 5 additions & 7 deletions plugins/haste/haste.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018 Dan Tès <https://github.com/delivrance>
# Copyright (c) 2020 Dan Tès <https://github.com/delivrance>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -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

Expand All @@ -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
)
17 changes: 11 additions & 6 deletions plugins/replace/replace.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018 BrightSide <https://github.com/bright5ide>
# Copyright (c) 2020 BrightSide <https://github.com/bright5ide>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -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)
10 changes: 5 additions & 5 deletions plugins/welcome/welcome.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018 Dan Tès <https://github.com/delivrance>
# Copyright (c) 2020 Dan Tès <https://github.com/delivrance>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand All @@ -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)
0