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

Commit

Permalink
More Deepsource bug fixes (#53)
Browse files Browse the repository at this point in the history
* Update translate.py

* built-in function min()

* Update spotify_autobio.py

* Update gizoogle.py

* Update memes.py

* Update functions.py

* Update circle.py

* pylint: auto fixes

* Update nsfw.py

* pylint: auto fixes
  • Loading branch information
code-rgb authored Oct 24, 2020
1 parent dac50d9 commit 53910fe
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 69 deletions.
3 changes: 1 addition & 2 deletions userge/plugins/admin/purge.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ async def purge_(message: Message):
start_message = 0
if "l" in message.flags:
limit = int(message.flags["l"])
if limit > 100:
limit = 100
limit = min(limit, 100)
start_message = message.message_id - limit
if message.reply_to_message:
start_message = message.reply_to_message.message_id
Expand Down
6 changes: 2 additions & 4 deletions userge/plugins/fun/gizoogle.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
)
async def gizoo_(message: Message):
""" gizoogle the text """

input_str = message.input_or_reply_str
if not text:
await message.edit("```You didn't gave the text```", del_in=3)
return
try:
result = text(input_str)
except:
result = "Failed to gizoogle the text."
finally:
return await message.edit(result)
return await message.err("Failed to gizoogle the text.", del_in=3)
await message.edit(result)


def text(input_text: str) -> str:
Expand Down
10 changes: 2 additions & 8 deletions userge/plugins/fun/memes.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
""" enjoy memes """

# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE >
#
# All rights reserved.

import asyncio
Expand Down Expand Up @@ -676,9 +670,9 @@ async def dice_gen(message: Message):
async def emoji_func(message):

switch = await message.edit_text("🤔")
userge = "😆 😂 😳 😒 🧐 🤔 😍 😘 🥰 🥳 😌 😮 🙄 😐 😧 😔 😢 😡 😨 🎃 🤕 🤒 😷 🤧 🤢 🤮 👍 💝 ❤ 💋 😻 🎉 🎄 👛 💎 🙈 ☃ 📁 👻 💀 🦠 🚑"
emoji_s = "😆 😂 😳 😒 🧐 🤔 😍 😘 🥰 🥳 😌 😮 🙄 😐 😧 😔 😢 😡 😨 🎃 🤕 🤒 😷 🤧 🤢 🤮 👍 💝 ❤ 💋 😻 🎉 🎄 👛 💎 🙈 ☃ 📁 👻 💀 🦠 🚑"

for emoji in userge:
for emoji in emoji_s:
try:
await switch.edit(emoji)
await sleep(2)
Expand Down
41 changes: 1 addition & 40 deletions userge/plugins/fun/nsfw.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import asyncio
import os
import urllib

import requests
from pyrogram import filters
from pyrogram.errors import MessageNotModified
from pyrogram.types import (
Expand All @@ -12,7 +7,7 @@
InputMediaPhoto,
)

from userge import Config, Message, userge
from userge import Config, userge
from userge.utils import get_file_id_and_ref


Expand All @@ -28,40 +23,6 @@ async def age_verification(msg):
return True


@userge.on_cmd("boobs", about={"header": "Find some Bob", "usage": "{tr}boobs"})
async def boobs(message: Message):
if await age_verification(message):
return
if not os.path.isdir(Config.DOWN_PATH):
os.makedirs(Config.DOWN_PATH)
pic_loc = os.path.join(Config.DOWN_PATH, "bobs.jpg")
await message.edit("`Finding some big bobs 🧐...`")
await asyncio.sleep(0.5)
await message.edit("`Sending some big bobs 🌚...`")
nsfw = requests.get("http://api.oboobs.ru/noise/1").json()[0]["preview"]
urllib.request.urlretrieve("http://media.oboobs.ru/{}".format(nsfw), pic_loc)
await message.client.send_photo(message.chat.id, photo=pic_loc)
os.remove(pic_loc)
await message.delete()


@userge.on_cmd("butts", about={"header": "Find some Butts", "usage": "{tr}butts"})
async def butts(message: Message):
if await age_verification(message):
return
if not os.path.isdir(Config.DOWN_PATH):
os.makedirs(Config.DOWN_PATH)
pic_loc = os.path.join(Config.DOWN_PATH, "bobs.jpg")
await message.edit("`Finding some beautiful butts 🧐...`")
await asyncio.sleep(0.5)
await message.edit("`Sending some beautiful butts 🌚...`")
nsfw = requests.get("http://api.obutts.ru/noise/1").json()[0]["preview"]
urllib.request.urlretrieve("http://media.obutts.ru/{}".format(nsfw), pic_loc)
await message.client.send_photo(message.chat.id, photo=pic_loc)
os.remove(pic_loc)
await message.delete()


if userge.has_bot:

@userge.bot.on_callback_query(filters.regex(pattern=r"^age_verification_true"))
Expand Down
13 changes: 6 additions & 7 deletions userge/plugins/fun/spotify_autobio.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,9 @@ async def sp_info_(message: Message):
get_name = track["name"]
with open("status_recent_played_song.txt", "a") as sf:
sf.write("• __" + get_name + "__" + "\n")
f = open("status_recent_played_song.txt", "r+")
recent_p = f.read()
f.truncate(0)

with open("status_recent_played_song.txt", "r+") as f:
recent_p = f.read()
f.truncate(0)
device_info = device.json()
g_dlist = device_info["devices"][0]
device_name = g_dlist["name"]
Expand Down Expand Up @@ -502,9 +501,9 @@ async def sp_recents_(message: Message):
with open("userge/xcache/recent_played_song.txt", "a") as f:
f.write("• [" + get_name + "]" + "(" + get_link + ")" + "\n")
await message.edit("`Getting recent played songs...`")
f = open("userge/xcache/recent_played_song.txt", "r+")
recent = f.read()
f.truncate(0)
with open("userge/xcache/recent_played_song.txt", "r+") as f:
recent = f.read()
f.truncate(0)
await message.edit(
"🎵 **Recently played songs:**\n" + recent, disable_web_page_preview=True
)
8 changes: 4 additions & 4 deletions userge/plugins/utils/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pymediainfo import MediaInfo

from userge import Message, userge
from userge.utils import thumb_from_audio
from userge.utils import runcmd, thumb_from_audio

CACHE = "userge/xcache/circle"
PATH = os.path.join(CACHE, "temp_vid.mp4")
Expand Down Expand Up @@ -44,7 +44,7 @@ async def video_note(message: Message):
width = track.width
if aspect_ratio != 1:
crop_by = width if (height > width) else height
os.system(f'ffmpeg -i {note} -vf "crop={crop_by}:{crop_by}" {PATH}')
await runcmd(f'ffmpeg -i {note} -vf "crop={crop_by}:{crop_by}" {PATH}')
os.remove(note)
else:
os.rename(note, PATH)
Expand All @@ -61,8 +61,8 @@ async def video_note(message: Message):
if thumb:
os.rename(thumb, thumb_loc)
else:
thumb_from_audio(audio_loc, thumb_loc)
os.system(
await thumb_from_audio(audio_loc, thumb_loc)
await runcmd(
f"ffmpeg -loop 1 -i {thumb_loc} -i {audio_loc} -c:v libx264 -tune stillimage -c:a aac -b:a 192k -vf \"scale='iw-mod (iw,2)':'ih-mod(ih,2)',format=yuv420p\" -shortest -movflags +faststart {PATH}"
)
if os.path.exists(PATH):
Expand Down
2 changes: 1 addition & 1 deletion userge/plugins/utils/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def translateme(message: Message):
text = message.filtered_input_str
flags = message.flags
if message.reply_to_message:
text = message.reply_to_message.text
text = message.reply_to_message.text or message.reply_to_message.caption
if not text:
await message.err(
text="Give a text or reply to a message to translate!\nuse `.help tr`"
Expand Down
6 changes: 3 additions & 3 deletions userge/utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def mention_markdown(user_id, name):

#------------------------

def thumb_from_audio(audio_path, output):
os.system(f'ffmpeg -i {audio_path} -filter:v scale=500:500 -an {output}')
async def thumb_from_audio(audio_path, output):
await runcmd(f'ffmpeg -i {audio_path} -filter:v scale=500:500 -an {output}')


def rand_array(array):
Expand All @@ -109,4 +109,4 @@ def rand_array(array):
async def download_link(url):
dest = Config.DOWN_PATH
obj = SmartDL(url, dest)
return obj.get_dest()
return obj.get_dest()

1 comment on commit 53910fe

@vercel
Copy link

@vercel vercel bot commented on 53910fe Oct 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.