Compare commits
4 Commits
f92d59dd91
...
master
Author | SHA1 | Date | |
---|---|---|---|
97a315d2d1 | |||
b29cf737a7 | |||
51a37c4562 | |||
34a3f06d91 |
17
bert.py
17
bert.py
@ -72,7 +72,7 @@ def connect(host, port):
|
||||
global irc
|
||||
print("Connecting to "+host+":"+str(port))
|
||||
context = ssl.create_default_context()
|
||||
with socket.create_connection((host, port)) as sock:
|
||||
with socket.create_connection((host, port), timeout=180) as sock:
|
||||
irc = context.wrap_socket(sock, server_hostname=host)
|
||||
|
||||
|
||||
@ -140,7 +140,14 @@ def me(chan, msg):
|
||||
|
||||
|
||||
def getData():
|
||||
try:
|
||||
raw = irc.recv(4096)
|
||||
except TimeoutError:
|
||||
print("Connection timed out!")
|
||||
sys.exit(0)
|
||||
if not raw:
|
||||
print("Connection lost!")
|
||||
sys.exit(0)
|
||||
try:
|
||||
data = raw.decode("UTF-8")
|
||||
except:
|
||||
@ -173,7 +180,7 @@ def is_registered(username):
|
||||
try:
|
||||
sendRaw("WHOIS "+str(username)+"\n")
|
||||
user_info = getMessage()
|
||||
regex = r"330 "+str(re.escape(nick))+" "+str(re.escape(username))+" \S+ :is logged in as"
|
||||
regex = rf"330 {str(re.escape(nick))} {str(re.escape(username))} \S+ :is logged in as"
|
||||
matches = re.finditer(regex, user_info, re.MULTILINE)
|
||||
for match in matches:
|
||||
acc_name = match.group(0).split()[3]
|
||||
@ -358,14 +365,14 @@ def command_loop():
|
||||
except:
|
||||
reason = "None"
|
||||
print("with no reason")
|
||||
if user == ircnick:
|
||||
say(channel, "You can't give rep to yourself. Selfish little prick!")
|
||||
continue
|
||||
try:
|
||||
acc_name = is_registered(user)
|
||||
give_acc = is_registered(ircnick)
|
||||
print("found account name for "+str(user)+": "+str(acc_name))
|
||||
if acc_name != None and give_acc != None:
|
||||
if acc_name == give_acc:
|
||||
say(channel, "You can't give rep to yourself. Selfish little prick!")
|
||||
continue
|
||||
give_rep(acc_name, user, give_acc, reason, channel)
|
||||
elif give_acc == None:
|
||||
say(channel, "You are not registered!")
|
||||
|
Reference in New Issue
Block a user