Skip to content

Commit

Permalink
Update 4 files
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Oct 8, 2023
1 parent 91d2eec commit b1452d0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
10 changes: 6 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ SESSION_STRING=""

# POSTGRES SETTINGS
PGUSER="postgres"
POSTGRES_DB=""
POSTGRES_USER=""
POSTGRES_PASSWORD=""
POSTGRES_HOST_AUTH_METHOD=""
POSTGRES_DB="..."
POSTGRES_USER="..."
POSTGRES_PASSWORD="..."
POSTGRES_HOST="localhost"
POSTGRES_PORT="5432"
POSTGRES_HOST_AUTH_METHOD="trust"

# PGADMIN SETTINGS
PGADMIN_DEFAULT_EMAIL=""
Expand Down
41 changes: 31 additions & 10 deletions bot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import os
import logging
from redis import Redis
import sqlalchemy as db
from pyrogram import Client
from termcolor import colored
from bot.config import config
from pytgcalls import GroupCallFactory

from bot.config import config
from bot.utils.driver import get_driver

# PyTgcalls Instances
VOICE_CHATS = {}
BOT_USERNAME = config.BOT_USERNAME

# CONFIG
_API_ID = config.API_ID
_API_HASH = config.API_ID
_BOT_TOKEN = config.BOT_TOKEN
_SESSION_STRING = config.SESSION_STRING
_REDIS_PORT = config.REDIS_PORT
_REDIS_PASSWORD = config.REDIS_PASSWORD
_POSTGRES_DB = config.POSTGRES_DB
_POSTGRES_USER = config._POSTGRES_USER
_POSTGRES_PASSWORD = config.POSTGRES_PASSWORD
_POSTGRES_HOST = config.POSTGRES_HOST
_POSTGRES_PORT = config.POSTGRES_PORT


_logs_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "logs")
_logs_file = os.path.join(_logs_dir, "kreacher.log")
Expand Down Expand Up @@ -36,23 +52,28 @@
# Bot Client
kreacher = Client(
"bot.kreacher",
api_id=config.API_ID,
api_hash=config.API_HASH,
bot_token=config.BOT_TOKEN,
api_id=API_ID,
api_hash=API_HASH,
bot_token=_BOT_TOKEN,
)

# UserBot Client
assistant = Client(
"userbot.assistant",
api_id=config.API_ID,
api_hash=config.API_HASH,
session_string=config.SESSION_STRING,
api_id=_API_ID,
api_hash=_API_HASH,
session_string=_SESSION_STRING,
)

_engine = db.create_engine(
f"postgresql://{_POSTGRES_USER}:{_POSTGRES_PASSWORD}@{_POSTGRES_HOST}:{POSTGRES_PORT}/{_POSTGRES_DB}"
)
conn = _engine.connect()

r = Redis(
host="localhost",
port=config.REDIS_PORT,
password=config.REDIS_PASSWORD,
port=_REDIS_PORT,
password=_REDIS_PASSWORD,
)

on_call = GroupCallFactory(
Expand Down
3 changes: 3 additions & 0 deletions bot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def __init__(self):
self.MANAGEMENT_MODE = os.getenv("MANAGEMENT_MODE")
self.MANTAINER = os.getenv("MANTAINER")
self.SESSION_STRING = os.getenv("SESSION_STRING")
self.POSTGRES_DB = os.getenv("POSTGRES_DB")
self.POSTGRES_USER = os.getenv("POSTGRES_USER")
self.POSTGRES_PASSWORD = os.getenv("POSTGRES_PASSWORD")
self.REDIS_PASSWORD = os.getenv("REDIS_PASSWORD")
self.REDIS_PORT = os.getenv("REDIS_PORT")

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
env_file:
- ./.env
ports:
- "5432:5432"
- "$($POSTGRES_PORT):$($POSTGRES_PORT)"
cache:
image: redis:7.2.1-alpine3.18
restart: always
Expand Down

0 comments on commit b1452d0

Please sign in to comment.