8000 Merge branch 'master' into dev · pyrogram/plugins@f989195 · GitHub
[go: up one dir, main page]

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

Commit f989195

Browse files
authored
Merge branch 'master' into dev
2 parents f11879e + a6c4c78 commit f989195

File tree

4 files changed

+75
-2
lines changed

4 files changed

+75
-2
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
- [Download](https://github.com/pyrogram/plugins/archive/master.zip) and copy the desired plugin(s) into your *plugins* folder.
1313
- Enable plugins in your Client by telling Pyrogram to search on your folder with `plugins_dir="plugins"`:
1414
```python
15+
from pyrogram import Client
16+
1517
app = Client("my_account", plugins_dir="plugins")
1618
```
1719
- Done! Run your client with `app.run()`, the plugins will be automatically loaded.
@@ -24,6 +26,7 @@
2426
- Create an awesome plugin.
2527
- Make a folder for your plugin and choose a meaningful name.
2628
- Create a python file named the same inside your plugin folder.
29+
- If necessary, create a `requirements.txt` file and add all the dependencies your plugin needs.
2730
- Open a new [Pull Request](https://github.com/pyrogram/plugins/compare) to propose adding your plugin inside the [plugins](plugins) directory.
2831
- Make sure you add a proper license and your name to it.
2932
- Also edit the readme to add the plugin in the list below.
@@ -36,5 +39,7 @@ You found a bug on a plugin or want to extend one? Or maybe you have ideas on ho
3639

3740
Name | Description | Usage | License
3841
:--- | :--- | :--- | :---
39-
[**Haste**](plugins/haste), by [delivrance](//github.com/delivrance) | Upload text to hastebin.com and send its link | Reply to a group chat text message with `!haste` | MIT
40-
[**eval**](plugins/eval), by [Furoin](//github.com/Furoin) | Evaluate a Python expression and send the result | Example: `!eval 1+2+3` | MIT
42+
[**haste**](plugins/haste), by [delivrance](//github.com/delivrance) | Upload text to hastebin.com and send its link | Reply to a group chat text message with `!haste`
43+
[**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
44+
[**eval**](plugins/eval), by [Furoin](//github.com/Furoin) | Evaluate a Python expression and send the result | Example: `!eval 1+2+3`
45+
[**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 <old>/<new>`

plugins/haste/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
requests

plugins/replace/replace.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2018 BrightSide <https://github.com/bright5ide>
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
from pyrogram import Client, Filters
24+
25+
@Client.on_message(Filters.command("r", prefix="!") & Filters.reply & ~Filters.edited & Filters.group)
26+
def r(client, message):
27+
if len(message.command) > 1:
28+
colength = len("r") + len("!")
29+
query = str(message.text)[colength:].lstrip()
30+
eventsplit=query.split("/")
31+
result="**You mean:**\n{}".format(message.reply_to_message.text.replace(eventsplit[0],eventsplit[1]))
32+
client.edit_message_text(message.chat.id, message.message_id, result)

plugins/welcome/welcome.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2018 Dan Tès <https://github.com/delivrance>
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
from pyrogram import Client, Emoji, Filters
24+
25+
MENTION = "[{}](tg://user?id={})"
26+
MESSAGE = "{} Welcome to [Pyrogram](https://docs.pyrogram.ml/)'s group chat {}!"
27+
28+
chats_filter = Filters.chat(["PyrogramChat", "PyrogramLounge"])
29+
30+
31+
@Client.on_message(chats_filter & Filters.new_chat_members)
32+
def welcome(client, message):
33+
new_members = [MENTION.format(i.first_name, i.id) for i in message.new_chat_members]
34+
text = MESSAGE.format(Emoji.SPARKLES, ", ".join(new_members))
35+
message.reply(text, disable_web_page_preview=True)

0 commit comments

Comments
 (0)
0