token support

This commit is contained in:
root 2019-01-21 00:23:29 +00:00
parent 3ab4c33b06
commit a7dabe6c1c
2 changed files with 41 additions and 2 deletions

View File

@ -3,6 +3,7 @@ host = 127.0.0.1
port = 64738 port = 64738
password = password =
channel = channel =
tokens = # example: token1,token2
[bot] [bot]
username = botamusique username = botamusique
@ -37,6 +38,12 @@ listening_addr = 127.0.0.1
listening_port = 8181 listening_port = 8181
[command] [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_file = file
play_url = url play_url = url
play_radio = radio play_radio = radio
@ -55,6 +62,14 @@ queue = queue
repeat = repeat repeat = repeat
update = update update = update
user_ban = userban
user_unban = userunban
url_ban = urlban
url_unban = urlunban
#command to reload the ban list
reload = reload
[radio] [radio]
ponyville = http://192.99.131.205:8000/stream.mp3 ponyville = http://192.99.131.205:8000/stream.mp3
luna = http://radio.ponyvillelive.com:8002/stream 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 download_in_progress = Download of %s in progress
no_possible = it's not possible to do that no_possible = it's not possible to do that
removing_item = Removing entry %s from queue 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: help = Command available:
<br />!file [path] <br />!file [path]
@ -90,12 +107,23 @@ help = Command available:
<br />!radio [url] - url of a stream <br />!radio [url] - url of a stream
<br />!list - display list of available tracks <br />!list - display list of available tracks
<br />!queue - display items in queue <br />!queue - display items in queue
<br />!np - display the current music
<br />!skip - jump to the next music of the playlist (of remove the X items if you add a number) <br />!skip - jump to the next music of the playlist (of remove the X items if you add a number)
<br />!stop - stop and clear the playlist <br />!stop - stop and clear the playlist
<br />!oust - stop + Go to default channel <br />!oust - stop + Go to default channel
<br />!v - get or change the volume (in %) <br />!v - get or change the volume (in %)
<br />!joinme - join your own channel <br />!joinme - join your own channel
admin_help = Admin command:
<br />!kill (kill the bot)
<br />!update (update the bot)
<br />!userban [user] (ban a user)
<br />!userunban [user] (unban a user)
<br />!urlban [url] (ban an url)
<br />!urlunban [url] (unban an url)
<br />!reload (reload the ban config)
<br />
[debug] [debug]
ffmpeg = False ffmpeg = False
mumbleConnection = False mumbleConnection = False

15
mumbleBot.py Normal file → Executable file
View File

@ -75,13 +75,23 @@ class MumbleBot:
password = args.password password = args.password
else: else:
password = var.config.get("server", "password") 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: if args.user:
username = args.user username = args.user
else: else:
username = var.config.get("bot", "username") 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) debug=var.config.getboolean('debug', 'mumbleConnection'), certfile=args.certificate)
self.mumble.callbacks.set_callback("text_received", self.message_received) 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("-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("-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("-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("-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", "--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") parser.add_argument("-C", "--cert", dest="certificate", type=str, default=None, help="Certificate file")