Merge pull request #22 from Lartza/store-volume
Store volume in the config file, write the config file, fixes
This commit is contained in:
commit
d5dcd138ab
@ -41,6 +41,7 @@ kill = kill
|
|||||||
stop_and_getout = oust
|
stop_and_getout = oust
|
||||||
joinme = joinme
|
joinme = joinme
|
||||||
queue = queue
|
queue = queue
|
||||||
|
repeat = repeat
|
||||||
|
|
||||||
[radio]
|
[radio]
|
||||||
ponyville = http://192.99.131.205:8000/stream.mp3
|
ponyville = http://192.99.131.205:8000/stream.mp3
|
||||||
|
13
mumbleBot.py
13
mumbleBot.py
@ -85,11 +85,11 @@ class MumbleBot:
|
|||||||
password = var.config.get("server", "password")
|
password = var.config.get("server", "password")
|
||||||
|
|
||||||
if args.user:
|
if args.user:
|
||||||
user = args.user
|
username = args.user
|
||||||
else:
|
else:
|
||||||
user = var.config.get("bot", "user")
|
username = var.config.get("bot", "username")
|
||||||
|
|
||||||
self.mumble = pymumble.Mumble(host, user=user, port=port, password=password,
|
self.mumble = pymumble.Mumble(host, user=username, port=port, password=password,
|
||||||
debug=var.config.getboolean('debug', 'mumbleConnection'))
|
debug=var.config.getboolean('debug', 'mumbleConnection'))
|
||||||
self.mumble.callbacks.set_callback("text_received", self.message_received)
|
self.mumble.callbacks.set_callback("text_received", self.message_received)
|
||||||
|
|
||||||
@ -184,6 +184,7 @@ class MumbleBot:
|
|||||||
self.volume = float(float(parameter) / 100)
|
self.volume = float(float(parameter) / 100)
|
||||||
self.send_msg_channel(var.config.get('strings', 'change_volume') % (
|
self.send_msg_channel(var.config.get('strings', 'change_volume') % (
|
||||||
int(self.volume * 100), self.mumble.users[text.actor]['name']))
|
int(self.volume * 100), self.mumble.users[text.actor]['name']))
|
||||||
|
var.config.set('bot', 'volume', str(self.volume))
|
||||||
else:
|
else:
|
||||||
self.send_msg_channel(var.config.get('strings', 'current_volume') % int(self.volume * 100))
|
self.send_msg_channel(var.config.get('strings', 'current_volume') % int(self.volume * 100))
|
||||||
|
|
||||||
@ -373,6 +374,9 @@ class MumbleBot:
|
|||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
if self.exit:
|
||||||
|
util.write_config()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if self.thread:
|
if self.thread:
|
||||||
var.current_music = None
|
var.current_music = None
|
||||||
@ -409,8 +413,9 @@ if __name__ == '__main__':
|
|||||||
parser.add_argument("-c", "--channel", dest="channel", type=str, help="Default channel for the bot")
|
parser.add_argument("-c", "--channel", dest="channel", type=str, help="Default channel for the bot")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
var.configfile = args.config
|
||||||
config = configparser.ConfigParser(interpolation=None, allow_no_value=True)
|
config = configparser.ConfigParser(interpolation=None, allow_no_value=True)
|
||||||
parsed_configs = config.read(['configuration.default.ini', args.config], encoding='latin-1')
|
parsed_configs = config.read(['configuration.default.ini', var.configfile], encoding='latin-1')
|
||||||
|
|
||||||
if len(parsed_configs) == 0:
|
if len(parsed_configs) == 0:
|
||||||
print('Could not read configuration from file \"{}\"'.format(args.config), file=sys.stderr)
|
print('Could not read configuration from file \"{}\"'.format(args.config), file=sys.stderr)
|
||||||
|
5
util.py
5
util.py
@ -66,6 +66,11 @@ def zipdir(zippath, zipname_prefix=None):
|
|||||||
return zipname
|
return zipname
|
||||||
|
|
||||||
|
|
||||||
|
def write_config():
|
||||||
|
with open(var.configfile, 'w') as f:
|
||||||
|
var.config.write(f)
|
||||||
|
|
||||||
|
|
||||||
class Dir(object):
|
class Dir(object):
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.name = os.path.basename(path.strip('/'))
|
self.name = os.path.basename(path.strip('/'))
|
||||||
|
@ -3,4 +3,5 @@ playlist = []
|
|||||||
user = ""
|
user = ""
|
||||||
music_folder = ""
|
music_folder = ""
|
||||||
is_proxified = False
|
is_proxified = False
|
||||||
|
configfile = None
|
||||||
config = None
|
config = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user