This commit is contained in:
Auric Vente 2024-02-28 04:00:24 -06:00
parent 927285366f
commit e399aa747a
1 changed files with 13 additions and 11 deletions

24
main.py
View File

@ -5,7 +5,6 @@ import json
import re import re
import httpx import httpx
import traceback import traceback
import subprocess
import os import os
import aiohttp import aiohttp
import random import random
@ -13,6 +12,7 @@ from bs4 import BeautifulSoup
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
import aiofiles import aiofiles
import shlex
HERE = Path(__file__).parent HERE = Path(__file__).parent
username = os.environ.get("GLUEBOT_USERNAME") username = os.environ.get("GLUEBOT_USERNAME")
@ -31,9 +31,8 @@ token = None
session = None session = None
delay = 3 delay = 3
gifmaker = "/usr/bin/gifmaker" gifmaker_common = [
"/usr/bin/gifmaker",
gm_common = [
"--width", 350, "--width", 350,
"--output", "/tmp/gifmaker", "--output", "/tmp/gifmaker",
"--nogrow", "--nogrow",
@ -97,11 +96,14 @@ def string_to_number(input_string):
return scaled_number return scaled_number
def join_command(command):
return " ".join(f"\"{arg}\"" for arg in command)
def gifmaker_command(args): def gifmaker_command(args):
command = [gifmaker] command = gifmaker_common.copy()
command.expand(gm_common) command.extend(args)
command.expand(args) return join_command(command)
return command
cmd_date = get_time() cmd_date = get_time()
@ -351,9 +353,9 @@ async def random_post(ws, room_id):
async def run_gifmaker(command, room_id): async def run_gifmaker(command, room_id):
process = await asyncio.create_subprocess_shell( process = await asyncio.create_subprocess_shell(
" ".join(command), command,
stdout=subprocess.PIPE, stdout=asyncio.subprocess.PIPE,
stderr=subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
shell=True, shell=True,
) )