From 11ae646a3ccc39eb0eb9ab6091b4a390ada92aa0 Mon Sep 17 00:00:00 2001
From: ElTata <eltata@firemail.cc>
Date: Tue, 13 Apr 2021 14:08:58 +0200
Subject: [PATCH] fix: update userhost for auto-logged registered users

---
 Irpg/Main.pm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Irpg/Main.pm b/Irpg/Main.pm
index 7992e6f..d9519da 100644
--- a/Irpg/Main.pm
+++ b/Irpg/Main.pm
@@ -537,6 +537,18 @@ sub parse {
         if ($opts->{voiceonlogin}) {
             Irpg::Irc::sts("MODE $opts->{botchan} +v :$arg[3]");
         }
+        # We call /USERHOST now to update userhost in rps
+        # we can do it because we know that the user is registered from this section
+        Irpg::Irc::sts("USERHOST $arg[3]");
+    }
+    elsif ($arg[1] eq '302') {
+        # 302 is RPL_USERHOST
+        # update of userhost because /USERHOST is called only for
+        # registered users
+        $arg[3] =~ m/:(\w+)\*?=[+-](.*)/;
+        foreach (grep { $rps->{$_}{nick} eq $1 } keys %$rps) {
+            $rps->{$_}{userhost} = "$1!$2";
+        }
     }
     elsif ($arg[1] eq 'privmsg') {
         $arg[0] = substr($arg[0],1); # strip leading : from privmsgs
-- 
GitLab