mirror of
https://github.com/azlux/botamusique
synced 2024-11-23 22:06:09 +00:00
Compare commits
No commits in common. "9f032c3a577b22d7f4089efdfa9b01092e73acc1" and "6115a0d3ee9786b5dffb1d3a7daa461ede283bca" have entirely different histories.
9f032c3a57
...
6115a0d3ee
@ -65,7 +65,6 @@ tmp_folder_max_size = 10
|
||||
username = botamusique
|
||||
volume = 0.8
|
||||
when_nobody_in_channel = nothing
|
||||
when_nobody_in_channel_ignore =
|
||||
|
||||
[webinterface]
|
||||
access_address = http://127.0.0.1:8181
|
||||
|
@ -134,10 +134,6 @@ port = 64738
|
||||
# - leave empty (do nothing)
|
||||
#when_nobody_in_channel =
|
||||
|
||||
# 'when_nobody_in_channel_ignore': Specify the list of users that should be ignored, from the list of active users.
|
||||
# This is typically used when other bots are present in the channel.
|
||||
#when_nobody_in_channel_ignore =
|
||||
|
||||
# 'youtube_query_cookie': Sometimes youtube will block the request of our bot and
|
||||
# request the bot to complete a captcha to verify the request is not made by a
|
||||
# bot.
|
||||
|
16
mumbleBot.py
16
mumbleBot.py
@ -103,7 +103,6 @@ class MumbleBot:
|
||||
tokens = var.config.get("server", "tokens")
|
||||
tokens = tokens.split(',')
|
||||
|
||||
|
||||
if args.user:
|
||||
self.username = args.user
|
||||
else:
|
||||
@ -133,11 +132,8 @@ class MumbleBot:
|
||||
self.join_channel()
|
||||
self.mumble.set_bandwidth(self.bandwidth)
|
||||
|
||||
bots = var.config.get("bot", "when_nobody_in_channel_ignore",fallback="")
|
||||
self.bots = set(bots.split(','))
|
||||
self._user_in_channel = self.get_user_count_in_channel()
|
||||
|
||||
|
||||
# ====== Volume ======
|
||||
self.volume_helper = util.VolumeHelper()
|
||||
|
||||
@ -378,18 +374,8 @@ class MumbleBot:
|
||||
# =======================
|
||||
|
||||
def get_user_count_in_channel(self):
|
||||
# Get the channel, based on the channel id
|
||||
own_channel = self.mumble.channels[self.mumble.users.myself['channel_id']]
|
||||
|
||||
# Build set of unique usernames
|
||||
users = set([user.get_property("name") for user in own_channel.get_users()])
|
||||
|
||||
# Exclude all bots from the set of usernames
|
||||
users = users.difference(self.bots)
|
||||
|
||||
# Return the number of elements in the set, as the final user count
|
||||
return len(users)
|
||||
|
||||
return len(own_channel.get_users())
|
||||
|
||||
def users_changed(self, user, message):
|
||||
# only check if there is one more user currently in the channel
|
||||
|
20
util.py
20
util.py
@ -12,15 +12,13 @@ import zipfile
|
||||
import re
|
||||
import subprocess as sp
|
||||
import logging
|
||||
import yt_dlp as youtube_dl
|
||||
from importlib import reload
|
||||
from sys import platform
|
||||
import traceback
|
||||
import requests
|
||||
from packaging import version
|
||||
|
||||
import yt_dlp as youtube_dl
|
||||
YT_PKG_NAME = 'yt-dlp'
|
||||
|
||||
log = logging.getLogger("bot")
|
||||
|
||||
|
||||
@ -139,7 +137,7 @@ def update(current_version):
|
||||
new_version = new_release_version(target)
|
||||
msg = ""
|
||||
if target == "git":
|
||||
msg = "git install, I do nothing<br/>"
|
||||
msg = "git install, I do nothing"
|
||||
|
||||
elif (target == "stable" and version.parse(new_version) > version.parse(current_version)) or \
|
||||
(target == "testing" and version.parse(new_version) != version.parse(current_version)):
|
||||
@ -148,17 +146,17 @@ def update(current_version):
|
||||
log.debug(tp)
|
||||
log.info('update: update pip libraries dependencies')
|
||||
sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', '-r', 'requirements.txt']).decode()
|
||||
msg = "New version installed, please restart the bot.<br/>"
|
||||
msg = "New version installed, please restart the bot."
|
||||
|
||||
log.info(f'update: starting update {YT_PKG_NAME} via pip3')
|
||||
tp = sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', YT_PKG_NAME]).decode()
|
||||
if f"Collecting {YT_PKG_NAME}" in tp.splitlines():
|
||||
msg += "Update done: " + tp.split('Successfully installed')[1]
|
||||
log.info('update: starting update youtube-dl via pip3')
|
||||
tp = sp.check_output([var.config.get('bot', 'pip3_path'), 'install', '--upgrade', 'youtube-dl']).decode()
|
||||
if "Requirement already up-to-date" in tp:
|
||||
msg += "Youtube-dl is up-to-date"
|
||||
else:
|
||||
msg += YT_PKG_NAME.capitalize() + " is up-to-date"
|
||||
msg += "Update done: " + tp.split('Successfully installed')[1]
|
||||
|
||||
reload(youtube_dl)
|
||||
msg += "<br/>" + YT_PKG_NAME.capitalize() + " reloaded"
|
||||
msg += "<br/> Youtube-dl reloaded"
|
||||
return msg
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user