Skip to content

Commit

Permalink
Remove "Deploy to Heroku" workflow support
Browse files Browse the repository at this point in the history
  • Loading branch information
l3v11 authored Oct 25, 2022
1 parent 28318d3 commit ef62f8b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 45 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/deploy.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ These four files are required to run the bot
## Deployment

These two guides are available to deploy the bot
- [Deploying to Heroku](https://github.com/l3v11/SearchX/wiki/Deploying-to-Heroku) (free)
- [Deploying to VPS](https://github.com/l3v11/SearchX/wiki/Deploying-to-VPS) (paid)
- [Deploying to Heroku](https://github.com/l3v11/SearchX/wiki/Deploying-to-Heroku)
- [Deploying to VPS](https://github.com/l3v11/SearchX/wiki/Deploying-to-VPS)

## Commands

Expand Down
14 changes: 7 additions & 7 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

DATABASE_URL = os.environ.get('DATABASE_URL', '')
if len(DATABASE_URL) == 0:
DATABASE_URL = None
DATABASE_URL = ''

IS_TEAM_DRIVE = os.environ.get('IS_TEAM_DRIVE', '')
IS_TEAM_DRIVE = IS_TEAM_DRIVE.lower() == 'true'
Expand All @@ -102,13 +102,13 @@

INDEX_URL = os.environ.get('INDEX_URL', '').rstrip("/")
if len(INDEX_URL) == 0:
INDEX_URL = None
INDEX_URL = ''

ARCHIVE_LIMIT = os.environ.get('ARCHIVE_LIMIT', '')
ARCHIVE_LIMIT = None if len(ARCHIVE_LIMIT) == 0 else float(ARCHIVE_LIMIT)
ARCHIVE_LIMIT = '' if len(ARCHIVE_LIMIT) == 0 else float(ARCHIVE_LIMIT)

CLONE_LIMIT = os.environ.get('CLONE_LIMIT', '')
CLONE_LIMIT = None if len(CLONE_LIMIT) == 0 else float(CLONE_LIMIT)
CLONE_LIMIT = '' if len(CLONE_LIMIT) == 0 else float(CLONE_LIMIT)

TOKEN_JSON_URL = os.environ.get('TOKEN_JSON_URL', '')
if len(TOKEN_JSON_URL) != 0:
Expand Down Expand Up @@ -152,12 +152,12 @@
APPDRIVE_EMAIL = os.environ.get('APPDRIVE_EMAIL', '')
APPDRIVE_PASS = os.environ.get('APPDRIVE_PASS', '')
if len(APPDRIVE_EMAIL) == 0 or len(APPDRIVE_PASS) == 0:
APPDRIVE_EMAIL = None
APPDRIVE_PASS = None
APPDRIVE_EMAIL = ''
APPDRIVE_PASS = ''

GDTOT_CRYPT = os.environ.get('GDTOT_CRYPT', '')
if len(GDTOT_CRYPT) == 0:
GDTOT_CRYPT = None
GDTOT_CRYPT = ''

if os.path.exists('drive_list'):
with open('drive_list', 'r+') as f:
Expand Down
1 change: 1 addition & 0 deletions bot/helper/drive_utils/gdriveTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(self, name=None, path=None, size=0, listener=None):
self.__total_folders = 0
self.__total_files = 0
self.__sa_count = 0
self.__service_account_index = 0
self.__start_time = 0
self.__total_time = 0
self.__alt_auth = False
Expand Down
29 changes: 25 additions & 4 deletions bot/helper/ext_utils/database.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
from pymongo import MongoClient

from bot import AUTHORIZED_USERS, DATABASE_URL
from bot import LOGGER, AUTHORIZED_USERS, DATABASE_URL

class DatabaseHelper:

def __init__(self):
self.mongodb = MongoClient(host=DATABASE_URL)["SearchX"]
self.col = self.mongodb["users"]
self.__err = False
self.__client = None
self.__db = None
self.__collection = None
self.__connect()

def __connect(self):
try:
self.__client = MongoClient(DATABASE_URL)
self.__db = self.client['SearchX']
self.__collection = self.db['users']
except PyMongoError as err:
LOGGER.error(err)
self.__err = True

def auth_user(self, user_id: int):
if self.__err:
return
self.col.insert_one({"user_id": user_id})
return 'Authorization granted'
self.__client.close()

def unauth_user(self, user_id: int):
if self.__err:
return
self.col.delete_many({"user_id": user_id})
return 'Authorization revoked'
self.__client.close()

def load_users(self):
if self.__err:
return
users = self.col.find().sort("user_id")
for user in users:
AUTHORIZED_USERS.add(user['user_id'])
AUTHORIZED_USERS.add(user["user_id"])
self.__client.close()

if DATABASE_URL is not None:
DatabaseHelper().load_users()
13 changes: 6 additions & 7 deletions bot/helper/telegram_helper/message_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

from telegram import InlineKeyboardMarkup
from telegram.error import RetryAfter
from telegram.message import Message

from bot import bot, LOGGER, Interval, STATUS_UPDATE_INTERVAL, \
status_reply_dict, status_reply_dict_lock
from bot.helper.ext_utils.bot_utils import SetInterval, get_readable_message

def sendMessage(text: str, bot, message: Message):
def sendMessage(text, bot, message):
try:
return bot.sendMessage(message.chat_id,
reply_to_message_id=message.message_id,
Expand All @@ -22,7 +21,7 @@ def sendMessage(text: str, bot, message: Message):
LOGGER.error(str(err))
return

def sendMarkup(text: str, bot, message: Message, reply_markup: InlineKeyboardMarkup):
def sendMarkup(text, bot, message, reply_markup: InlineKeyboardMarkup):
try:
return bot.sendMessage(message.chat_id,
reply_to_message_id=message.message_id,
Expand All @@ -36,7 +35,7 @@ def sendMarkup(text: str, bot, message: Message, reply_markup: InlineKeyboardMar
LOGGER.error(str(err))
return

def editMessage(text: str, message: Message, reply_markup=None):
def editMessage(text, message, reply_markup=None):
try:
bot.editMessageText(text=text, message_id=message.message_id,
chat_id=message.chat.id,
Expand All @@ -50,14 +49,14 @@ def editMessage(text: str, message: Message, reply_markup=None):
LOGGER.error(str(err))
return str(err)

def deleteMessage(bot, message: Message):
def deleteMessage(bot, message):
try:
bot.deleteMessage(chat_id=message.chat.id,
message_id=message.message_id)
except Exception as err:
except:
pass

def sendLogFile(bot, message: Message):
def sendLogFile(bot, message):
with open('log.txt', 'rb') as f:
bot.sendDocument(document=f, filename=f.name,
reply_to_message_id=message.message_id,
Expand Down
7 changes: 4 additions & 3 deletions bot/modules/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from html import escape
from telegram.ext import CommandHandler

from bot import LOGGER, dispatcher, DOWNLOAD_DIR, Interval, INDEX_URL, download_dict, download_dict_lock
from bot import LOGGER, dispatcher, DOWNLOAD_DIR, Interval, INDEX_URL, download_dict, download_dict_lock, status_reply_dict_lock
from bot.helper.download_utils.ddl_generator import appdrive, gdtot
from bot.helper.download_utils.gd_downloader import add_gd_download
from bot.helper.drive_utils.gdriveTools import GoogleDriveHelper
Expand All @@ -35,8 +35,9 @@ def __init__(self, bot, message, is_compress=False, is_extract=False, pswd=None)

def clean(self):
try:
Interval[0].cancel()
Interval.clear()
with status_reply_dict_lock:
Interval[0].cancel()
Interval.clear()
delete_all_messages()
except:
pass
Expand Down
4 changes: 2 additions & 2 deletions bot/modules/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def authorize(update, context):
user_id = ''
reply_message = update.message.reply_to_message
if len(context.args) == 1:
user_id = context.args[0]
user_id = int(context.args[0])
elif reply_message:
user_id = reply_message.from_user.id
if user_id:
Expand Down Expand Up @@ -38,7 +38,7 @@ def unauthorize(update, context):
user_id = ''
reply_message = update.message.reply_to_message
if len(context.args) == 1:
user_id = context.args[0]
user_id = int(context.args[0])
elif reply_message:
user_id = reply_message.from_user.id
if user_id:
Expand Down

0 comments on commit ef62f8b

Please sign in to comment.