From 26464f4e489ca3355608d182db7741ffa6dc4c04 Mon Sep 17 00:00:00 2001 From: Swee Date: Sun, 22 Sep 2024 13:14:17 -0700 Subject: [PATCH] Update sweebot.py --- sweebot.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/sweebot.py b/sweebot.py index cba123b..391ef10 100644 --- a/sweebot.py +++ b/sweebot.py @@ -4,14 +4,25 @@ __version__ = "0.0.1 patch 4" import socket import subprocess from time import sleep, time, ctime -from os import system as ossystem, path, environ, listdir +from os import system as ossystem, path, environ, listdir, getcwd +cwd = getcwd() import re from random import choice, randint as random import traceback import threading -import sqlite3 -conn = sqlite3.connect("/home/swee/sbirc.db") -database = conn.cursor() +class config: + def __init__(self): + import sqlite3 + conn = sqlite3.connect(cwd + "/sbirc.db") + self.database = conn.cursor() + def perms(self, cloak: str): + try: + self.database.execute(f"SELECT * FROM users WHERE username = '{cloak}';") + output = self.database.fetchall() + return output[0][1] + except: + return '' + # Code snippet from my buddy Irish # Define a dictionary to map terminal color codes to IRC color codes color_map = { @@ -129,6 +140,7 @@ irc3 = bot_irc() irc.connect_irc( server_irc, port_irc, channel_irc, botnick_irc, botpass_irc, botnickpass_irc ) +sbconfig = config() threes = [":3", ":3c", "uwu", "owo", "/ᐠ。ꞈ。ᐟ\\", "(✿◠‿◠)"] snacks = ["PepperMintHTMLs", "Dice App candies", "SweeCrypt codes", "Windows 11 Bloomberry flavored icecream"] run = 0 @@ -138,13 +150,6 @@ times = 0 def update(): open("/home/swee/run.txt", 'w').write(str(run)) open("/home/swee/block.txt", 'w').write(str(block)) -def getperms(cloak: str): - try: - database.execute("SELECT * FROM users WHERE username = '"+ cloak + "';") - output = database.fetchall() - return output[0][1] - except: - return '' update() def irci2(): @@ -213,7 +218,7 @@ while True: nick = text.split(" ")[0][1:].split("!")[0] username = text.split(" ")[0][1:].split("@")[1] try: - perms = getperms(username) + perms = config.perms(username) except: perms = "" print(command) @@ -267,7 +272,10 @@ while True: elif command[0] == "$perms": if len(command) == 2: - irc.send_irc(channel, nick + ": permissions of cloak " + command[1] + ": " + getperms(command[1])) + if config.perms(command[1]) != "": + irc.send_irc(channel, nick + ": permissions of cloak " + command[1] + ": " + config.perms(command[1])) + else: + irc.send_irc(channel, nick + ": The cloak " + command[1] + " Doesn't have permissions.") else: if perms != "": irc.send_irc(channel, nick + ": " + perms)