1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
from config import Config
from ampache.client import AmpacheClient
from collections import deque
from command_parser import parse_command, Commands
import pymumble_py3 as pymumble
class AmpacheBot:
"""
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_message(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
|