1
0
mirror of https://github.com/azlux/botamusique synced 2024-11-23 22:06:09 +00:00

Compare commits

..

4 Commits

Author SHA1 Message Date
Terry Geng
508811cd2a
Merge pull request #309 from knector01/master
Allow changing bot avatar
2022-01-21 09:40:16 -05:00
Terry Geng
89c3131bb7
Merge pull request #308 from KrakatauiHD/master
Fix logfile rotation (small fix)
2022-01-21 09:37:21 -05:00
knector01
fd2c41eb9c feat: Add avatar config option 2022-01-20 21:18:02 -07:00
KrakatauiHD
f8a71058f0
make the rotating logsfiles rotating again 2022-01-20 16:08:25 +01:00
3 changed files with 15 additions and 2 deletions

View File

@ -29,6 +29,7 @@ certificate =
[bot] [bot]
username = botamusique username = botamusique
comment = "Hi, I'm here to play radio, local music or youtube/soundcloud music. Have fun!" comment = "Hi, I'm here to play radio, local music or youtube/soundcloud music. Have fun!"
avatar =
# default volume from 0 to 1. # default volume from 0 to 1.
volume = 0.1 volume = 0.1
stereo = True stereo = True

View File

@ -21,8 +21,10 @@ port = 64738
[bot] [bot]
# 'username' is the user name of the bot. # 'username' is the user name of the bot.
# 'comment' is the comment displayed by the bot. # 'comment' is the comment displayed by the bot.
# 'avatar' is the path to the avatar image shown on the bot (PNG recommended, 128 KB max).
#username = botamusique #username = botamusique
#comment = "Hi, I'm here to play radio, local music or youtube/soundcloud music. Have fun!" #comment = "Hi, I'm here to play radio, local music or youtube/soundcloud music. Have fun!"
#avatar =
# 'language': Available languages can be found inside lang/ folder. # 'language': Available languages can be found inside lang/ folder.
#language=en_US #language=en_US

View File

@ -127,6 +127,7 @@ class MumbleBot:
exit() exit()
self.set_comment() self.set_comment()
self.set_avatar()
self.mumble.users.myself.unmute() # by sure the user is not muted self.mumble.users.myself.unmute() # by sure the user is not muted
self.join_channel() self.join_channel()
self.mumble.set_bandwidth(self.bandwidth) self.mumble.set_bandwidth(self.bandwidth)
@ -233,6 +234,15 @@ class MumbleBot:
def set_comment(self): def set_comment(self):
self.mumble.users.myself.comment(var.config.get('bot', 'comment')) self.mumble.users.myself.comment(var.config.get('bot', 'comment'))
def set_avatar(self):
avatar_path = var.config.get('bot', 'avatar', fallback=None)
if avatar_path:
with open(avatar_path, 'rb') as avatar_file:
self.mumble.users.myself.texture(avatar_file.read())
else:
self.mumble.users.myself.texture(b'')
def join_channel(self): def join_channel(self):
if self.channel: if self.channel:
if '/' in self.channel: if '/' in self.channel:
@ -730,7 +740,7 @@ def start_web_interface(addr, port):
werkzeug_logger = logging.getLogger('werkzeug') werkzeug_logger = logging.getLogger('werkzeug')
logfile = util.solve_filepath(var.config.get('webinterface', 'web_logfile')) logfile = util.solve_filepath(var.config.get('webinterface', 'web_logfile'))
if logfile: if logfile:
handler = logging.handlers.RotatingFileHandler(logfile, mode='a', maxBytes=10240) # Rotate after 10KB handler = logging.handlers.RotatingFileHandler(logfile, mode='a', maxBytes=10240, backupCount=3) # Rotate after 10KB, leave 3 old logs
else: else:
handler = logging.StreamHandler() handler = logging.StreamHandler()
@ -813,7 +823,7 @@ if __name__ == '__main__':
handler = None handler = None
if logfile: if logfile:
print(f"Redirecting stdout and stderr to log file: {logfile}") print(f"Redirecting stdout and stderr to log file: {logfile}")
handler = logging.handlers.RotatingFileHandler(logfile, mode='a', maxBytes=10240) # Rotate after 10KB handler = logging.handlers.RotatingFileHandler(logfile, mode='a', maxBytes=10240, backupCount=3) # Rotate after 10KB, leave 3 old logs
if var.config.getboolean("bot", "redirect_stderr", fallback=False): if var.config.getboolean("bot", "redirect_stderr", fallback=False):
sys.stderr = util.LoggerIOWrapper(bot_logger, logging.INFO, sys.stderr = util.LoggerIOWrapper(bot_logger, logging.INFO,
fallback_io_buffer=sys.stderr.buffer) fallback_io_buffer=sys.stderr.buffer)