Skip to content

Telegram bot for controlling Mopidy music server written in reactive PHP.

Notifications You must be signed in to change notification settings

sshaddicts/Mophpidy

Repository files navigation

Mophpidy

Telegram bot for controlling Mopidy music server written in reactive PHP.

Build Status Join the chat at https://gitter.im/Mophpidy/Lobby

Features

  • Browsing collection
  • Volume control
  • Playback control
  • Search (currently only gmusic and soundcloud)
  • Favorites (all playlists that match /favou?rites/i in playlist name will be merged into one)

Installation

Docker

docker pull 421p/mophpidy

ARM is also supported (Raspberry PI and such)

docker pull 421p/mophpidy:arm32v7

Docker Compose example:

# docker-compose.yml
version: '3'

services:
  bot:
    image: 421p/mophpidy
    restart: always
    volumes:
      - './data:/app/data' # for data persistence
    environment:
      MOPIDY_URI: 'ws://mopidyhost:6680/mopidy/ws/'
      TELEGRAM_TOKEN: 'TELEGRAM_BOT_TOKEN'
      BOT_USERNAME: '@TELEGRAM_BOT_USERNAME'
      ADMIN: '11223344' # partially supports multiple users '111222333, 14224124'

As you can see you have to provide 4 environment variables:

  • MOPIDY_URI - uri to mopidy websocket endpoint
  • TELEGRAM_TOKEN - bot token
  • BOT_USERNAME - bot username
  • ADMIN - one or more (partial support) telegram user id

For the first installation you have to create a database by running doctrine command.

docker-compose run bot doctrine orm:sc:cr

Non-docker

  1. Create .env file with 4 required environment variables
# .env
MOPIDY_URI='ws://mopidyhost:6680/mopidy/ws/'
TELEGRAM_TOKEN='TELEGRAM_BOT_TOKEN'
BOT_USERNAME='@TELEGRAM_BOT_USERNAME'
ADMIN='11223344'
  1. Install dependencies:
composer install
  1. Create database (for a fresh installation only)
./doctrine orm:sc:cr
  1. Run bot
php bot.php

It's highly recommended to install event pecl extension for running bot but not required.