Merge pull request #2 from jcjordyn130/main

Add placeholders for Server() and allow for a list of bot oppers
This commit is contained in:
a-bad-dev 2026-03-14 02:32:43 -03:00 committed by GitHub
commit 66ba59e5d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

10
main.py
View file

@ -11,11 +11,12 @@ import queue
class Server():
# Setup the IRC related things such as user details and prefixes
# This function also sets up the threading events and queues
def __init__(self, realname, nickname, channel, command_prefix = "$!", bot_prefix = "$$"):
def __init__(self, realname, nickname, channel, command_prefix = "$!", bot_prefix = "$$", opper_nicknames = []):
print(f"[SERVER/MAINTHREAD] Using Server() on Python3 PID {os.getpid()}")
self.realname = realname
self.nickname = nickname
self.channel = channel
self.opper_nicknames = opper_nicknames
# Prefix for commands to execute
self.command_prefix = command_prefix
@ -261,7 +262,7 @@ class Server():
if msg["command"] == "INVITE":
msg_source = msg["params"][0]
source_user = msg["prefix"].partition("!~")[0]
if source_user == "jcjordyn120":
if source_user in self.opper_nicknames:
print(f"[RECVTHREAD] Joining channel by user command!")
self._msg_q.put(f"JOIN {msg['params'][-1]}\r\n".encode())
@ -310,8 +311,9 @@ class Server():
self._msg_q.put(f"PRIVMSG {source_channel} :CMD {cmd} exited with returncode {proc.returncode}\r\n".encode())
if __name__ == "__main__":
serv = Server("<username>", "<nick>", "<channel>") #
serv.connect("<server IP>", 6667, sock_recvbuf = 8192) # NOTE TO USER: You have to set these values
serv = Server("username", "nickname", "##channel", opper_nicknames = ["opperhere"])
serv.connect("IP", 6667, sock_recvbuf = 8192)
# Allow for the user to send raw IRC messages
# These bypass the send queue