TheHamkerCat 5 năm trước cách đây
mục cha
commit
9654fa23e4
5 tập tin đã thay đổi với 48 bổ sung và 30 xóa
  1. 16 3
      README.md
  2. 10 17
      sample_config.py
  3. 6 7
      wbb/__init__.py
  4. 10 3
      wbb/modules/music.py
  5. 6 0
      wbb/utils/functions.py

+ 16 - 3
README.md

@@ -8,8 +8,8 @@ Just Another Telegram Bot Written In Python Using Pyrogram.
 ## Requirements
 
 - Python 3.7 or higher.
-- A [Telegram API key](//docs.pyrogram.org/intro/setup#api-keys).
-- A [Telegram bot token](//t.me/botfather).
+- A [Telegram API key](https://docs.pyrogram.org/intro/setup#api-keys).
+- A [Telegram bot token](https://t.me/botfather).
 
 ## Installation
 
@@ -28,7 +28,20 @@ $ python3 -m wbb
 
 # Heroku
 
-Soon af
+```sh 
+$ heroku git:remote -a YOUR_HEROKU_APP_NAME
+
+$ heroku stack:set container
+
+$ git add -f .
+
+$ git commit -m 'Hail WBB!'
+
+$ git push heroku HEAD:master --force
+
+$ heroku ps:scale worker=1
+```
+
 
 ## Features 
 

+ 10 - 17
sample_config.py

@@ -1,21 +1,14 @@
-bot_token = "1455:AAE4qFS3nF-0Tn"
-
-api_id = 69
-
-api_hash = "e46b6c854d2bf580"
-
+BOT_TOKEN = "1455:AAE4qFS3nF-0Tn"
+API_ID = 69
+API_HASH = "e46b6c854d2bf580"
 OWNER_ID = 1243703097
+MAIN_CHATS = [-1001485393652]  # NOTE These are the chats where main functions of bot will work, like music downloading etc.
+SUDO_CHAT_ID = [354165569, 564426514, 686215463]
+LOG_GROUP_ID = -1001337393587
+FERNET_ENCRYPTION_KEY = "iKMq0WZMnJKjMQxZWKtv-cplMuF_LoyshXj0XbTGGWM="
+WELCOME_DELAY_KICK_SEC = 300
+MONGO_DB_URI = "mongodb+srv://username:password@cluster0.ksiis.mongodb.net/YourDataBaseName?retryWrites=true&w=majority"
 
-sudo_users_id = [354165569, 564426514, 686215463]
-
-log_group_id = -1001337393587
-
-# https://cryptography.io/en/latest/fernet.html
-fernet_encryption_key = "iKMq0WZMnJKjMQxZWKtv-cplMuF_LoyshXj0XbTGGWM="
-
-captcha_delay_in_seconds = 300
-
-mongo_db_uri = "mongodb+srv://username:password@cluster0.ksiis.mongodb.net/YourDataBaseName?retryWrites=true&w=majority"
 
-# Leave This As It Is
+# NOTE Don't make changes below this line
 ARQ_API_BASE_URL = "https://thearq.tech"

+ 6 - 7
wbb/__init__.py

@@ -1,9 +1,8 @@
 from config import (
-    bot_token, api_id, api_hash, OWNER_ID,
-    sudo_users_id as SUDO_USER_ID, log_group_id as LOG_GROUP_ID,
-    fernet_encryption_key as FERNET_ENCRYPTION_KEY, mongo_db_uri as mdb_uri,
-    captcha_delay_in_seconds as WELCOME_DELAY_KICK_SEC,
-    ARQ_API_BASE_URL as ARQ_API)
+    BOT_TOKEN, API_ID ,API_HASH, OWNER_ID, SUDO_USER_ID,
+    LOG_GROUP_ID, FERNET_ENCRYPTION_KEY, MONGO_DB_URI,
+    WELCOME_DELAY_KICK_SEC, ARQ_API_BASE_URL as ARQ_API
+    )
 from pyrogram import Client
 from motor.motor_asyncio import AsyncIOMotorClient as MongoClient
 from Python_ARQ import ARQ
@@ -41,7 +40,7 @@ SUDOERS.append(OWNER_ID)
 MOD_LOAD = []
 MOD_NOLOAD = []
 bot_start_time = time.time()
-mongo_client = MongoClient(mdb_uri)
+mongo_client = MongoClient(MONGO_DB_URI)
 db = mongo_client.wbb
-app = Client("wbb", bot_token=bot_token, api_id=api_id, api_hash=api_hash)
+app = Client("wbb", bot_token=BOT_TOKEN, api_id=API_ID, api_hash=API_HASH)
 arq = ARQ(ARQ_API)

+ 10 - 3
wbb/modules/music.py

@@ -7,10 +7,13 @@ import aiofiles
 import os
 from random import randint
 from pyrogram import filters
-from wbb import app, SUDOERS, arq 
+from wbb import app, SUDOERS, arq
+from wbb.utils.functions import convert_seconds_to_minutes
 from wbb.utils.fetch import fetch
 from wbb.utils.errors import capture_err
 
+
+
 __MODULE__ = "Music"
 __HELP__ = """/ytmusic [link] To Download Music From Various Websites Including Youtube.
 /saavn [query] To Download Music From Saavn.
@@ -98,11 +101,13 @@ async def jssong(_, message):
         sname = songs[0].song
         slink = songs[0].media_url
         ssingers = songs[0].singers
+        duration = int(songs[0].duration)
+        duration = convert_seconds_to_minutes(duration)
         await m.edit("Downloading") 
         song = await download_song(slink)
         await m.edit("Uploading")
         await message.reply_audio(audio=song, title=sname,
-                                  performer=ssingers)
+                                  performer=ssingers, duration=duration)
         os.remove(song)
         await m.delete()
     except Exception as e:
@@ -128,11 +133,13 @@ async def deezsong(_, message):
         title = songs[0].title
         url = songs[0].url
         artist = songs[0].artist
+        duration = int(songs[0].duration)
+        duration = convert_seconds_to_minutes(duration)
         await m.edit("Downloading") 
         song = await download_song(url)
         await m.edit("Uploading") 
         await message.reply_audio(audio=song, title=title,
-                                  performer=artist)
+                                  performer=artist, duration=duration)
         os.remove(song)
         await m.delete()
     except Exception as e:

+ 6 - 0
wbb/utils/functions.py

@@ -0,0 +1,6 @@
+def convert_seconds_to_minutes(seconds):
+    seconds = seconds % (24 * 3600)
+    seconds %= 3600
+    minutes = seconds // 60
+    seconds %= 60
+    return "%02d:%02d" % (minutes, seconds)