* Update docker-compose.yml No dotenv file needed. All environment values are now defined in docker-compose * Update RU.json * Updated docker-compose * Update README.md * Resolved issue where playback didn’t start after user joined channel 247 * Added logging system * Updated logging system * Update player.py * Added 24/7 required intent * Update main.py * Added logs folder * Updated logging system * Updated logging system * Added some typehint * Removed error_log * Renamed a valuable * Removed unnecessary value * Fixed some bugs * Added bot status settings * Added autocomplete in playtop * Added a new emoji in Loop button * Optimized code * Update requirements.txt * Fixed autoplay with empty queue This commit addresses the issue where autoplay was being activated even when the history queue had no tracks. The problem has been resolved to ensure smooth user experience * Enhanced Loop Control Button Functionality * Updated the loop button in controller * Fixed activity update Resolved the issue where activity updates were not reflected when the value remained the same. * Added sync function in debug view * Optimized code * Added version in the debug * Added nodes panel in debug view * Merged .env into settings.json * Rewritten ipc_client * Separated the dashboard from the project * Removed some necessary requirements * Remove support for replit * Update README.md * Update settings Example.json * Added get_recommendations into node class * Saved log file when updating * Rewritten some method in ipc_client * Written swap and remove method in queue * Added remove_track and swap_track method in player * Update methods.py * Added secure protocol in ipc client * Fixed some bugs * Added some method in ipc cilent * Update methods.py * Update methods.py * Added playlist method * Optimized Spotify client code * Added Category class in Spotify client * Added settings method in ipc client * Fixed some bugs * Send track requester_id in initPlayer * Fixed some bugs * Fixed some bugs * Optimized some code * Dump discord.py * Added start and end position for each track * Update methods.py * Fixed a bug * Fixed some bugs * Fixed IPC client creation issue * Rewrote filters * Fixed some bugs * Added filter event in ipc method * Added filter selector in music controller * Added inbox method * Optimized some code * Updated zh-TW local_lang * Fixed some bugs * Delete supervisord.conf * Fixed some bugs * Updated wording in IPC client * Update pool.py * Fixed no song suggestions when spotify_client is None * Fixed connection problem from the dashboard * Fixed some bugs * Added voice status (#33) * Updated the placeholder name for clarity * Added voice status * Dump bot version * Added global template for voice status * Added new placeholder * Updated settings view * Updated version tag * Improved codes * Fixed some bugs * Supported clear queue endpoint in ipc * Update methods.py * Update README.md * Remove PLACEHOLDERS.MD --------- Co-authored-by: Azarath7 <158289825+Azarath7@users.noreply.github.com>
124 lines
4.7 KiB
Python
124 lines
4.7 KiB
Python
import requests, zipfile, os, shutil, argparse
|
|
from io import BytesIO
|
|
|
|
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
__version__ = "v2.6.9"
|
|
|
|
GITHUB_API_URL = "https://api.github.com/repos/ChocoMeow/Vocard/releases/latest"
|
|
VOCARD_URL = "https://github.com/ChocoMeow/Vocard/archive/"
|
|
IGNORE_FILES = ["settings.json", "logs"]
|
|
|
|
class bcolors:
|
|
WARNING = '\033[93m'
|
|
FAIL = '\033[91m'
|
|
OKGREEN = '\033[92m'
|
|
ENDC = '\033[0m'
|
|
|
|
def check_version(with_msg=False):
|
|
"""Check for the latest version of the project.
|
|
|
|
Args:
|
|
with_msg (bool): option to print the message.
|
|
|
|
Returns:
|
|
str: the latest version.
|
|
"""
|
|
response = requests.get(GITHUB_API_URL)
|
|
latest_version = response.json().get("name", __version__)
|
|
if with_msg:
|
|
msg = f"{bcolors.OKGREEN}Your bot is up-to-date! - {latest_version}{bcolors.ENDC}" if latest_version == __version__ else \
|
|
f"{bcolors.WARNING}Your bot is not up-to-date! The latest version is {latest_version} and you are currently running version {__version__}\n. Run `python update.py -l` to update your bot!{bcolors.ENDC}"
|
|
print(msg)
|
|
return latest_version
|
|
|
|
def download_file(version=None):
|
|
"""Download the latest version of the project.
|
|
|
|
Args:
|
|
version (str): the version to download. If None, download the latest version.
|
|
|
|
Returns:
|
|
BytesIO: the downloaded zip file.
|
|
"""
|
|
version = version if version else check_version()
|
|
print(f"Downloading Vocard version: {version}")
|
|
response = requests.get(VOCARD_URL + version + ".zip")
|
|
if response.status_code == 404:
|
|
print(f"{bcolors.FAIL}Warning: Version not found!{bcolors.ENDC}")
|
|
exit()
|
|
print("Download Completed")
|
|
return response
|
|
|
|
def install(response, version):
|
|
"""Install the downloaded version of the project.
|
|
|
|
Args:
|
|
response (BytesIO): the downloaded zip file.
|
|
version (str): the version to install.
|
|
"""
|
|
user_input = input(f"{bcolors.WARNING}--------------------------------------------------------------------------\n"
|
|
"Note: Before proceeding, please ensure that there are no personal files or\n" \
|
|
"sensitive information in the directory you're about to delete. This action\n" \
|
|
"is irreversible, so it's important to double-check that you're making the \n" \
|
|
f"right decision. {bcolors.ENDC} Continue with caution? (Y/n) ")
|
|
|
|
if user_input.lower() in ["y", "yes"]:
|
|
print("Installing ...")
|
|
zfile = zipfile.ZipFile(BytesIO(response.content))
|
|
zfile.extractall(ROOT_DIR)
|
|
|
|
version = version.replace("v", "")
|
|
source_dir = os.path.join(ROOT_DIR, f"Vocard-{version}")
|
|
if os.path.exists(source_dir):
|
|
for filename in os.listdir(ROOT_DIR):
|
|
if filename in IGNORE_FILES + [f"Vocard-{version}"]:
|
|
continue
|
|
|
|
filename = os.path.join(ROOT_DIR, filename)
|
|
if os.path.isdir(filename):
|
|
shutil.rmtree(filename)
|
|
else:
|
|
os.remove(filename)
|
|
for filename in os.listdir(source_dir):
|
|
shutil.move(os.path.join(source_dir, filename), os.path.join(ROOT_DIR, filename))
|
|
os.rmdir(source_dir)
|
|
print(f"{bcolors.OKGREEN}Version {version} installed Successfully! Run `python main.py` to start your bot{bcolors.ENDC}")
|
|
else:
|
|
print("Update canceled!")
|
|
|
|
def parse_args():
|
|
"""Parse command line arguments."""
|
|
parser = argparse.ArgumentParser(description='Update script for Vocard.')
|
|
parser.add_argument('-c', '--check', action='store_true', help='Check the current version of the Vocard')
|
|
parser.add_argument('-v', '--version', type=str, help='Install the specified version of the Vocard')
|
|
parser.add_argument('-l', '--latest', action='store_true', help='Install the latest version of the Vocard from Github')
|
|
parser.add_argument('-b', '--beta', action='store_true', help='Install the beta version of the Vocard from Github')
|
|
return parser.parse_args()
|
|
|
|
def main():
|
|
"""Main function."""
|
|
args = parse_args()
|
|
|
|
if args.check:
|
|
check_version(with_msg=True)
|
|
|
|
elif args.version:
|
|
version = args.version
|
|
response = download_file(version)
|
|
install(response, version)
|
|
|
|
elif args.latest:
|
|
response = download_file()
|
|
version = check_version()
|
|
install(response, version)
|
|
|
|
elif args.beta:
|
|
response = download_file("refs/heads/beta")
|
|
install(response, "beta")
|
|
pass
|
|
|
|
else:
|
|
print(f"{bcolors.FAIL}No arguments provided. Run `python update.py -h` for help.{bcolors.ENDC}")
|
|
|
|
if __name__ == "__main__":
|
|
main() |