Add IDENT support
This commit is contained in:
parent
445f47bea4
commit
390e0ffb0a
@ -26,6 +26,11 @@ non-developmental deployments.
|
||||
This'll require a few libraries:
|
||||
libircclient-dev libsqlite3-dev build-essentials
|
||||
|
||||
* Hosting
|
||||
|
||||
https://git.lain.church/emil/probotic
|
||||
https://bis64wqhh3louusbd45iyj76kmn4rzw5ysawyan5bkxwyzihj67c5lid.onion/emil/probotic
|
||||
|
||||
* License
|
||||
|
||||
Copyright 2023 https://git.lain.church/anon ,
|
||||
|
@ -10,6 +10,8 @@ typedef struct
|
||||
} creds_t;
|
||||
|
||||
VARDECL creds_t creds;
|
||||
/* nickserv identify password */
|
||||
VARDECL char * ident_password = NULL;
|
||||
|
||||
/* DECL char ** str_split(char const * s, char c); */
|
||||
/* DECL void split_clean(char ** split); */
|
||||
|
23
src/irc.c
23
src/irc.c
@ -52,7 +52,7 @@ get_username(const char * origin)
|
||||
}
|
||||
|
||||
DECL void
|
||||
ircmsg(const char* fmt,
|
||||
ircmsg(char const * reciever, char const * fmt,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
@ -72,7 +72,7 @@ ircmsg(const char* fmt,
|
||||
do
|
||||
{
|
||||
swp = irc_color_convert_to_mirc(data);
|
||||
IRCMSG(swp);
|
||||
irc_cmd_msg(session, reciever, swp);
|
||||
free(swp);
|
||||
} while((data = strtok(NULL, delim), data));
|
||||
|
||||
@ -80,11 +80,13 @@ ircmsg(const char* fmt,
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
DECL void
|
||||
event_connect(irc_session_t * lsession,
|
||||
const char * event,
|
||||
const char * origin,
|
||||
const char ** params,
|
||||
char const * event,
|
||||
char const * origin,
|
||||
char const ** params,
|
||||
unsigned int count)
|
||||
{
|
||||
(void) event;
|
||||
@ -93,13 +95,20 @@ event_connect(irc_session_t * lsession,
|
||||
(void) count;
|
||||
/* msg ChanServ IDENTIFY? */
|
||||
irc_cmd_join(lsession, creds.channel, 0);
|
||||
if (ident_password)
|
||||
{
|
||||
if (ircmsg("NickServ", "IDENTIFY %s" ident_password))
|
||||
{ exit(1); }
|
||||
memset(ident_password, '\0', strlen(indent_password));
|
||||
}
|
||||
|
||||
#ifdef INITIAL_ASSIGNMENT_MESSAGE
|
||||
if(is_no_assignment(creds.channel))
|
||||
{
|
||||
ircmsg(IRC_RED "No assignment for this channel. Finding a new..." IRC_STOP);
|
||||
ircmsg(creds.channel, IRC_RED "No assignment for this channel. Finding a new..." IRC_STOP);
|
||||
random_assign(creds.channel);
|
||||
}
|
||||
ircmsg(remind(creds.channel));
|
||||
ircmsg(creds.channel, remind(creds.channel));
|
||||
#endif /* INITIAL_ASSIGNMENT_MESSAGE */
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,9 @@ main (int argc,
|
||||
/* { creds.port = atoi(argv[1]); } */
|
||||
else if (strcmp(arg, "channel") == 0)
|
||||
{ free(creds.channel); creds.channel = strdup(argv[1]); }
|
||||
else if (strcmp(arg, "identify") == 0)
|
||||
{ ident_password = argv[1]; }
|
||||
|
||||
/* else if (strcmp(arg, "username") == 0) */
|
||||
/* { free(creds.username); creds.username = strdup(argv[1]); } */
|
||||
/* else if (strcmp(arg, "password") == 0) */
|
||||
|
26
src/parse.c
26
src/parse.c
@ -117,28 +117,28 @@ parse_command(char const * cmd)
|
||||
if (strcmp(cmd, "remind") == 0)
|
||||
{
|
||||
msgswp = remind(current_username);
|
||||
ircmsg("%s: %s", current_username, msgswp);
|
||||
ircmsg(creds.channel, "%s: %s", current_username, msgswp);
|
||||
}
|
||||
else if (strcmp(cmd, "help") == 0)
|
||||
{ ircmsg(help_msg); }
|
||||
{ ircmsg(creds.channel, help_msg); }
|
||||
else if (strcmp(cmd, "magic") == 0)
|
||||
{ ircmsg("%s: " IRC_YELLOW "%d" IRC_STOP, current_username, (rand() % 100) + 1); }
|
||||
{ ircmsg(creds.channel, "%s: " IRC_YELLOW "%d" IRC_STOP, current_username, (rand() % 100) + 1); }
|
||||
else if (strcmp(cmd, "dump") == 0)
|
||||
{
|
||||
#ifndef NO_VULN_COMMANDS
|
||||
ircmsg("%s: All projects:", current_username);
|
||||
ircmsg(creds.channel, "%s: All projects:", current_username);
|
||||
msgswp = dump();
|
||||
ircmsg(msgswp);
|
||||
ircmsg(creds.channel, msgswp);
|
||||
#else
|
||||
ircmsg("%s: dump disabled", current_username);
|
||||
ircmsg(creds.channel, "%s: dump disabled", current_username);
|
||||
#endif /* !NO_VULN_COMMANDS */
|
||||
}
|
||||
else if (strcmp(cmd, "reroll") == 0)
|
||||
{
|
||||
/* ircmsg("%s: Rerolling...", current_username); */
|
||||
/* ircmsg(creds.channel, "%s: Rerolling...", current_username); */
|
||||
purge_assignments(current_username);
|
||||
random_assign(current_username);
|
||||
ircmsg("%s: %s", current_username, remind(current_username));
|
||||
ircmsg(creds.channel, "%s: %s", current_username, remind(current_username));
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -148,19 +148,19 @@ parse_command(char const * cmd)
|
||||
if (strncmp(cmd, "raw", i) == 0)
|
||||
{
|
||||
#ifndef NO_VULN_COMMANDS
|
||||
/* ircmsg("%s: Executing SQL `%s'.", current_username, arg); */
|
||||
/* ircmsg(creds.channel, "%s: Executing SQL `%s'.", current_username, arg); */
|
||||
msgswp = raw(arg);
|
||||
ircmsg(msgswp);
|
||||
ircmsg(creds.channel, msgswp);
|
||||
#else
|
||||
ircmsg("%s: raw disabled", current_username);
|
||||
ircmsg(creds.channel, "%s: raw disabled", current_username);
|
||||
#endif /* !NO_VULN_COMMANDS */
|
||||
}
|
||||
else if (strncmp(cmd, "repo", i) == 0)
|
||||
{
|
||||
/* ircmsg("%s: Setting project repository...", current_username); */
|
||||
/* ircmsg(creds.channel, "%s: Setting project repository...", current_username); */
|
||||
set_repo(creds.channel, arg);
|
||||
msgswp = remind(creds.channel);
|
||||
ircmsg("%s: %s", current_username, msgswp);
|
||||
ircmsg(creds.channel, "%s: %s", current_username, msgswp);
|
||||
}
|
||||
}
|
||||
free(msgswp);
|
||||
|
Reference in New Issue
Block a user