#include "quakedef.h"
#include "lhnet.h"
#include "console.h"
+#include "irc.h"
#define IRC_MAX_ARGS 15
#define IRC_NET_BUFFER_LEN 1024
static qboolean irc_registered;
static qboolean irc_connected;
-static cvar_t irc_nickname = { CVAR_SAVE, "irc_nickname", "", "nickname to use when connecting to IRC" };
+static cvar_t irc_nickname = { CVAR_SAVE, "irc_nickname", "darkplaces", "nickname to use when connecting to IRC" };
+static cvar_t irc_username = { CVAR_SAVE, "irc_username", "darkplaces", "username/ident to use when connecting to IRC" };
+static cvar_t irc_realname = { CVAR_SAVE, "irc_realname", "darkplaces", "realname to use when connecting to IRC" };
static mempool_t *irc_mempool;
return 0;
}
-#ifdef SUPPORTIPV6
- if (!LHNETADDRESS_Resolve(&peeraddress, addr, 6667))
- {
- Con_Printf("[IRC] Bad server address: %s.\n", addr);
- return 0;
- }
-#else
if (!LHNETADDRESS_FromString(&peeraddress, addr, 6667))
{
Con_Printf("[IRC] Bad server address: %s.\n", addr);
return 0;
}
-#endif
// this should really be non-blocking, but it does not work.
if(!(irc_socket = LHNET_OpenSocket(&address, &peeraddress, 1, 0, 0)))
irc_incoming.len = remaining_len;
}
-static void IRC_ReadMessages(void)
+static int IRC_ReadMessages(void)
{
lhnetaddress_t dummyaddress;
int read;
irc_incoming.len += read;
IRC_ProcessAllMessages();
}
+ else if (read == 0)
+ {
+ IRC_Disconnect();
+ return 0;
+ }
+
+ return -1;
}
static void IRC_WriteMessages(void)
Cvar_SetQuick(&irc_nickname, nick);
IRC_AddMessage(va(vabuf, sizeof(vabuf), "NICK %s", irc_nickname.string));
- IRC_AddMessage(va(vabuf, sizeof(vabuf), "USER %s optional optional :%s", irc_nickname.string, nick));
+ IRC_AddMessage(va(vabuf, sizeof(vabuf), "USER %s optional optional :%s", irc_username.string, irc_realname.string));
Mem_Free(nick);
}
irc_mempool = Mem_AllocPool("IRC", 0, NULL);
Cvar_RegisterVariable(&irc_nickname);
+ Cvar_RegisterVariable(&irc_username);
+ Cvar_RegisterVariable(&irc_realname);
Cmd_AddCommand("ircconnect", IRC_Connect_f, "connect to an IRC server");
Cmd_AddCommand("ircdisconnect", IRC_Disconnect_f, "disconnect from an IRC server");