Skip to content
View Satoruatwork's full-sized avatar
💭
learning
💭
learning

Block or report Satoruatwork

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
Satoruatwork/README.md

import os from telegram import Update from telegram.ext import Updater, CommandHandler, CallbackContext import youtube_dl

Function to start the bot

def start(update: Update, context: CallbackContext) -> None: update.message.reply_text("Hello! I'm your music bot. Use /play to play music.")

Function to play music

def play(update: Update, context: CallbackContext) -> None: query = ' '.join(context.args) if not query: update.message.reply_text("Please provide a song name.") return

update.message.reply_text(f"Searching for {query}...")

# YouTube search and download
ydl_opts = {
    'format': 'bestaudio/best',
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '192',
    }],
    'outtmpl': '/tmp/%(title)s.%(ext)s',
}

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    info_dict = ydl.extract_info(f"ytsearch:{query}", download=True)
    video = info_dict['entries'][0]
    title = video.get('title', None)
    file_path = f"/tmp/{title}.mp3"

update.message.reply_text(f"Playing {title}...")
# Here you would typically send the audio file to the user
# update.message.reply_audio(audio=open(file_path, 'rb'))

def main(): # Insert your bot token here updater = Updater("YOUR_BOT_TOKEN")

dispatcher = updater.dispatcher

# Register the commands
dispatcher.add_handler(CommandHandler("start", start))
dispatcher.add_handler(CommandHandler("play", play))

# Start the bot
updater.start_polling()
updater.idle()

if name == 'main': main() git clone https://github.com/yourusername/telegram-music-bot.git cd telegram-music-bot git add bot.py git commit -m "Initial commit with bot code" git push origin main

Popular repositories Loading

  1. Satoru Satoru Public

  2. Satoruhlc Satoruhlc Public

  3. Satoruatwork Satoruatwork Public

    Config files for my GitHub profile.

  4. Music-Player Music-Player Public

    Forked from vi2k6/Music-Player

    A bot that can play music on telegram group's voice chat.

    Python

  5. VCPlayBot VCPlayBot Public

    Forked from Shiv-x/VCPlayBot

    Telegram Group Music Bot Groups Music allows you to play music in your groups.

    Python

  6. MusicPlayer MusicPlayer Public

    Forked from AsmSafone/MusicPlayer

    A Telegram Music Bot written in Python using Pyrogram and Py-Tgcalls. This is Also The Source Code of The UserBot Which is Playing Music in @S1-BOTS Support Group ❤️

    Python