Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update pyrogram #336

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 4 additions & 3 deletions plugins/fun/animesticker/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# By @Krishna_Singhal

import random

from pyrogram.types import ReplyParameters
from emoji import get_emoji_regexp

from userge import userge, Message
Expand All @@ -35,7 +35,7 @@ async def anime_sticker(message: Message):
if args:
text = args
elif replied:
text = args if args else replied.text
text = args or replied.text
else:
await message.err("Input not found!")
return
Expand Down Expand Up @@ -77,7 +77,8 @@ async def anime_sticker(message: Message):
await userge.send_sticker(
chat_id=message.chat.id,
sticker=str(saved.sticker.file_id),
reply_to_message_id=message_id
reply_parameters=ReplyParameters(
message_id=message_id) if message_id else None,
)
await saved.delete()
except IndexError:
Expand Down
4 changes: 2 additions & 2 deletions plugins/fun/autofastly/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import os

from pyrogram import enums

from pyrogram.types import LinkPreviewOptions
from userge import userge, Message, filters, config, get_collection
from ...utils import ocr

Expand Down Expand Up @@ -45,7 +45,7 @@ async def autofastly(msg: Message):
"<code>Oops!!get the OCR API from</code> "
"<a href='https://eepurl.com/bOLOcf'>HERE</a> "
"<code>& add it to Heroku config vars</code> (<code>OCR_SPACE_API_KEY</code>)",
disable_web_page_preview=True,
link_preview_options=LinkPreviewOptions(is_disabled=True),
parse_mode=enums.ParseMode.HTML, del_in=0)
return

Expand Down
6 changes: 4 additions & 2 deletions plugins/fun/carbon/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import aiofiles
from pyrogram.errors.exceptions.bad_request_400 import YouBlockedUser
from pyrogram.types import ReplyParameters
from selenium import webdriver

from userge import userge, Message, config
Expand Down Expand Up @@ -72,7 +73,7 @@ async def carbon_(message: Message):
userge.send_document(chat_id=message.chat.id,
document=file_id,
caption='`' + caption + '`',
reply_to_message_id=replied.id if replied else None)
reply_parameters=ReplyParameters(message_id=replied.id if replied else None))
)
else:
input_str = message.filtered_input_str
Expand Down Expand Up @@ -169,7 +170,8 @@ async def carbon_(message: Message):
message.delete(),
message.client.send_photo(chat_id=message.chat.id,
photo=carbon_path,
reply_to_message_id=message_id)
repy_parameters=ReplyParameters(message_id=message_id)
)
)
os.remove(carbon_path)
driver.quit()
7 changes: 4 additions & 3 deletions plugins/fun/deepfry/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import random

from PIL import Image, ImageEnhance, ImageOps
from pyrogram.types import ReplyParameters
from pyrogram.errors.exceptions.bad_request_400 import YouBlockedUser

from userge import userge, Message, config
Expand Down Expand Up @@ -75,7 +76,7 @@ async def deepfryer(message: Message):

await message.client.send_photo(chat_id=message.chat.id,
photo=fried_file,
reply_to_message_id=replied.id)
reply_parameters=ReplyParameters(message_id=replied.id))
await message.delete()
os.remove(fried_file)

Expand Down Expand Up @@ -195,7 +196,7 @@ async def fry_(message: Message):
await userge.send_message(
chat,
f"/deepfry {args}",
reply_to_message_id=media.id,
reply_parameters=ReplyParameters(message_id=media.id),
)
response = await conv.get_response(mark_read=True)
if not response.photo:
Expand All @@ -213,7 +214,7 @@ async def fry_(message: Message):
await message.client.send_sticker(
message.chat.id,
sticker=deep_fry,
reply_to_message_id=message_id,
reply_parameters=ReplyParameters(message_id=message_id)
)
await message.delete()
for garb in (dls_loc, frying_file, deep_fry):
Expand Down
4 changes: 3 additions & 1 deletion plugins/fun/gifify/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os

import lottie
from pyrogram.types import ReplyParameters

from userge import userge, Message, config, pool

Expand Down Expand Up @@ -51,7 +52,8 @@ async def gifify(msg: Message):
msg.chat.id,
converted_gif,
unsave=True,
reply_to_message_id=replied.id)
reply_params=ReplyParameters(message_id=replied.id),
)
await msg.delete()
os.remove(converted_gif)

Expand Down
8 changes: 5 additions & 3 deletions plugins/fun/glitch/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from PIL import Image
from glitch_this import ImageGlitcher

from pyrogram.types import ReplyParameters
from userge import userge, Message, config
from userge.utils import take_screen_shot, runcmd

Expand Down Expand Up @@ -89,7 +89,8 @@ async def glitch_(message: Message):
await message.client.send_sticker(
message.chat.id,
glitched,
reply_to_message_id=message_id)
reply_parameters=ReplyParameters(message_id=message_id)
)
os.remove(glitched)
await message.delete()
else:
Expand All @@ -106,7 +107,8 @@ async def glitch_(message: Message):
await message.client.send_animation(
message.chat.id,
Glitched,
reply_to_message_id=message_id)
reply_parameters=ReplyParameters(message_id=message_id)
)
os.remove(Glitched)
await message.delete()
for files in (dls_loc, glitch_file):
Expand Down
4 changes: 2 additions & 2 deletions plugins/fun/meme/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import os

from pyrogram.errors.exceptions.bad_request_400 import YouBlockedUser

from pyrogram.types import ReplyParameters
from userge import userge, Message, config
from userge.utils import take_screen_shot, runcmd

Expand Down Expand Up @@ -85,7 +85,7 @@ async def meme_(message: Message):
await conv.send_message(message.input_str)
response = await conv.get_response(mark_read=True)
if response.sticker:
await response.copy(message.chat.id, reply_to_message_id=replied.id)
await response.copy(message.chat.id, reply_parameters=ReplyParameters(message_id=replied.id))
await message.delete()
for file in (meme_file, dls_loc):
if file and os.path.exists(file):
Expand Down
6 changes: 4 additions & 2 deletions plugins/fun/memes/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from re import sub

from pyrogram import enums
from pyrogram.types import ReplyParameters

import requests
import wget
Expand Down Expand Up @@ -359,12 +360,13 @@ async def decide_(message: Message):
await message.client.send_animation(chat_id=chat_id,
animation=path,
caption=str(r["answer"]).upper(),
reply_to_message_id=message_id)
reply_parameters=ReplyParameters(message_id=message_id)
)
else:
await message.client.send_photo(chat_id=chat_id,
photo=path,
caption=str(r["answer"]).upper(),
reply_to_message_id=message_id)
reply_parameters=ReplyParameters(message_id=message_id))
os.remove(path)


Expand Down
3 changes: 2 additions & 1 deletion plugins/fun/memify/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import textwrap

from PIL import Image, ImageFont, ImageDraw
from pyrogram.types import ReplyParameters

from userge import userge, Message, config
from userge.utils import progress, take_screen_shot, runcmd
Expand Down Expand Up @@ -66,7 +67,7 @@ async def memify(message: Message):
webp_file = await draw_meme_text(dls_loc, message.input_str)
await message.client.send_sticker(chat_id=message.chat.id,
sticker=webp_file,
reply_to_message_id=replied.id)
reply_parameters=ReplyParameters(message_id=replied.id))
await message.delete()
os.remove(webp_file)

Expand Down
4 changes: 2 additions & 2 deletions plugins/fun/poll/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import random

from userge import userge, Message

from pyrogram.types import ReplyParameters

@userge.on_cmd("poll", about={
'header': "Create Poll of Suggestion to get opinion",
Expand All @@ -35,7 +35,7 @@ async def create_poll(msg: Message):
question=query,
options=options,
is_anonymous=anonymous,
reply_to_message_id=msg_id)
reply_parameters=ReplyParameters(message_id=msg_id))
else:
query = "Do you agree with that Suggestion..?"
await userge.send_poll(
Expand Down
3 changes: 2 additions & 1 deletion plugins/fun/quote/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import asyncio

from pyrogram.errors.exceptions.bad_request_400 import YouBlockedUser
from pyrogram.types import ReplyParameters

from userge import userge, Message

Expand Down Expand Up @@ -42,4 +43,4 @@ async def quotecmd(message: Message):
message_id = replied.id if replied else None
await userge.send_sticker(chat_id=message.chat.id,
sticker=quote.sticker.file_id,
reply_to_message_id=message_id)
reply_parameters=ReplyParameters(message_id=message_id))
3 changes: 2 additions & 1 deletion plugins/fun/rgb_sticklet/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import textwrap

from PIL import Image, ImageDraw, ImageFont
from pyrogram.types import ReplyParameters

from userge import userge, Message, get_collection

Expand Down Expand Up @@ -101,7 +102,7 @@ async def sticklet(message: Message):
image.save(image_name, "WebP")

await message.client.send_sticker(
chat_id=message.chat.id, sticker=image_name, reply_to_message_id=reply_to)
chat_id=message.chat.id, sticker=image_name, reply_parameters=ReplyParameters(message_id=reply_to))

# cleanup
try:
Expand Down
8 changes: 4 additions & 4 deletions plugins/fun/transform/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import os

from PIL import Image, ImageOps

from pyrogram.types import ReplyParameters
from userge import userge, Message, config
from userge.utils import take_screen_shot, runcmd

Expand Down Expand Up @@ -77,7 +77,7 @@ async def ghost_invert(message: Message):
await message.client.send_sticker(
message.chat.id,
sticker=Converted,
reply_to_message_id=replied.id)
reply_parameters=ReplyParameters(message_id=replied.id))
await message.delete()
for files in (dls_loc, ghost_file, Converted):
if files and os.path.exists(files):
Expand Down Expand Up @@ -139,7 +139,7 @@ async def mirror_flip(message: Message):
await message.client.send_sticker(
message.chat.id,
sticker=Converted,
reply_to_message_id=replied.id)
reply_parameters=ReplyParameters(message_id=replied.id))
await message.delete()
for files in (dls_loc, mirror_flip_file, Converted):
if files and os.path.exists(files):
Expand Down Expand Up @@ -208,7 +208,7 @@ async def rotate_(message: Message):
await message.client.send_sticker(
message.chat.id,
sticker=Converted,
reply_to_message_id=replied.id)
reply_parameters=ReplyParameters(message_id=replied.id))
await message.delete()
for files in (dls_loc, rotate_file, Converted):
if files and os.path.exists(files):
Expand Down
4 changes: 2 additions & 2 deletions plugins/fun/tweet/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from PIL import Image
from emoji import get_emoji_regexp
from validators.url import url

from pyrogram.types import ReplyParameters
from userge import userge, config, Message

CONVERTED_IMG = config.Dynamic.DOWN_PATH + "img.png"
Expand Down Expand Up @@ -136,6 +136,6 @@ async def _tweets(msg: Message, text: str, username: str = '', type_: str = "twe
msg_id = msg.reply_to_message.id if msg.reply_to_message else None
await msg.client.send_photo(chat_id=msg.chat.id,
photo=CONVERTED_IMG,
reply_to_message_id=msg_id)
reply_parameters=ReplyParameters(message_id=msg_id))
os.remove(tmp_file)
os.remove(CONVERTED_IMG)
4 changes: 2 additions & 2 deletions plugins/misc/deezloader/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import deezloader # pylint: disable=W0406
from deezloader.exceptions import NoDataApi

from pyrogram.types import LinkPreviewOptions
from userge import userge, Message, pool
from . import ARL_TOKEN
from ..upload import doc_upload, audio_upload
Expand Down Expand Up @@ -51,7 +51,7 @@ async def deezload(message: Message):
os.makedirs(TEMP_PATH)
await message.edit("Checking your Token.")
if ARL_TOKEN is None:
await message.edit(ARL_HELP, disable_web_page_preview=True)
await message.edit(ARL_HELP, link_preview_options=LinkPreviewOptions(is_disabled=True))
return
try:
loader = deezloader.Login(ARL_TOKEN)
Expand Down
6 changes: 3 additions & 3 deletions plugins/misc/download/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from urllib.parse import unquote_plus

from pySmartDL import SmartDL
from pyrogram.types import Message as PyroMessage
from pyrogram.types import Message as PyroMessage, LinkPreviewOptions
from pyrogram import enums

from userge import Message, config
Expand Down Expand Up @@ -84,7 +84,7 @@ async def url_download(message: Message, url: str) -> Tuple[str, int]:
downloader.start(blocking=False)
with message.cancel_callback(downloader.stop):
while not downloader.isFinished():
total_length = downloader.filesize if downloader.filesize else 0
total_length = downloader.filesize or 0
downloaded = downloader.get_dl_size()
percentage = downloader.get_progress() * 100
speed = downloader.get_speed(human=True)
Expand Down Expand Up @@ -112,7 +112,7 @@ async def url_download(message: Message, url: str) -> Tuple[str, int]:
humanbytes(total_length),
speed,
estimated_total_time)
await message.edit(progress_str, disable_web_page_preview=True)
await message.edit(progress_str, link_preview_options=LinkPreviewOptions(is_disabled=True))
await asyncio.sleep(config.Dynamic.EDIT_SLEEP_TIMEOUT)
if message.process_is_canceled:
raise ProcessCanceled
Expand Down
Loading