Skip to content

Commit

Permalink
Refactor config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-lymar committed Sep 18, 2024
1 parent 41b0297 commit dad9855
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 72 deletions.
4 changes: 2 additions & 2 deletions app/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def load_proxies_from_file(file_path):
'name': 'Pin Out Master',
'app_token': 'd2378baf-d617-417a-9d99-d685824335f0',
'promo_id': 'd2378baf-d617-417a-9d99-d685824335f0',
'base_delay': 30,
'base_delay': 20,
'attempts': 35,
'copies': 90,
},
Expand All @@ -121,7 +121,7 @@ def load_proxies_from_file(file_path):
'app_token': '4bdc17da-2601-449b-948e-f8c7bd376553',
'promo_id': '4bdc17da-2601-449b-948e-f8c7bd376553',
'base_delay': 30,
'attempts': 35,
'attempts': 40,
'copies': 90,
}
]
Expand Down
Empty file added bot/common/__init__.py
Empty file.
19 changes: 19 additions & 0 deletions bot/common/referals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
REFERRAL_LINKS = {
'Cats 🐈‍⬛': 'https://t.me/catsgang_bot/join?startapp=Lv39AXNhcBvwK6ZWcoGpD',
'🅧 X Empire': 't.me/empirebot/game?startapp=hero452792586',
'Binance Moonbix 🟠': 'https://t.me/Binance_Moonbix_bot/start?startapp=ref_452792586&startApp=ref_452792586',
'🥠 Hrum': 't.me/hrummebot/game?startapp=ref452792586',
'🏠 CITY Holder': 'https://t.me/cityholder/game?startapp=452792586',
'🤖 TapSwap': 'https://t.me/tapswap_mirror_2_bot?start=r_452792586',
'⚫️ DotCoin': 'https://t.me/dotcoin_bot?start=r_452792586',
'🖲️ CEX.IO Power Tap': 'https://t.me/cexio_tap_bot?start=1716399236183636',
'⭐ Major': 'https://t.me/major/start?startapp=452792586',
'😺 Catizen': 'https://t.me/catizenbot/gameapp?startapp=r_2779_5703457',
'🪙 Blum': 'https://t.me/blum/app?startapp=ref_8U6nYohQav',
'👾 Not Pixel': 'https://t.me/notpixel/app?startapp=f452792586',
'🐸 Frog Trader': 'https://t.me/xkucoinbot/kucoinminiapp?startapp'
'=cm91dGU9JTJGdGFwLWdhbWUlM0ZpbnZpdGVyVXNlcklkJTNENDUyNzkyNTg2JTI2cmNvZGUlM0Q=',
'🔥 HOT Wallet': 'https://t.me/herewalletbot/app?startapp=9477477',
'Binance 🔶': 'https://www.binance.com/activity/referral-entry/CPA?ref=CPA_009SJLVSMT',
'Bybit ⚫️': 'https://www.bybit.com/invite?ref=ZYJQX3B',
}
36 changes: 36 additions & 0 deletions bot/common/static_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Supported languages
SUPPORTED_LANGUAGES = ['en', 'ru', 'uk', 'sk', 'es', 'fr', 'tr', 'ar', 'de', 'fa', 'ur', 'hi']

ACHIEVEMENTS = [
"newcomer", "key_seeker",
"bonus_hunter", "code_expert",
"key_master", "elite_player",
"game_legend", "absolute_leader"
]


GAMES = [
'Pin Out Master',
'Count Masters',
'Hide Ball',
'Bouncemasters',
'Merge Away',
'Stone Age',
'Train Miner',
'Mow and Trim',
'Chain Cube 2048',
'Fluff Crusade',
'Polysphere',
'Twerk Race 3D',
'Zoopolis',
'Tile Trio'
]

STATUS_LIMITS = {
'free': {'daily_limit': 2, 'interval_minutes': 10},
'friend': {'daily_limit': 5, 'interval_minutes': 10},
'premium': {
'daily_limit': 4, 'interval_minutes': 10,
'safety_daily_limit': 2, 'safety_interval_minutes': 240
}
}
57 changes: 0 additions & 57 deletions bot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,63 +13,6 @@
storage = MemoryStorage()
dp = Dispatcher(storage=storage)

# Supported languages
SUPPORTED_LANGUAGES = ['en', 'ru', 'uk', 'sk', 'es', 'fr', 'tr', 'ar', 'de', 'fa', 'ur', 'hi']

REFERRAL_LINKS = {
'Cats 🐈‍⬛': 'https://t.me/catsgang_bot/join?startapp=Lv39AXNhcBvwK6ZWcoGpD',
'🅧 X Empire': 't.me/empirebot/game?startapp=hero452792586',
'Binance Moonbix 🟠': 'https://t.me/Binance_Moonbix_bot/start?startapp=ref_452792586&startApp=ref_452792586',
'🥠 Hrum': 't.me/hrummebot/game?startapp=ref452792586',
'🏠 CITY Holder': 'https://t.me/cityholder/game?startapp=452792586',
'🤖 TapSwap': 'https://t.me/tapswap_mirror_2_bot?start=r_452792586',
'⚫️ DotCoin': 'https://t.me/dotcoin_bot?start=r_452792586',
'🖲️ CEX.IO Power Tap': 'https://t.me/cexio_tap_bot?start=1716399236183636',
'⭐ Major': 'https://t.me/major/start?startapp=452792586',
'😺 Catizen': 'https://t.me/catizenbot/gameapp?startapp=r_2779_5703457',
'🪙 Blum': 'https://t.me/blum/app?startapp=ref_8U6nYohQav',
'👾 Not Pixel': 'https://t.me/notpixel/app?startapp=f452792586',
'🐸 Frog Trader': 'https://t.me/xkucoinbot/kucoinminiapp?startapp'
'=cm91dGU9JTJGdGFwLWdhbWUlM0ZpbnZpdGVyVXNlcklkJTNENDUyNzkyNTg2JTI2cmNvZGUlM0Q=',
'🔥 HOT Wallet': 'https://t.me/herewalletbot/app?startapp=9477477',
'Binance 🔶': 'https://www.binance.com/activity/referral-entry/CPA?ref=CPA_009SJLVSMT',
'Bybit ⚫️': 'https://www.bybit.com/invite?ref=ZYJQX3B',
}


ACHIEVEMENTS = [
"newcomer", "key_seeker",
"bonus_hunter", "code_expert",
"key_master", "elite_player",
"game_legend", "absolute_leader"
]


GAMES = [
'Pin Out Master',
'Count Masters',
'Hide Ball',
'Bouncemasters',
'Merge Away',
'Stone Age',
'Train Miner',
'Mow and Trim',
'Chain Cube 2048',
'Fluff Crusade',
'Polysphere',
'Twerk Race 3D',
'Zoopolis',
'Tile Trio'
]

STATUS_LIMITS = {
'free': {'daily_limit': 2, 'interval_minutes': 10},
'friend': {'daily_limit': 5, 'interval_minutes': 10},
'premium': {
'daily_limit': 4, 'interval_minutes': 10,
'safety_daily_limit': 2, 'safety_interval_minutes': 240
}
}

# Forwarding message to group§
GROUP_CHAT_ID = int(os.getenv("GROUP_CHAT_ID", 0))
3 changes: 2 additions & 1 deletion bot/handlers/admin_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from aiogram import types, F, Router
from aiogram.fsm.context import FSMContext
from aiogram.types import InlineKeyboardMarkup, Message
from config import bot, BOT_ID, GAMES, GROUP_CHAT_ID
from config import bot, BOT_ID, GROUP_CHAT_ID
from common.static_data import GAMES
from database.database import (get_session, log_user_action, get_admin_chat_ids, get_keys_count_for_games,
get_users_list_admin_panel, get_user_details, get_subscribed_users)
from keyboards.inline import (get_admin_panel_keyboard, get_main_in_admin, get_detail_info_in_admin,
Expand Down
3 changes: 2 additions & 1 deletion bot/handlers/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import logging
from aiogram import types, F, Router
from aiogram.fsm.context import FSMContext
from config import bot, BOT_ID, GAMES, STATUS_LIMITS, SUPPORTED_LANGUAGES
from config import bot, BOT_ID
from common.static_data import GAMES, STATUS_LIMITS, SUPPORTED_LANGUAGES
from database.database import (
get_session, get_or_create_user, update_user_language, log_user_action,
get_user_language, get_oldest_keys, update_keys_generated,
Expand Down
2 changes: 1 addition & 1 deletion bot/keyboards/referral_links_kb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from config import REFERRAL_LINKS
from common.referals import REFERRAL_LINKS
from .back_to_main_kb import get_back_to_main_menu_button


Expand Down
18 changes: 9 additions & 9 deletions bot/redis_client.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import redis
import os
from dotenv import load_dotenv

import redis.asyncio as redis

load_dotenv()

# Configuring the Redis client
redis_client = redis.StrictRedis(
host='localhost',
port=6379,
host=os.getenv('REDIS_HOST', 'localhost'),
port=os.getenv('REDIS_PORT', 6379),
decode_responses=True
)

try:
redis_client.ping()
print("Successfully connected to Redis!")
except redis.ConnectionError:
print("Could not connect to Redis.")
2 changes: 1 addition & 1 deletion bot/utils/services.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime, timezone

from config import ACHIEVEMENTS
from common.static_data import ACHIEVEMENTS


def calculate_achievement(total_keys: int, total_premium_keys: int, days_in_bot: int) -> str:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ alembic==1.13.2
asyncpg==0.29.0
coloredlogs==15.0.1
flake8==7.1.1
greenlet==3.1.0
redis==5.0.8
python-dotenv==1.0.1
psycopg2-binary==2.9.9
Expand Down

0 comments on commit dad9855

Please sign in to comment.