Added installer script. Fixed simplematrixbotlib stability issue in api.py

This commit is contained in:
Hash Borgir 2024-02-12 19:49:00 -07:00
parent 2a6cbecd28
commit 18b5e37fd9
2 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,32 @@
From 4aa5b913f75e32f6ed06fc6e691daa856824b26a Mon Sep 17 00:00:00 2001
From: Hash Borgir <atirjavid@gmail.com>
Date: Mon, 12 Feb 2024 19:12:05 -0700
Subject: [PATCH] Fixed stability issue in api.py
---
simplematrixbotlib/api.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/simplematrixbotlib/api.py b/simplematrixbotlib/api.py
index 1d87b3d..13a78cf 100644
--- a/simplematrixbotlib/api.py
+++ b/simplematrixbotlib/api.py
@@ -295,6 +295,7 @@ class Api:
pass # Successful upload
else:
print(f"Failed Upload Response: {resp}")
+ return
content = {
"body": os.path.basename(image_filepath),
@@ -342,6 +343,7 @@ class Api:
pass # Successful upload
else:
print(f"Failed Upload Response: {resp}")
+ return
content = {
"body": os.path.basename(video_filepath),
--
2.34.1

51
install.sh Executable file
View File

@ -0,0 +1,51 @@
#!/bin/bash
# Store current directory
current_dir=$(pwd)
# Clone the simplematrixbotlib repository
git clone https://github.com/imbev/simplematrixbotlib.git
# Copy the patch file to the simplematrixbotlib directory
cp 0001-Fixed-stability-issue-in-api.py.patch $current_dir/simplematrixbotlib/
# Change directory to simplematrixbotlib
cd $current_dir/simplematrixbotlib/
# Apply the patch
git apply 0001-Fixed-stability-issue-in-api.py.patch
# Remove the patch file
rm 0001-Fixed-stability-issue-in-api.py.patch
# Install simplematrixbotlib
pip install .
# Change back to the original directory
cd $current_dir
# Install requirements
pip install -r requirements.txt
# Create .env file with required content
echo -e "MATRIX_URL = \"https://matrix.org\"\nMATRIX_USER = \"\"\nMATRIX_PASS = \"\"" > .env
# Print ASCII art
echo " _____ ____ _ "
echo "| ___| _ _ __ __ _ _ _ _ _ | __ ) ___ | |_ "
echo "| |_ | | | | '_ \ / _\` | | | | | | | | _ \ / _ \| __| "
echo "| _|| |_| | | | | (_| | |_| | |_| | | |_) | (_) | |_ "
echo "|_| \__,_|_| |_|\__, |\__,_|\__, | |____/ \___/ \__| "
echo " |___/ |___/ "
# Echo setup completion message
echo "Bot setup completed."
# Prompt user to modify funguy.py to set ADMIN_USER
echo "Modify .env file and set your credentials and homeserver"
echo "Please open funguy.py and set the ADMIN_USER variable to your admin username."
# Launch the bot
echo "Launch the bot with 'python funguy.py'"