Skip to content

Commit

Permalink
Add support for away-notify
Browse files Browse the repository at this point in the history
Some servers apparently sent away-notify messages even without the
cap being negotiated which caused a crash.
  • Loading branch information
hifi committed Jul 14, 2023
1 parent 881dd45 commit a7f861a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions heisenbridge/network_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,14 @@ def init(self):
cmd.add_argument(
"--add",
nargs=1,
choices=["message-tags", "chghost", "draft/relaymsg", "znc.in/self-message", "twitch.tv/membership"],
choices=[
"message-tags",
"chghost",
"draft/relaymsg",
"znc.in/self-message",
"twitch.tv/membership",
"away-notify",
],
help="Add to CAP request",
)
cmd.add_argument("--remove", nargs=1, help="Remove from CAP request")
Expand Down Expand Up @@ -1937,7 +1944,16 @@ def on_whoisrealhost(self, conn, event) -> None:
data["realhost"] = event.arguments[1]

def on_away(self, conn, event) -> None:
if event.arguments[0].lower() in self.whois_data:
if len(event.arguments) < 2:
target = self
if event.source.nick in self.rooms:
target = self.rooms[event.source.nick]

if event.target is None:
target.send_notice(f"{event.source.nick} is no longer away")
else:
target.send_notice(f"{event.source.nick} is now away: {event.target}")
elif event.arguments[0].lower() in self.whois_data:
self.whois_data[event.arguments[0].lower()]["away"] = event.arguments[1]
else:
self.send_notice(f"{event.arguments[0]} is away: {event.arguments[1]}")
Expand Down

0 comments on commit a7f861a

Please sign in to comment.