[ejabberd] mod_irc userinfo patch

Oleg V. Motienko mmm at ttn.ru
Tue Oct 12 20:00:17 MSD 2004


Hello!

Here is small patch for mod_irc_connection (attached) which give CTCP 
USERINFO answer with jid of jabber user.

Also I change mod_irc_connection to bind irc client socket to one of 
hosts addresses (12.32.56.78 in example).
May be it's possible to give address in module's option? But my erlang 
skill is too poor :(

--- mod_irc_connection.erl  Wed Sep 22 18:18:26
+++ mod_irc_connection.erl       Tue Oct 12 19:48:58
@@ -80,7 +80,7 @@
     Addr = StateData#state.server,
     Port = 6667,
     ?DEBUG("connecting to ~s:~p~n", [Addr, Port]),
-    case gen_tcp:connect(Addr, Port, [binary, {packet, 0}]) of
+    case gen_tcp:connect(Addr, Port, [binary, {packet, 0}, {ip, 
{12,32,56,78}}]) of
        {ok, Socket} ->
            NewStateData = StateData#state{socket = Socket},
            send_text(NewStateData,

-- 
Regards, Oleg
xmpp: mmm at jabber.ttn.ru

-------------- next part --------------
--- mod_irc_connection.erl.orig	Tue Oct 12 19:42:38 2004
+++ mod_irc_connection.erl	Tue Oct 12 19:48:58 2004
@@ -399,6 +399,9 @@
 	    [From, "PRIVMSG", Nick, ":\001VERSION\001" | _] ->
 		process_version(StateData, Nick, From),
 		StateData;
+	    [From, "PRIVMSG", Nick, ":\001USERINFO\001" | _] ->
+		process_userinfo(StateData, Nick, From),
+		StateData;
 	    [From, "PRIVMSG", Nick | _] ->
 		process_privmsg(StateData, Nick, From, String),
 		StateData;
@@ -756,6 +759,17 @@
 		    "http://ejabberd.jabberstudio.org/"
 		    "\001\r\n",
 		    [FromUser])).
+
+
+process_userinfo(StateData, Nick, From) ->
+    [FromUser | _] = string:tokens(From, "!"),
+    send_text(
+      StateData,
+      io_lib:format("NOTICE ~s :\001USERINFO "
+		    "This user use xmpp://~s"
+		    "\001\r\n",
+		    [FromUser,
+		    jlib:jid_to_string(StateData#state.user)])).
 
 
 process_topic(StateData, Chan, From, String) ->


More information about the ejabberd mailing list