Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Oct 11, 2023
1 parent 7bfe536 commit 3c19254
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
10 changes: 10 additions & 0 deletions .vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update && sudo apt-get install redis -y
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb; sudo apt-get -fy install
rm -rf google-chrome-stable_current_amd64.deb && sudo apt-get update
6 changes: 0 additions & 6 deletions .webdriver.sh

This file was deleted.

4 changes: 2 additions & 2 deletions bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@
)

# ------------------------------------------------------------------------------

"""
engine = db.create_engine(
f"postgresql://{_POSTGRES_USER}:{_POSTGRES_PASSWORD}@{_POSTGRES_HOST}:{_POSTGRES_PORT}/{_POSTGRES_DB}"
)
conn = engine.connect()
db_metadata = db.MetaData()

"""
# ------------------------------------------------------------------------------

r = Redis(
Expand Down
4 changes: 2 additions & 2 deletions bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from termcolor import colored
from pyrogram.types import BotCommand

from bot.setup import setup_db, setup_plugins
from bot.setup import setup_plugins
from bot import kreacher, assistant

ay = asyncio.get_event_loop()
Expand All @@ -29,7 +29,7 @@ async def start_bot():
print(f'{colored("[INFO]", "blue")}: SETED BOT COMMANDS')


setup_db()
# setup_db()
setup_plugins()
ay.run_until_complete(start_bot())

Expand Down
11 changes: 7 additions & 4 deletions bot/helpers/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ def add_or_create_queue(
queue: dict = r.hgetall("queues")
if group_id in str(queue):
giq: list = pickle.loads(queue[group_id])
print(giq)
giq.append(values)
hset = r.hset("queues", group_id, pickle.dumps(giq))
if hset == 0:
return position
return False
print(kw)
hset = r.hset("queues", group_id, values)
if hset == 1:
return position
Expand All @@ -47,15 +49,15 @@ def next_in_queue(group_id: str) -> Union[Tuple, None]:
for i in range(len(values)):
if values[i].get("is_playing"):
_next = values[i + 1]
tdo = (
ot = (
_next["from_user"],
_next["is_playing"],
_next["position"],
_next["date"],
_next["file"],
_next["type_of"],
)
return tdo
return ot
return None


Expand All @@ -68,15 +70,15 @@ def previous_in_queue(group_id: str) -> Union[Tuple, None]:
for i in range(len(values)):
if values[i].get("is_playing"):
_previous = values[i - 1]
tdo = (
ot = (
_previous["from_user"],
_previous["is_playing"],
_previous["position"],
_previous["date"],
_previous["file"],
_previous["type_of"],
)
return tdo
return ot
return None


Expand Down Expand Up @@ -108,6 +110,7 @@ def get_last_position_in_queue(group_id: str) -> Union[int, None]:
if group_id not in str(queue):
return None
value: dict = pickle.loads(queue[group_id])[-1]
print(value)
return value["position"]


Expand Down
8 changes: 3 additions & 5 deletions bot/plugins/commands/play_song.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,17 @@ async def _(client: Client, message: Message):
"**__Can't find song.\n\nTry searching with more specific title.__**",
)
if str(message.chat.id) in str(QUEUES):
position = get_last_position_in_queue(str(message.chat.id))
if position is None:
return
position = get_last_position_in_queue(str(message.chat.id)) + 1
add_or_create_queue(
str(message.chat.id),
from_user=str(message.from_user.id),
date=str(datetime.now()),
file=url,
type_of="song_yt",
position=position + 1,
position=position,
)
return await msg.edit(
f"**__Added to queue at {position + 1}\n\nTitle: [{name}]({url})\nDuration: {duration} Minutes\n Requested by:__** [{data['first_name']}]({data['mention']})",
f"**__Added to queue at {position}\n\nTitle: [{name}]({url})\nDuration: {duration} Minutes\n Requested by:__** [{data['first_name']}]({data['mention']})",
reply_markup=InlineKeyboardMarkup(
[[InlineKeyboardButton("cʟᴏꜱᴇ", callback_data="close")]]
),
Expand Down
3 changes: 2 additions & 1 deletion bot/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
from pathlib import Path
from termcolor import colored

"""
from bot import db_metadata, engine
def setup_db():
db_metadata.create_all(engine)

"""

def setup_plugins():
cwd = os.path.dirname(os.path.abspath(__file__))
Expand Down

0 comments on commit 3c19254

Please sign in to comment.