Mods
This commit is contained in:
parent
1ee48e2952
commit
8ab18265fa
37
main.py
37
main.py
|
@ -3,6 +3,7 @@ import traceback, subprocess, os, aiohttp, sys, random
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import aiofiles
|
||||||
|
|
||||||
HERE = Path(__file__).parent
|
HERE = Path(__file__).parent
|
||||||
username = os.environ.get("GLUEBOT_USERNAME")
|
username = os.environ.get("GLUEBOT_USERNAME")
|
||||||
|
@ -30,6 +31,9 @@ def clean_lines(s):
|
||||||
def random_int(min_val, max_val):
|
def random_int(min_val, max_val):
|
||||||
return random.randint(min_val, max_val)
|
return random.randint(min_val, max_val)
|
||||||
|
|
||||||
|
def get_path(name):
|
||||||
|
return str(Path(HERE, name))
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"User-Agent": "gluebot",
|
"User-Agent": "gluebot",
|
||||||
"Origin": "https://deek.chat",
|
"Origin": "https://deek.chat",
|
||||||
|
@ -132,17 +136,22 @@ async def on_message(ws, message):
|
||||||
|
|
||||||
elif cmd == "bird" or cmd == "birds" or cmd == "birb" or cmd == "birbs" or cmd == "brb":
|
elif cmd == "bird" or cmd == "birds" or cmd == "birb" or cmd == "birbs" or cmd == "brb":
|
||||||
update_time()
|
update_time()
|
||||||
await gif_bird(None, room_id)
|
await random_bird(ws, room_id)
|
||||||
|
|
||||||
elif cmd == "post" or cmd == "shitpost" or cmd == "4chan" or cmd == "anon" or cmd == "shit":
|
elif cmd == "post" or cmd == "shitpost" or cmd == "4chan" or cmd == "anon" or cmd == "shit":
|
||||||
update_time()
|
update_time()
|
||||||
await random_post(ws, room_id)
|
await random_post(ws, room_id)
|
||||||
|
|
||||||
def get_input_path(name):
|
async def random_bird(ws, room_id):
|
||||||
return str(Path(HERE, name))
|
birdfile = get_path("data/aves.txt")
|
||||||
|
|
||||||
|
async with aiofiles.open(birdfile, mode="r", encoding="utf-8") as file:
|
||||||
|
birds = await file.readlines()
|
||||||
|
bird = random.choice(birds).strip()
|
||||||
|
await send_message(ws, f".i {bird} bird", room_id)
|
||||||
|
|
||||||
async def gif_describe(who, room_id):
|
async def gif_describe(who, room_id):
|
||||||
input_path = get_input_path("describe.jpg")
|
input_path = get_path("describe.jpg")
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
gifmaker,
|
gifmaker,
|
||||||
|
@ -156,7 +165,7 @@ async def gif_describe(who, room_id):
|
||||||
await run_gifmaker(command, room_id)
|
await run_gifmaker(command, room_id)
|
||||||
|
|
||||||
async def gif_wins(who, room_id):
|
async def gif_wins(who, room_id):
|
||||||
input_path = get_input_path("wins.gif")
|
input_path = get_path("wins.gif")
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
gifmaker,
|
gifmaker,
|
||||||
|
@ -169,7 +178,7 @@ async def gif_wins(who, room_id):
|
||||||
await run_gifmaker(command, room_id)
|
await run_gifmaker(command, room_id)
|
||||||
|
|
||||||
async def gif_numbers(who, room_id):
|
async def gif_numbers(who, room_id):
|
||||||
input_path = get_input_path("numbers.png")
|
input_path = get_path("numbers.png")
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
gifmaker,
|
gifmaker,
|
||||||
|
@ -181,7 +190,7 @@ async def gif_numbers(who, room_id):
|
||||||
await run_gifmaker(command, room_id)
|
await run_gifmaker(command, room_id)
|
||||||
|
|
||||||
async def gif_date(who, room_id):
|
async def gif_date(who, room_id):
|
||||||
input_path = get_input_path("time.jpg")
|
input_path = get_path("time.jpg")
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
gifmaker,
|
gifmaker,
|
||||||
|
@ -193,20 +202,6 @@ async def gif_date(who, room_id):
|
||||||
|
|
||||||
await run_gifmaker(command, room_id)
|
await run_gifmaker(command, room_id)
|
||||||
|
|
||||||
async def gif_bird(who, room_id):
|
|
||||||
input_path = get_input_path("bird.png")
|
|
||||||
|
|
||||||
command = [
|
|
||||||
gifmaker,
|
|
||||||
gm_common,
|
|
||||||
f"--input '{input_path}'",
|
|
||||||
"--words '[randomx]' --randomfile data/aves.txt --bgcolor 0,0,0",
|
|
||||||
"--filter anyhue2 --frames 3 --fontsize 42 --fillwords",
|
|
||||||
"--fontcolor light --bgcolor dark --outline font --opacity 0.9",
|
|
||||||
]
|
|
||||||
|
|
||||||
await run_gifmaker(command, room_id)
|
|
||||||
|
|
||||||
async def random_post(ws, room_id):
|
async def random_post(ws, room_id):
|
||||||
boards = ["g", "an", "ck", "lit", "x", "tv", "v", "fit", "k", "o"]
|
boards = ["g", "an", "ck", "lit", "x", "tv", "v", "fit", "k", "o"]
|
||||||
board = random.choice(boards)
|
board = random.choice(boards)
|
||||||
|
|
|
@ -3,3 +3,4 @@ websockets ~= 12.0
|
||||||
aiohttp ~= 3.9.3
|
aiohttp ~= 3.9.3
|
||||||
beautifulsoup4 ~= 4.12.3
|
beautifulsoup4 ~= 4.12.3
|
||||||
httpx ~= 0.27.0
|
httpx ~= 0.27.0
|
||||||
|
aiofiles ~= 23.2.1
|
Loading…
Reference in New Issue