Created
April 15, 2012 23:11
-
-
Save rcoup/2395261 to your computer and use it in GitHub Desktop.
Patch for nagircbot 0.0.33 to support NickServ authentication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- orig/nagircbot-0.0.33/anna.cpp 2011-01-18 23:39:10.000000000 +1300 | |
+++ anna.cpp 2012-04-16 10:49:13.080360702 +1200 | |
@@ -50,6 +50,7 @@ | |
char *nick = "nagircbot"; | |
char *user = "nagircbot"; | |
char *password = NULL; | |
+char *nickserv_password = NULL; | |
int one_line = 1; | |
char *username = "Nagios IRC Bot " VERSION ", (C) www.vanheusden.com"; /* complete username */ | |
int verbose = 255; /* default is log everything */ | |
@@ -118,7 +119,7 @@ | |
return 0; | |
} | |
-int irc_login(server_t server_conn, char *user, char *username, char *server, char *password) | |
+int irc_login(server_t server_conn, char *user, char *username, char *server, char *password, char *nickserv_password) | |
{ | |
if (password != NULL && send_irc(server_conn, "PASS %s", password) == -1) | |
return -1; | |
@@ -130,6 +131,9 @@ | |
if (send_irc(server_conn, "USER %s \"localhost\" \"%s\" :%s", user, server, username) == -1) | |
return -1; | |
+ if (nickserv_password != NULL && send_irc(server_conn, "PRIVMSG NICKSERV :IDENTIFY %s", nickserv_password) == -1) | |
+ return -1; | |
+ | |
return 0; | |
} | |
@@ -814,6 +818,7 @@ | |
printf("-u username (for logging into the irc server)\n"); | |
printf("-U name (as seen by other users)\n"); | |
printf("-p password (for logging into the irc server)\n"); | |
+ printf("-Z NickServ password (for user authentication)\n"); | |
printf("-N prefix for all in-channel messages, e.g. for nick highlight\n"); | |
printf("-m display all information on separate lines\n"); | |
printf("-t show a summary in the topic-line\n"); | |
@@ -867,7 +872,7 @@ | |
color_str[3] = mystrdup("_11,1 "); | |
color_str[0][0] = color_str[1][0] = color_str[2][0] = color_str[3][0] = 3; | |
- while((c = getopt(argc, argv, "N:A:eRP:xXF:f:i:hHSs:c:k:Ctn:u:U:p:T:mvdVz:I:")) != -1) | |
+ while((c = getopt(argc, argv, "N:A:eRP:xXF:f:i:hHSs:c:k:Ctn:u:U:p:Z:T:mvdVz:I:")) != -1) | |
{ | |
switch(c) | |
{ | |
@@ -953,6 +958,10 @@ | |
password = mystrdup(optarg); | |
break; | |
+ case 'Z': | |
+ nickserv_password = mystrdup(optarg); | |
+ break; | |
+ | |
case 'U': | |
username = mystrdup(optarg); | |
break; | |
@@ -1090,7 +1099,7 @@ | |
dolog("Logging in..."); | |
- if (irc_login(server_conn, user, username, server, password) == -1) | |
+ if (irc_login(server_conn, user, username, server, password, nickserv_password) == -1) | |
state = S_DISCONNECTING; | |
if (irc_join_channel(server_conn, channel, keyword) == -1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment