From e07e82b9dd93c97e53521f9fcdc967febf8d0eeb Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Wed, 15 Jun 2022 12:05:51 -0500 Subject: Added bot's code --- src/bot.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/bot.py (limited to 'src/bot.py') diff --git a/src/bot.py b/src/bot.py new file mode 100644 index 0000000..9b10736 --- /dev/null +++ b/src/bot.py @@ -0,0 +1,62 @@ +from config import Config +from ampache.client import AmpacheClient +from collections import deque +import pymumble_py3 as pymumble + +class Bot: + """ + The bot class. It reads a config file (given in the constructor) + and with it populates its own and the ampache client's variables. + """ + def __init__(self, config_file): + # The file may not exist. If it doesn't, the configparser will + # throw a key error exception. TODO: first open the file, if + # it doesn't exist it will throw a more ad hoc exception. + self._configuration = Config(config_file) + self._playlist = deque() + self._init_client() + self._init_bot() + self._init_misc() + + def _init_misc(self): + miscellaneous = self._configuration.get_directories() + self._download_dir = miscellaneous[0] + self._automatically_delete = miscellaneous[1] + + def _init_client(self): + client_info = self._configuration.get_ampache_config() + auth_info = self._configuration.get_auth() + self._client = AmpacheClient(client_info[0], auth_info, + client_info[1]) + + def _init_bot(self): + mumble_info = self._configuration.get_mumble_config() + host = mumble_info[0] + password = mumble_info[1] + certfile = mumble_info[2] + keyfile = mumble_info[3] + bot_nick = mumble_info[4] + self._bot = pymumble.Mumble(host, bot_nick, password=password, certfile=certfile, + keyfile=keyfile, reconnect=True, stereo=True) + + def read_command(self): + pass + + def parse_command(self): + pass + + def add_to_playlist(self, ): + pass + + def play_song(self, ): + pass + + # API methods. + def query_song(self, song_id): + pass + + def query_album(self, album_id): + pass + + def download_song(self): + pass -- cgit v1.2.3