Skip to content

Commit

Permalink
MAX_DURATION in config.env (UsergeTeam#324)
Browse files Browse the repository at this point in the history
* MAX_DURATION in config.env

* Update voice_call.py

* Update config.py

* Update config.env.sample

* Removed unwanted lines
  • Loading branch information
jigarvarma2k20 authored May 10, 2021
1 parent 5ea21f7 commit 1879d6f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions config.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ UNFINISHED_PROGRESS_STR='░'
# custom name for your sticker pack
CUSTOM_PACK_NAME=""

# custom audio max duration for voice chat plugin
MAX_DURATION=900


# set your own custom media for .alive or
# disable it by putting value 'nothing'
Expand Down
1 change: 1 addition & 0 deletions userge/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Config:
REMOVE_BG_API_KEY = os.environ.get("REMOVE_BG_API_KEY")
WEATHER_DEFCITY = os.environ.get("WEATHER_DEFCITY")
TZ_NUMBER = os.environ.get("TZ_NUMBER", 1)
MAX_DURATION = int(os.environ.get("MAX_DURATION", 900))
G_DRIVE_CLIENT_ID = os.environ.get("G_DRIVE_CLIENT_ID")
G_DRIVE_CLIENT_SECRET = os.environ.get("G_DRIVE_CLIENT_SECRET")
G_DRIVE_PARENT_ID = os.environ.get("G_DRIVE_PARENT_ID")
Expand Down
7 changes: 3 additions & 4 deletions userge/plugins/utils/voice_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@
from pyrogram.types.messages_and_media.message import Str
from pyrogram.errors import MessageDeleteForbidden

from userge import userge, Message, pool, filters, get_collection
from userge import userge, Message, pool, filters, get_collection, Config
from userge.utils import time_formatter
from userge.utils.exceptions import StopConversation

CHANNEL = userge.getCLogger(__name__)

VC_DB = get_collection("VC_CMDS_TOGGLE")
CMDS_FOR_ALL = False
MAX_DURATION = int(os.environ.get("MAX_DURATION", 900))

ADMINS = {}

Expand Down Expand Up @@ -508,7 +507,7 @@ async def tg_down(msg: Message):

global BACK_BUTTON_TEXT # pylint: disable=global-statement

if msg.audio.duration > MAX_DURATION:
if msg.audio.duration > Config.MAX_DURATION:
return await _skip()

message = await reply_text(msg, f"`Downloading {msg.audio.title}`")
Expand Down Expand Up @@ -576,7 +575,7 @@ def mp3_down(url: str):

with ytdl.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(url)
if info.get("duration") > MAX_DURATION:
if info.get("duration") > Config.MAX_DURATION:
return False

return info.get("title"), time_formatter(info.get("duration"))
Expand Down

0 comments on commit 1879d6f

Please sign in to comment.