forked from VJBots/VJ-Url-Uploader-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
330 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import os | ||
import re | ||
from os import environ, getenv | ||
|
||
id_pattern = re.compile(r'^.\d+$') | ||
def is_enabled(value, default): | ||
if value.lower() in ["true", "yes", "1", "enable", "y"]: | ||
return True | ||
elif value.lower() in ["false", "no", "0", "disable", "n"]: | ||
return False | ||
else: | ||
return default | ||
|
||
class Config(object): | ||
# Bot Information | ||
TECH_VJ_BOT_TOKEN = os.environ.get("TECH_VJ_BOT_TOKEN", "") | ||
TECH_VJ_BOT_USERNAME = os.environ.get("TECH_VJ_BOT_USERNAME", "") # Bot username without @. | ||
|
||
# The Telegram API things | ||
TECH_VJ_API_ID = int(os.environ.get("TECH_VJ_API_ID", "")) | ||
TECH_VJ_API_HASH = os.environ.get("TECH_VJ_API_HASH", "") | ||
|
||
# the download location, where the HTTP Server runs | ||
TECH_VJ_DOWNLOAD_LOCATION = "./DOWNLOADS" | ||
|
||
# Telegram maximum file upload size | ||
TECH_VJ_MAX_FILE_SIZE = 50000000 | ||
TECH_VJ_TG_MAX_FILE_SIZE = 4194304000 #2097152000 | ||
TECH_VJ_FREE_USER_MAX_FILE_SIZE = 50000000 | ||
|
||
# chunk size that should be used with requests | ||
TECH_VJ_CHUNK_SIZE = int(128) | ||
# default thumbnail to be used in the videos | ||
|
||
# proxy for accessing youtube-dl in GeoRestricted Areas | ||
# Get your own proxy from https://github.com/rg3/youtube-dl/issues/1091#issuecomment-230163061 | ||
TECH_VJ_HTTP_PROXY = "" | ||
|
||
# maximum message length in Telegram | ||
TECH_VJ_MAX_MESSAGE_LENGTH = 4096 | ||
|
||
# set timeout for subprocess | ||
TECH_VJ_PROCESS_MAX_TIMEOUT = 3600 | ||
|
||
# your telegram account id | ||
TECH_VJ_OWNER_ID = int(os.environ.get("TECH_VJ_OWNER_ID", "")) | ||
TECH_VJ_SESSION_NAME = "VJ-URL-UPLOADER-BOT" | ||
|
||
# database uri (mongodb) | ||
TECH_VJ_DATABASE_URL = os.environ.get("TECH_VJ_DATABASE_URL", "") | ||
TECH_VJ_MAX_RESULTS = "50" | ||
|
||
# channel information | ||
TECH_VJ_LOG_CHANNEL = int(os.environ.get("TECH_VJ_LOG_CHANNEL", "-1001623633000")) # your log channel id and make bot admin in log channel with full right | ||
|
||
# if you want force subscribe then give your channel id below else leave blank | ||
tech_vj_update_channel = environ.get('TECH_VJ_UPDATES_CHANNEL', '-1001623633000') # your update channel id and make bot admin in update channel with full right | ||
TECH_VJ_UPDATES_CHANNEL = int(tech_vj_update_channel) if tech_vj_update_channel and id_pattern.search(tech_vj_update_channel) else None | ||
|
||
# Url Shortner Information | ||
TECH_VJ = bool(environ.get('TECH_VJ', True)) # Set False If you want shortlink off else True | ||
TECH_VJ_URL = environ.get('TECH_VJ_URL', 'moneykamalo.com') # your shortlink url domain or url without https:// | ||
TECH_VJ_API = environ.get('TECH_VJ_API', '0eefb93e1e3ce9470a7033115ceb1bad13a9d674') # your url shortner api | ||
TECH_VJ_TUTORIAL = os.environ.get("TECH_VJ_TUTORIAL", "https://t.me/How_To_Open_Linkl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
numpy | ||
yt-dlp | ||
Pillow | ||
aiohttp | ||
hachoir | ||
olefile | ||
requests | ||
tgcrypto | ||
aiofiles | ||
dnspython | ||
motor[srv] | ||
beautifulsoup4 | ||
pyrogram==1.4.16 | ||
datetime | ||
pytz | ||
requests | ||
bs4 | ||
Flask==1.1.2 | ||
gunicorn==20.1.0 | ||
Jinja2==3.0.3 | ||
werkzeug==2.0.2 | ||
itsdangerous==2.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python-3.11.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton | ||
|
||
|
||
class Translation(object): | ||
|
||
TECH_VJ_START_TEXT = """ | ||
<b>ʜᴇʟʟᴏ {} 👋 | ||
ɪ ᴀᴍ ᴀ ᴘᴏᴡᴇʀғᴜʟ ᴀᴅᴠᴀɴᴄᴇ ᴜʀʟ ᴜᴘʟᴏᴀᴅᴇʀ ʙᴏᴛ | ||
ɢɪᴠᴇ ᴍᴇ ᴀɴʏ ʟɪɴᴋ ɪ ᴡɪʟʟ ᴜᴘʟᴏᴀᴅ ɪɴᴛᴏ ғɪʟᴇ ᴏʀ ᴠɪᴅᴇᴏ ᴡɪᴛʜ ᴄᴜsᴛᴏᴍ ᴛʜᴜᴍʙɴᴀɪʟ sᴜᴘᴘᴏʀᴛ | ||
ᴛʜɪs ʙᴏᴛ ɪs ᴘᴏᴡᴇʀᴇᴅ ʙʏ <a href="https://t.me/kingvj01">ᴛᴇᴄʜ ᴠᴊ</a></b> | ||
""" | ||
|
||
TECH_VJ_HELP_TEXT = """ | ||
<b>🖍️ ғᴇᴀᴛᴜʀᴇs :- | ||
🔺 ᴜᴘʟᴏᴀᴅ <a href="https://t.me/VJCode/4">ʏᴛ-ᴅʟᴘ sᴜᴘᴘᴏʀᴛᴇᴅ ʟɪɴᴋs</a> ᴛᴏ ᴛᴇʟᴇɢʀᴀᴍ. | ||
🔺 ᴜᴘʟᴏᴀᴅ ʜᴛᴛᴘ/ʜᴛᴛᴘs ᴀs ғɪʟᴇ/ᴠɪᴅᴇᴏ ᴛᴏ ᴛᴇʟᴇɢʀᴀᴍ. | ||
🔺 ᴜᴘʟᴏᴀᴅ ᴢᴇᴇ5, sᴏɴʏ.ʟɪᴠᴇ, ᴠᴏᴏᴛ ᴀɴᴅ ᴍᴜᴄʜ ᴍᴏʀᴇ. | ||
🔺 ᴘᴇʀᴍᴀɴᴇɴᴛ ᴛʜᴜᴍʙɴᴀɪʟ Sᴜᴘᴘᴏʀᴛ. | ||
🔺 ʙʀᴏᴀᴅᴄᴀsᴛ ᴍᴇssᴀɢᴇ ʙʏ /broadcast ᴄᴏᴍᴍᴀɴᴅ | ||
💢 ʜᴏᴡ ᴛᴏ ᴜsᴇ ᴍᴇ :- | ||
🔻 ʜᴏᴡ ᴛᴏ ᴜᴘʟᴏᴀᴅ ʏᴏᴜᴛᴜʙᴇ ʟɪɴᴋs <a href="https://t.me/VJCode/11">ᴛᴜᴛᴏʀɪᴀʟ ᴠɪᴅᴇᴏ</a> | ||
🔻 sᴇɴᴅ ᴍᴇ ᴛʜᴇ ɢᴏᴏɢʟᴇ ᴅʀɪᴠᴇ | ʏᴛᴅʟ | ᴅɪʀᴇᴄᴛ ʟɪɴᴋs. | ||
🔻sᴇʟᴇᴄᴛ ᴛʜᴇ ᴅᴇsɪʀᴇᴅ ᴏᴘᴛɪᴏɴ. | ||
🔻 ᴛʜᴇɴ ʙᴇ ʀᴇʟᴀxᴇᴅ ʏᴏᴜʀ ғɪʟᴇ ᴡɪʟʟ ʙᴇ ᴜᴘʟᴏᴀᴅᴇᴅ sᴏᴏɴ..</b> | ||
""" | ||
|
||
TECH_VJ_ABOUT_TEXT = """ | ||
<b>♻️ ᴍʏ ɴᴀᴍᴇ : ᴜʀʟ ᴜᴘʟᴏᴀᴅᴇʀ ʙᴏᴛ | ||
🌀 ᴄʜᴀɴɴᴇʟ : <a href="https://t.me/vj_botz">ᴠᴊ ʙᴏᴛᴢ</a> | ||
🌺 ʜᴇʀᴏᴋᴜ : <a href="https://heroku.com/">ʜᴇʀᴏᴋᴜ</a> | ||
📑 ʟᴀɴɢᴜᴀɢᴇ : <a href="https://www.python.org/">ᴘʏᴛʜᴏɴ 3.10.5</a> | ||
🇵🇲 ғʀᴀᴍᴇᴡᴏʀᴋ : <a href="https://docs.pyrogram.org/">ᴘʏʀᴏɢʀᴀᴍ 2.0.30</a> | ||
👲 ᴅᴇᴠᴇʟᴏᴘᴇʀ : <a href="https://t.me/kingvj01">ᴛᴇᴄʜ ᴠᴊ</a></b> | ||
""" | ||
|
||
|
||
TECH_VJ_START_BUTTONS = InlineKeyboardMarkup( | ||
[[ | ||
InlineKeyboardButton('💝 sᴜʙsᴄʀɪʙᴇ ᴍʏ ʏᴏᴜᴛᴜʙᴇ ᴄʜᴀɴɴᴇʟ', url='https://youtube.com/@Tech_VJ') | ||
], [ | ||
InlineKeyboardButton('🔍 sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ', url='https://t.me/vj_bot_disscussion'), | ||
InlineKeyboardButton('🤖 ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ', url='https://t.me/vj_botz') | ||
], [ | ||
InlineKeyboardButton('❓ ʜᴇʟᴘ', callback_data='help'), | ||
InlineKeyboardButton('🦊 ᴀʙᴏᴜᴛ', callback_data='about') | ||
], [ | ||
InlineKeyboardButton('🇮🇳 ғᴏʟʟᴏᴡ ᴍᴇ ᴏɴ ɪɴsᴛᴀɢʀᴀᴍ 💖', url='https://instagram.com/tech.vj') | ||
]] | ||
) | ||
TECH_VJ_HELP_BUTTONS = InlineKeyboardMarkup( | ||
[[ | ||
InlineKeyboardButton('💝 sᴜʙsᴄʀɪʙᴇ ᴍʏ ʏᴏᴜᴛᴜʙᴇ ᴄʜᴀɴɴᴇʟ', url='https://youtube.com/@Tech_VJ') | ||
], [ | ||
InlineKeyboardButton('🔍 sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ', url='https://t.me/vj_bot_disscussion'), | ||
InlineKeyboardButton('🤖 ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ', url='https://t.me/vj_botz') | ||
], [ | ||
InlineKeyboardButton('🏠 ʜᴏᴍᴇ', callback_data='home'), | ||
InlineKeyboardButton('🦊 ᴀʙᴏᴜᴛ', callback_data='about') | ||
], [ | ||
InlineKeyboardButton('📛 ᴄʟᴏsᴇ', callback_data='close') | ||
]] | ||
) | ||
TECH_VJ_ABOUT_BUTTONS = InlineKeyboardMarkup( | ||
[[ | ||
InlineKeyboardButton('💝 sᴜʙsᴄʀɪʙᴇ ᴍʏ ʏᴏᴜᴛᴜʙᴇ ᴄʜᴀɴɴᴇʟ', url='https://youtube.com/@Tech_VJ') | ||
], [ | ||
InlineKeyboardButton('🔍 sᴜᴘᴘᴏʀᴛ ɢʀᴏᴜᴘ', url='https://t.me/vj_bot_disscussion'), | ||
InlineKeyboardButton('🤖 ᴜᴘᴅᴀᴛᴇ ᴄʜᴀɴɴᴇʟ', url='https://t.me/vj_botz') | ||
], [ | ||
InlineKeyboardButton('🏠 ʜᴏᴍᴇ', callback_data='home'), | ||
InlineKeyboardButton('❓ ʜᴇʟᴘ', callback_data='help') | ||
], [ | ||
InlineKeyboardButton('📛 ᴄʟᴏsᴇ', callback_data='close') | ||
]] | ||
) | ||
|
||
TECH_VJ_ERROR = "<b>ᴇʀʀᴏʀ : {}</b>" | ||
|
||
|
||
TECH_VJ_FORMAT_SELECTION = "<b>ꜱᴇʟᴇᴄᴛ ᴛʜᴇ ᴅᴇꜱɪʀᴇᴅ ғᴏʀᴍᴀᴛ: ғɪʟᴇ ꜱɪᴢᴇ ᴍɪɢʜᴛ ʙᴇ ᴀᴘᴘʀᴏxɪᴍᴀᴛᴇ \nɪғ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ꜱᴇᴛ ᴄᴜꜱᴛᴏᴍ ᴛʜᴜᴍʙɴᴀɪʟ, ꜱᴇɴᴅ ᴘʜᴏᴛᴏ ʙᴇғᴏʀᴇ ᴏʀ ǫᴜɪᴄᴋʟʏ ᴀғᴛᴇʀ ᴛᴀᴘᴘɪɴɢ ᴏɴ ᴀɴʏ ᴏғ ᴛʜᴇ ʙᴇʟᴏᴡ ʙᴜᴛᴛᴏɴꜱ.\nʏᴏᴜ ᴄᴀɴ ᴜꜱᴇ /delthumbnail ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴛʜᴇ ᴀᴜᴛᴏ-ɢᴇɴᴇʀᴀᴛᴇᴅ ᴛʜᴜᴍʙɴᴀɪʟ.</b>" | ||
TECH_VJ_SET_CUSTOM_USERNAME_PASSWORD = """<b>Iғ ʏᴏᴜ ᴡᴀɴᴛ ᴛᴏ ᴅᴏᴡɴʟᴏᴀᴅ ᴘʀᴇᴍɪᴜᴍ ᴠɪᴅᴇᴏꜱ, ᴘʀᴏᴠɪᴅᴇ ɪɴ ᴛʜᴇ ғᴏʟʟᴏᴡɪɴɢ ғᴏʀᴍᴀᴛ:\nURL | ғɪʟᴇɴᴀᴍᴇ | ᴜꜱᴇʀɴᴀᴍᴇ | ᴘᴀꜱꜱᴡᴏʀᴅ</b>""" | ||
TECH_VJ_DOWNLOAD_START = "<b>📥 ᴅᴏᴡɴʟᴏᴀᴅɪɴɢ...</b>" | ||
TECH_VJ_UPLOAD_START = "<b>📤 ᴜᴘʟᴏᴀᴅɪɴɢ...</b>" | ||
TECH_VJ_RCHD_TG_API_LIMIT = "<b>ᴅᴏᴡɴʟᴏᴀᴅᴇᴅ ɪɴ {} ꜱᴇᴄᴏɴᴅꜱ.\nᴅᴇᴛᴇᴄᴛᴇᴅ ғɪʟᴇ ꜱɪᴢᴇ: {}\nꜱᴏʀʀʏ. ʙᴜᴛ, ɪ ᴄᴀɴɴᴏᴛ ᴜᴘʟᴏᴀᴅ ғɪʟᴇꜱ ɢʀᴇᴀᴛᴇʀ ᴛʜᴀɴ 𝟸GB ᴅᴜᴇ ᴛᴏ ᴛᴇʟᴇɢʀᴀᴍ API ʟɪᴍɪᴛᴀᴛɪᴏɴꜱ.</b>" | ||
TECH_VJ_AFTER_SUCCESSFUL_UPLOAD_MSG = "<b>ᴛʜᴀɴᴋꜱ ғᴏʀ ᴜꜱɪɴɢ ᴍᴇ\n\nJᴏɪɴ : @VJ_BOTZ</b>" | ||
TECH_VJ_AFTER_SUCCESSFUL_UPLOAD_MSG_WITH_TS = "<b>ᴅᴏᴡɴʟᴏᴀᴅᴇᴅ ɪɴ {} ꜱᴇᴄᴏɴᴅꜱ.\nUᴘʟᴏᴀᴅᴇᴅ ɪɴ {} ꜱᴇᴄᴏɴᴅꜱ.\n\n@VJ_BOTZ</b>" | ||
TECH_VJ_SAVED_CUSTOM_THUMB_NAIL = "<b>ᴄᴜꜱᴛᴏᴍ ᴠɪᴅᴇᴏ / ғɪʟᴇ ᴛʜᴜᴍʙɴᴀɪʟ ꜱᴀᴠᴇᴅ. Tʜɪꜱ ɪᴍᴀɢᴇ ᴡɪʟʟ ʙᴇ ᴜꜱᴇᴅ ɪɴ ᴛʜᴇ ᴠɪᴅᴇᴏ / ғɪʟᴇ.</b>" | ||
TECH_VJ_DEL_ETED_CUSTOM_THUMB_NAIL = "<b>✅ ᴄᴜꜱᴛᴏᴍ ᴛʜᴜᴍʙɴᴀɪʟ ᴄʟᴇᴀʀᴇᴅ ꜱᴜᴄᴄᴇꜱғᴜʟʟʏ.</b>" | ||
TECH_VJ_CUSTOM_CAPTION_UL_FILE = "<b>{}</b>" | ||
TECH_VJ_NO_VOID_FORMAT_FOUND = "<b>ᴇʀʀᴏʀ...\nTᴇᴄʜ VJ ꜱᴀɪᴅ: {}</b>" | ||
TECH_VJ_REPLY_TO_MEDIA_ALBUM_TO_GEN_THUMB = "<b>ʀᴇᴘʟʏ /generatecustomthumbnail ᴛᴏ ᴀ ᴍᴇᴅɪᴀ ᴀʟʙᴜᴍ, ᴛᴏ ɢᴇɴᴇʀᴀᴛᴇ ᴄᴜꜱᴛᴏᴍ ᴛʜᴜᴍʙᴀɪʟ</b>" | ||
TECH_VJ_ERR_ONLY_TWO_MEDIA_IN_ALBUM = """<b>ᴍᴇᴅɪᴀ ᴀʟʙᴜᴍ ꜱʜᴏᴜʟᴅ ᴄᴏɴᴛᴀɪɴ ᴏɴʟʏ ᴛᴡᴏ ᴘʜᴏᴛᴏꜱ. ᴘʟᴇᴀꜱᴇ ʀᴇ-ꜱᴇɴᴅ ᴛʜᴇ ᴍᴇᴅɪᴀ ᴀʟʙᴜᴍ, ᴀɴᴅ ᴛʜᴇɴ ᴛʀʏ ᴀɢᴀɪɴ, ᴏʀ ꜱᴇɴᴅ ᴏɴʟʏ ᴛᴡᴏ ᴘʜᴏᴛᴏꜱ ɪɴ ᴀɴ ᴀʟʙᴜᴍ.\nʏᴏᴜ ᴄᴀɴ ᴜꜱᴇ /ʀᴇɴᴀᴍᴇ ᴄᴏᴍᴍᴀɴᴅ ᴀғᴛᴇʀ ʀᴇᴄᴇɪᴠɪɴɢ ғɪʟᴇ ᴛᴏ ʀᴇɴᴀᴍᴇ ɪᴛ ᴡɪᴛʜ ᴄᴜꜱᴛᴏᴍ ᴛʜᴜᴍʙɴᴀɪʟ ꜱᴜᴘᴘᴏʀᴛ.</b>""" | ||
TECH_VJ_CANCEL_STR = "<b>ᴘʀᴏᴄᴇꜱꜱ ᴄᴀɴᴄᴇʟʟᴇᴅ</b>" | ||
TECH_VJ_ZIP_UPLOADED_STR = "<b>ᴜᴘʟᴏᴀᴅᴇᴅ {} ғɪʟᴇꜱ ɪɴ {} ꜱᴇᴄᴏɴᴅꜱ</b>" | ||
TECH_VJ_SLOW_URL_DECED = "<b>Gᴏꜱʜ ᴛʜᴀᴛ ꜱᴇᴇᴍꜱ ᴛᴏ ʙᴇ ᴀ ᴠᴇʀʏ ꜱʟᴏᴡ URL. Sɪɴᴄᴇ ʏᴏᴜ ᴡᴇʀᴇ ꜱᴄʀᴇᴡɪɴɢ ᴍʏ ʜᴏᴍᴇ, I ᴀᴍ ɪɴ ɴᴏ ᴍᴏᴏᴅ ᴛᴏ ᴅᴏᴡɴʟᴏᴀᴅ ᴛʜɪꜱ ғɪʟᴇ. ᴍᴇ ᴀ ғᴀꜱᴛ URL ꜱᴏ ᴛʜᴀᴛ I ᴄᴀɴ ᴜᴘʟᴏᴀᴅ ᴛᴏ Tᴇʟᴇɢʀᴀᴍ, ᴡɪᴛʜᴏᴜᴛ ᴍᴇ ꜱʟᴏᴡɪɴɢ ᴅᴏᴡɴ ғᴏʀ ᴏᴛʜᴇʀ ᴜꜱᴇʀꜱ.</b>" | ||
|
||
TECH_VJ_ERROR_YTDLP = "<b>ᴘʟᴇᴀꜱᴇ ʀᴇᴘᴏʀᴛ ᴛʜɪꜱ ɪꜱꜱᴜᴇ ᴏɴ https://yt-dl.org/bug . ᴍᴀᴋᴇ ꜱᴜʀᴇ ʏᴏᴜ ᴀʀᴇ ᴜꜱɪɴɢ ᴛʜᴇ ʟᴀᴛᴇꜱᴛ ᴠᴇʀꜱɪᴏɴ; ꜱᴇᴇ https://yt-dl.org/update ᴏɴ ʜᴏᴡ ᴛᴏ ᴜᴘᴅᴀᴛᴇ. ʙᴇ ꜱᴜʀᴇ ᴛᴏ ᴄᴀʟʟ ʏᴏᴜᴛᴜʙᴇ-ᴅʟ ᴡɪᴛʜ ᴛʜᴇ --ᴠᴇʀʙᴏꜱᴇ ғʟᴀɢ ᴀɴᴅ ɪɴᴄʟᴜᴅᴇ ɪᴛꜱ ᴄᴏᴍᴘʟᴇᴛᴇ ᴏᴜᴛᴘᴜᴛ.</b>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import asyncio | ||
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup | ||
from pyrogram.errors import FloodWait, UserIsBlocked, MessageNotModified, PeerIdInvalid | ||
from typing import Union | ||
import pytz | ||
import random | ||
import re | ||
import os | ||
from datetime import datetime, date | ||
import string | ||
from typing import List | ||
from database.users_chats_db import tech_vj | ||
from bs4 import BeautifulSoup | ||
import requests | ||
import aiohttp | ||
import json | ||
from config import Config | ||
|
||
|
||
TOKENS = {} | ||
VERIFIED = {} | ||
|
||
LOG_TEXT_P = """#NewUser | ||
ID - <code>{}</code> | ||
Nᴀᴍᴇ - {}""" | ||
|
||
|
||
async def get_verify_shorted_link(link): | ||
API = Config.TECH_VJ_API | ||
URL = Config.TECH_VJ_URL | ||
https = link.split(":")[0] | ||
if "http" == https: | ||
https = "https" | ||
link = link.replace("http", https) | ||
|
||
if URL == "api.shareus.in": | ||
url = f"https://{URL}/shortLink" | ||
params = {"token": API, | ||
"format": "json", | ||
"link": link, | ||
} | ||
try: | ||
async with aiohttp.ClientSession() as session: | ||
async with session.get(url, params=params, raise_for_status=True, ssl=False) as response: | ||
data = await response.json(content_type="text/html") | ||
if data["status"] == "success": | ||
return data["shortlink"] | ||
else: | ||
logger.error(f"Error: {data['message']}") | ||
return f'https://{URL}/shortLink?token={API}&format=json&link={link}' | ||
|
||
except Exception as e: | ||
logger.error(e) | ||
return f'https://{URL}/shortLink?token={API}&format=json&link={link}' | ||
else: | ||
url = f'https://{URL}/api' | ||
params = {'api': API, | ||
'url': link, | ||
} | ||
try: | ||
async with aiohttp.ClientSession() as session: | ||
async with session.get(url, params=params, raise_for_status=True, ssl=False) as response: | ||
data = await response.json() | ||
if data["status"] == "success": | ||
return data['shortenedUrl'] | ||
else: | ||
logger.error(f"Error: {data['message']}") | ||
return f'https://{URL}/api?api={API}&link={link}' | ||
|
||
except Exception as e: | ||
logger.error(e) | ||
return f'{URL}/api?api={API}&link={link}' | ||
|
||
async def check_token(bot, userid, token): | ||
user = await bot.get_users(userid) | ||
if not await tech_vj.is_user_exist(user.id): | ||
await tech_vj.add_user(user.id, user.first_name) | ||
await bot.send_message(Config.TECH_VJ_LOG_CHANNEL, LOG_TEXT_P.format(user.id, user.mention)) | ||
if user.id in TOKENS.keys(): | ||
TKN = TOKENS[user.id] | ||
if token in TKN.keys(): | ||
is_used = TKN[token] | ||
if is_used == True: | ||
return False | ||
else: | ||
return True | ||
else: | ||
return False | ||
|
||
async def get_token(bot, userid, link): | ||
user = await bot.get_users(userid) | ||
if not await tech_vj.is_user_exist(user.id): | ||
await tech_vj.add_user(user.id, user.first_name) | ||
await bot.send_message(Config.TECH_VJ_LOG_CHANNEL, LOG_TEXT_P.format(user.id, user.mention)) | ||
token = ''.join(random.choices(string.ascii_letters + string.digits, k=7)) | ||
TOKENS[user.id] = {token: False} | ||
link = f"{link}verify-{user.id}-{token}" | ||
shortened_verify_url = await get_verify_shorted_link(link) | ||
return str(shortened_verify_url) | ||
|
||
async def verify_user(bot, userid, token): | ||
user = await bot.get_users(userid) | ||
if not await tech_vj.is_user_exist(user.id): | ||
await tech_vj.add_user(user.id, user.first_name) | ||
await bot.send_message(Config.TECH_VJ_LOG_CHANNEL, LOG_TEXT_P.format(user.id, user.mention)) | ||
TOKENS[user.id] = {token: True} | ||
tz = pytz.timezone('Asia/Kolkata') | ||
today = date.today() | ||
VERIFIED[user.id] = str(today) | ||
|
||
async def check_verification(bot, userid): | ||
user = await bot.get_users(userid) | ||
if not await tech_vj.is_user_exist(user.id): | ||
await tech_vj.add_user(user.id, user.first_name) | ||
await bot.send_message(Config.TECH_VJ_LOG_CHANNEL, LOG_TEXT_P.format(user.id, user.mention)) | ||
tz = pytz.timezone('Asia/Kolkata') | ||
today = date.today() | ||
if user.id in VERIFIED.keys(): | ||
EXP = VERIFIED[user.id] | ||
years, month, day = EXP.split('-') | ||
comp = date(int(years), int(month), int(day)) | ||
if comp<today: | ||
return False | ||
else: | ||
return True | ||
else: | ||
return False |