Added socks5 proxy support

This commit is contained in:
Joan
2024-03-24 20:40:44 +01:00
parent a7eb633760
commit c31e155c74
5 changed files with 52 additions and 19 deletions

View File

@@ -10,7 +10,7 @@ import search_manager
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup, ForceReply
from telegram.constants import ParseMode
from telegram.ext import (
Application,
ApplicationBuilder,
CallbackQueryHandler,
CallbackContext,
CommandHandler,
@@ -27,7 +27,7 @@ ACTION, ADD_PRODUCT_NAME, ADD_PRODUCT_MIN_PRICE, ADD_PRODUCT_MAX_PRICE, \
ADD_PRODUCT_COORDS, ADD_PRODUCT_DISTANCE, REMOVE_PRODUCT, LIST, FINISH, CONTINUE_OR_FINISH = range(13)
MAX_PRODUCTS_TESTING = 5
MAX_PRODUCTS_PREMIUM = 30
MAX_PRODUCTS_PREMIUM = 5
MAX_PRODUCTS_HOMELABS = 5
# Enable logging
@@ -401,11 +401,11 @@ async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> N
telegram_user_id = helpers.get_telegram_user_id(update)
telegram_user_name = helpers.get_telegram_user_name(update)
#if not walladb.is_user_valid(telegram_user_id):
message = f"Bienvenido a @wallamanta_homelabs_vip, usa el comando /help para más información."
if telegram_user_id < 0:
message = "Este bot no se puede usar en grupos."
elif walladb.get_user(telegram_user_id) == "NoName":
walladb.enable_user(telegram_user_id, telegram_user_name)
message = f"Bienvenido a @wallamanta, usa el comando /help para más información."
elif walladb.is_user_premium(telegram_user_id):
message = f"Bienvenido a @wallamanta_homelabs_vip, usa el comando /help para más información."
await update.message.reply_markdown_v2(helpers.telegram_escape_characters(message))
async def add_to_db_and_send(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
@@ -480,7 +480,13 @@ def main()->None:
"""Start the bot."""
# Create the Application and pass it your bot's token.
application = Application.builder().get_updates_http_version('1.1').http_version('1.1').token(constants.TELEGRAM_TOKEN).build()
if constants.telegram_proxy:
logging.info("Creating application with socks5 proxy")
application = ApplicationBuilder().get_updates_http_version('1.1').http_version('1.1').token(constants.TELEGRAM_TOKEN).proxy(constants.proxy_url).get_updates_proxy(constants.proxy_url).build()
else:
logging.info("Creating application without socks5 proxy")
application = ApplicationBuilder().get_updates_http_version('1.1').http_version('1.1').token(constants.TELEGRAM_TOKEN).build()
p = threading.Thread(target=search_manager.work)
p.start()