Don't try to get services mood via GETMOOD

This commit is contained in:
Dpeta 2022-11-17 10:31:04 +01:00
parent 2ff1a87901
commit 16625ba936

38
irc.py
View file

@ -22,6 +22,15 @@ from oyoyo.cmdhandler import DefaultCommandHandler
from oyoyo import helpers, services from oyoyo import helpers, services
PchumLog = logging.getLogger("pchumLogger") PchumLog = logging.getLogger("pchumLogger")
SERVICES = [
"nickserv",
"chanserv",
"memoserv",
"operserv",
"helpserv",
"hostserv",
"botserv",
]
# Python 3 # Python 3
QString = str QString = str
@ -692,12 +701,13 @@ class PesterHandler(DefaultCommandHandler):
def nomatchingkey(self, target, our_handle, failed_handle, key, *error): def nomatchingkey(self, target, our_handle, failed_handle, key, *error):
# Try to get moods the old way if metadata fails. # Try to get moods the old way if metadata fails.
PchumLog.info("nomatchingkey: " + failed_handle) PchumLog.info("nomatchingkey: " + failed_handle)
chumglub = "GETMOOD " # No point in GETMOOD-ing services
try: if failed_handle.casefold() not in SERVICES:
helpers.msg(self.client, "#pesterchum", chumglub + failed_handle) try:
except OSError as e: helpers.msg(self.client, "#pesterchum", f"GETMOOD {failed_handle}")
PchumLog.warning(e) except OSError as e:
self.parent.setConnectionBroken() PchumLog.warning(e)
self.parent.setConnectionBroken()
def keynotset(self, target, our_handle, failed_handle, key, *error): def keynotset(self, target, our_handle, failed_handle, key, *error):
# Try to get moods the old way if metadata fails. # Try to get moods the old way if metadata fails.
@ -1028,12 +1038,11 @@ class PesterHandler(DefaultCommandHandler):
"""Get mood via metadata if supported""" """Get mood via metadata if supported"""
# Get via metadata or via legacy method # Get via metadata or via legacy method
if self.parent.metadata_supported == True: if self.parent.metadata_supported:
# Metadata # Metadata
for c in chums: for chum in chums:
chandle = c.handle
try: try:
helpers.metadata(self.client, chandle, "get", "mood") helpers.metadata(self.client, chum.handle, "get", "mood")
except OSError as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.parent.setConnectionBroken() self.parent.setConnectionBroken()
@ -1043,16 +1052,17 @@ class PesterHandler(DefaultCommandHandler):
"Server doesn't seem to support metadata, using legacy GETMOOD." "Server doesn't seem to support metadata, using legacy GETMOOD."
) )
chumglub = "GETMOOD " chumglub = "GETMOOD "
for c in chums: for chum in chums:
chandle = c.handle if len(chumglub + chum.handle) >= 350:
if len(chumglub + chandle) >= 350:
try: try:
helpers.msg(self.client, "#pesterchum", chumglub) helpers.msg(self.client, "#pesterchum", chumglub)
except OSError as e: except OSError as e:
PchumLog.warning(e) PchumLog.warning(e)
self.parent.setConnectionBroken() self.parent.setConnectionBroken()
chumglub = "GETMOOD " chumglub = "GETMOOD "
chumglub += chandle # No point in GETMOOD-ing services
if chum.handle.casefold() not in SERVICES:
chumglub += chum.handle
if chumglub != "GETMOOD ": if chumglub != "GETMOOD ":
try: try:
helpers.msg(self.client, "#pesterchum", chumglub) helpers.msg(self.client, "#pesterchum", chumglub)