Giter Site home page Giter Site logo

dgnsrekt / discorgeous Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 2.0 207 KB

Discord + GTTS = a discord bot that sends google text to speech voice messages to discord voice channels.

License: MIT License

Python 100.00%
discord bot gtts google-text-to-speech python python3 discord-bot music-bot discord-server discord-py discord-py-bot discord-python-bot speech tts text-to-speech

discorgeous's Introduction

Discorgeous

Discord + GTTS = a discord bot that sends google text to speech voice messages to discord voice channels.

Code style: black

    ____   _
   / __ \ (_)_____ _____ ____   _____ ____ _ ___   ____   __  __ _____
  / / / // // ___// ___// __ \ / ___// __ `// _ \ / __ \ / / / // ___/
 / /_/ // /(__  )/ /__ / /_/ // /   / /_/ //  __// /_/ // /_/ /(__  )
/_____//_//____/ \___/ \____//_/    \__, / \___/ \____/ \__,_//____/
                                   /____/

Usage: discorgeous [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  client      Send a single message to server.
  client-ssh  ssh client not implemented.
  repl        Repl messages to server.
  server      Runs the discord bot server.
  tester      Sends test song to server.

REQUIRES

On Linux environments, installing discord.py[voice] requires getting the following dependencies:

apt install libffi-dev libnacl-dev

QUICK START

Install

git clone https://github.com/dgnsrekt/Discorgeous.git
cd Discorgeous
pip3 install -e .

Run Single Server

discorgeous server --single --port 5555 --token {discord_bot_token} --channel {discord_channel_id}

Run REPL Client

discorgeous repl --port 5555

Run Test Song

discorgeous tester --port 5555

Run Muliple Servers

First edit the server_config.toml file in the Discorgeous/config folder. Add as many servers as you like.

[ServerOne] <- Whatever name you want.
CHANNEL_ID = "000000000000000000" <- {discord_channel_id}
VOICE_TOKEN = "00000000000000000000000000000000000000000000000000000000000" <- {discord_bot_token}
IP = "0.0.0.0"
PORT = "6666" <- Make sure each server has a different port.

[ServerTwo] <- Whatever name you want.
CHANNEL_ID = "111111111111111111" <- {discord_channel_id}
VOICE_TOKEN = "11111111111111111111111111111111111111111111111111111111111" <- {discord_bot_token}
IP = "0.0.0.0"
PORT = "5555" <- Make sure each server has a different port.

Run server with configuration section name

discorgeous server --config ServerOne --config ServerTwo

Run in seperate tmux instances

discorgeous server --config ServerOne --config ServerTwo --tmux

Example Client Script

The MinuteNotificationClient sends a current time message to a discorgeous server every minute.

from discorgeous import Client
from datetime import datetime
import asyncio
import sys


class MinuteNotificationClient(Client):
    def __init__(self, *, ip, port, sleep_interval=60):
        super().__init__(ip=ip, port=port)
        self.sleep_interval = sleep_interval

    async def timeupdate(self, *, loop):
        while True:
            current_time = datetime.now().time()
            hour = current_time.hour
            minute = current_time.minute
            message = f"The current time is {hour} {minute}."
            await self.handler(message, loop)
            await asyncio.sleep(self.sleep_interval)

    def start(self):
        loop = asyncio.get_event_loop()
        time_coro = self.timeupdate(loop=loop)
        loop.run_until_complete(time_coro)

        try:
            loop.run_forever()
        except KeyboardInterrupt as e:
            print(e)
        finally:
            loop.close()


MNC = MinuteNotificationClient(ip="localhost", port=6666, sleep_interval=60)

try:
    MNC.start()
except KeyboardInterrupt as e:
    print(str(e))
except Exception as e:
    print(str(e))
finally:
    sys.exit()

TODO

  • Client over SSH
  • Documentation
  • Tests
  • Config files in user path.
  • Update Requirements.
  • Link to discord voice bot token creation guide.
  • Add port/name check to server config to make sure all ports and names are unique.
  • Add non-async version of the client.
  • Dump Client config.
  • Example Random lyrics/quotes.
  • client.start() method should take a list of coroutines, add them to a loop, then start.
  • Py package
  • Update for discord.py 1.0

Contact

License

This code is licensed under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.