diff options
author | Epoch Qwert <epoch@53flpnlls43fcguy.onion> | 2014-08-10 02:56:31 -0500 |
---|---|---|
committer | Epoch Qwert <epoch@53flpnlls43fcguy.onion> | 2014-08-10 02:56:31 -0500 |
commit | cdc0b8465879a9634d8acc79adad02254309a25c (patch) | |
tree | 1aa294cfa6b6e17126fbde53e5d00ae76d60ff95 | |
parent | 5405317a9c153301f20abea25ab65881f21ee9c5 (diff) | |
download | segfault-cdc0b8465879a9634d8acc79adad02254309a25c.tar.gz segfault-cdc0b8465879a9634d8acc79adad02254309a25c.zip |
added nick globbing for easier control of many bots at once.
-rw-r--r-- | segfault.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -544,13 +544,15 @@ struct alias *getalias_h(char *msg) { } void c_alias_h(int fd,char *from,char *line) { + char tmps[512]; char *derp=strchr(line,' '); struct alias *tmp; if(!derp) { if((tmp=getalias_h(line)) != NULL) { privmsg(fd,from,tmp->target); } else { - privmsg(fd,from,"not an alias."); + snprintf(tmps,sizeof(tmps),"'%s' not an alias.",line); + privmsg(fd,from,tmps); } return; } @@ -849,6 +851,7 @@ void message_handler(int fd,char *from,char *nick,char *msg,int redones) { struct alias *m; char *tmp2; char tmp[512]; + int len; int sz; //debug_time(fd,from); if(strcmp(nick,mynick)) { @@ -867,11 +870,12 @@ void message_handler(int fd,char *from,char *nick,char *msg,int redones) { append_file(fd,"raw",LOG,msg,'\n'); debug_time(fd,from,"finished writing to log."); } - //if(!strchr(msg,'*')-msg) - if(!strncmp(msg,mynick,strlen(mynick))) { - if(msg[strlen(mynick)] == ',' || msg[strlen(mynick)] == ':') { - if(msg[strlen(mynick)+1] == ' ') { - msg+=strlen(mynick)+1; + len=strchr(msg,'*')?strchr(msg,'*')-msg:strlen(mynick); + if(!strncmp(msg,mynick,len)) { + if(msg[len] == '*') len++; + if(msg[len] == ',' || msg[len] == ':') { + if(msg[len+1] == ' ') { + msg+=len+1; msg[0]=trigger_char; } } |