From a7dabe6c1c659551b7a1e24276098700c7760cab Mon Sep 17 00:00:00 2001 From: root Date: Mon, 21 Jan 2019 00:23:29 +0000 Subject: [PATCH 1/2] token support --- configuration.default.ini | 28 ++++++++++++++++++++++++++++ mumbleBot.py | 15 +++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) mode change 100644 => 100755 mumbleBot.py diff --git a/configuration.default.ini b/configuration.default.ini index d25b469..d268b95 100644 --- a/configuration.default.ini +++ b/configuration.default.ini @@ -3,6 +3,7 @@ host = 127.0.0.1 port = 64738 password = channel = +tokens = # example: token1,token2 [bot] username = botamusique @@ -37,6 +38,12 @@ listening_addr = 127.0.0.1 listening_port = 8181 [command] +#This it the char (only on letter) the bot will recognize as a command +command_symbol = ! +#this option split username, in case you use such kind of mumo plugins https://wiki.mumble.info/wiki/Mumo#Set_Status +split_username_at_space = False + + play_file = file play_url = url play_radio = radio @@ -55,6 +62,14 @@ queue = queue repeat = repeat update = update +user_ban = userban +user_unban = userunban +url_ban = urlban +url_unban = urlunban + +#command to reload the ban list +reload = reload + [radio] ponyville = http://192.99.131.205:8000/stream.mp3 luna = http://radio.ponyvillelive.com:8002/stream @@ -82,6 +97,8 @@ too_long = This music is too long, skipping ! download_in_progress = Download of %s in progress no_possible = it's not possible to do that removing_item = Removing entry %s from queue +user_ban = You are ban, not allowed to do that ! +url_ban = This url isn't allowed ! help = Command available:
!file [path] @@ -90,12 +107,23 @@ help = Command available:
!radio [url] - url of a stream
!list - display list of available tracks
!queue - display items in queue +
!np - display the current music
!skip - jump to the next music of the playlist (of remove the X items if you add a number)
!stop - stop and clear the playlist
!oust - stop + Go to default channel
!v - get or change the volume (in %)
!joinme - join your own channel +admin_help = Admin command: +
!kill (kill the bot) +
!update (update the bot) +
!userban [user] (ban a user) +
!userunban [user] (unban a user) +
!urlban [url] (ban an url) +
!urlunban [url] (unban an url) +
!reload (reload the ban config) +
[debug] ffmpeg = False mumbleConnection = False + diff --git a/mumbleBot.py b/mumbleBot.py old mode 100644 new mode 100755 index fb30df2..4e745a2 --- a/mumbleBot.py +++ b/mumbleBot.py @@ -75,13 +75,23 @@ class MumbleBot: password = args.password else: password = var.config.get("server", "password") - + if args.tokens: + tokens = args.tokens + print(tokens) + else: + tokens = var.config.get("server", "tokens") + access_tokens = [] + tokenslist = tokens.split(",") + for i in tokenslist: + access_tokens.append(str(i)) + logging.info(access_tokens) + print(access_tokens) if args.user: username = args.user else: username = var.config.get("bot", "username") - self.mumble = pymumble.Mumble(host, user=username, port=port, password=password, + self.mumble = pymumble.Mumble(host, user=username, port=port, password=password, tokens=access_tokens, debug=var.config.getboolean('debug', 'mumbleConnection'), certfile=args.certificate) self.mumble.callbacks.set_callback("text_received", self.message_received) @@ -542,6 +552,7 @@ if __name__ == '__main__': parser.add_argument("-s", "--server", dest="host", type=str, help="Hostname of the Mumble server") parser.add_argument("-u", "--user", dest="user", type=str, help="Username for the bot") parser.add_argument("-P", "--password", dest="password", type=str, help="Server password, if required") + parser.add_argument("-T", "--tokens", dest="tokens", type=str, help="Server tokens, if required") parser.add_argument("-p", "--port", dest="port", type=int, help="Port for the Mumble server") parser.add_argument("-c", "--channel", dest="channel", type=str, help="Default channel for the bot") parser.add_argument("-C", "--cert", dest="certificate", type=str, default=None, help="Certificate file") From cf99e661fb29a69765af925a7177ab4af7f06748 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 21 Jan 2019 00:39:58 +0000 Subject: [PATCH 2/2] allow single access_token --- mumbleBot.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mumbleBot.py b/mumbleBot.py index 4e745a2..864261e 100755 --- a/mumbleBot.py +++ b/mumbleBot.py @@ -77,15 +77,15 @@ class MumbleBot: password = var.config.get("server", "password") if args.tokens: tokens = args.tokens - print(tokens) else: tokens = var.config.get("server", "tokens") access_tokens = [] - tokenslist = tokens.split(",") - for i in tokenslist: - access_tokens.append(str(i)) - logging.info(access_tokens) - print(access_tokens) + if "," in tokens: + tokenslist = tokens.split(",") + for i in tokenslist: + access_tokens.append(str(i)) + else: + access_tokens.append(tokens) if args.user: username = args.user else: