commit 2b67eb5866f83b91d2641ac6cc16eee93793894b
parent 184782d97f9b3add672905074e6dfa04a53224e2
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Wed, 11 Jul 2012 23:15:37 +0200
make -w work with -o
Diffstat:
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/irctk.c b/irctk.c
@@ -176,6 +176,7 @@ static struct argp_option options[] = {
struct arguments
{
char nick[MAX_NICK_LEN];
+ char hostname[MAX_NICK_LEN];
char *server;
int port;
char *password;
@@ -226,6 +227,7 @@ struct arguments args;
void initialize_args()
{
strncpy(args.nick, "irctk", MAX_NICK_LEN-1);
+ strncpy(args.hostname, "!~UNKNOWN@UNKNOWN", MAX_NICK_LEN-1);
args.server = NULL;
args.password = NULL;
args.port = 6667;
@@ -1168,7 +1170,9 @@ int do_cmd_msg(irc_session_t *s, char *chan, char* line)
return rsl;
if (args.own) {
- printf("[%s] <%s> %s", is_local ? chan : "", output_nick(args.nick),
+ printf("[%s] <%s%s> %s", is_local ? chan : "",
+ output_nick(args.nick),
+ args.with_host ? args.hostname : "",
line);
fflush(stdout);
}
@@ -1282,8 +1286,14 @@ void manage_event (irc_session_t *session, const char *event, const char *origin
const char **params, unsigned int count)
{
int rsl = 0; // TODO use
+ char temp[MAX_NICK_LEN+1];
saw_user(origin);
+ irc_target_get_nick(origin, temp, MAX_NICK_LEN);
+ if (!strcmp(temp, args.nick)) {
+ // it is us, store our hostname
+ irc_target_get_host(origin, args.hostname, MAX_NICK_LEN);
+ }
if (atoi(event) == LIBIRC_RFC_ERR_ERRONEUSNICKNAME) {
if (args.force_nick) {
@@ -1359,9 +1369,7 @@ void event_nick (irc_session_t *session, const char *event, const char *origin,
void event_join (irc_session_t * session, const char *event, const char *origin,
const char ** params, unsigned int count)
{
- // TODO check if it is us!
manage_event(session, event, origin, params, count);
- // TODO make it an option? irc_cmd_user_mode (session, "+i");
debug("[%s] <%s> /join %s\n", params[0], origin, params[0]);
saw_user(params[0]);