Check http://www.eleves.ens.fr:8080/home/fleuret for latest version
-----------------------------------------------------------------------------*/
-#define VERSION "v2.9.2d"
+#define VERSION "v2.9.3a"
#define OPTIONS ""
#include <time.h>
#define DEFAULT_CONTROL_CHAR '|'
#define DELAY_NICK_BACK 300
-#define DELAY_MAX_RECONNECT 300
+#define DELAY_MAX_RECONNECT 120
#define DELAY_DEAD_SERVER 900
#define DEFAULT_SERVER "sil.polytechnique.fr"
int deban_delay = DEFAULT_DEBAN_DELAY;
char control_char = DEFAULT_CONTROL_CHAR;
-int cop_mode;
+int cop_mode, anti_flood, anti_clone, ctcp_reply;
int delay;
timeval delay_pause;
if(buffer[0] != '\0') control_char = buffer[0];
}
}
+ else if(strcmp(buffer, "COPMODE") == 0)
+ {
+ cop_mode = 1;
+ }
+ else if(strcmp(buffer, "ANTIFLOOD") == 0)
+ {
+ anti_flood = 1;
+ anti_flood_off_until = current_time;
+ }
+ else if(strcmp(buffer, "ANTICLONES") == 0)
+ {
+ anti_clone = 1;
+ }
+ else if(strcmp(buffer, "CTCPREPLY") == 0)
+ {
+ ctcp_reply = 1;
+ }
+ else if(strcmp(buffer, "CHANNEL") == 0)
+ {
+ if(r != NULL)
+ {
+ r = next_word(buffer, r, SMALL_BUFFER_SIZE);
+ strncpy(home_channel, buffer, SMALL_BUFFER_SIZE);
+ }
+ }
}
}
shit_list.Reverse();
(*file)<<"% Config file for a TropBot " VERSION "\n";
(*file)<<"\n";
+ (*file)<<"% Delay in s before +o on level 2 users\n";
(*file)<<"OPDELAY "<<op_delay<<"\n";
+ (*file)<<"% Delay before auto -b on servers +b\n";
(*file)<<"DEBANDELAY "<<deban_delay<<"\n";
+ (*file)<<"% Charactere used for public commands\n";
(*file)<<"CONTROLCHAR "<<control_char<<"\n";
(*file)<<"\n";
+ (*file)<<"% Home channel\n";
+ (*file)<<"CHANNEL "<<home_channel<<"\n";
+
+ (*file)<<"\n";
+ (*file)<<"% Cop-mode activation/desactivation\n";
+ if(cop_mode) (*file)<<"COPMODE\n";
+ else (*file)<<"% COPMODE\n";
+
+ (*file)<<"% Anti-flood activation/desactivation\n";
+ if(anti_flood) (*file)<<"ANTIFLOOD\n";
+ else (*file)<<"% ANTIFLOOD\n";
+ (*file)<<"% Anti-clones activation/desactivation\n";
+ if(anti_clone) (*file)<<"ANTICLONES\n";
+ else (*file)<<"% ANTICLONES\n";
+
+ (*file)<<"% Ctcp replies activation/desactivation\n";
+ if(ctcp_reply) (*file)<<"CTCPREPLY\n";
+ else (*file)<<"% CTCPREPLY\n";
+
+ (*file)<<"\n";
+
+ (*file)<<"% Friends list\n";
for(person=level_list.first; person != NULL; person=person->next)
{
(*file)<<"FRIEND "<<person->body->level<<" "<<person->body->pattern;
(*file)<<"\n";
+ (*file)<<"% Restricted-sites list\n";
for(restricted=restricted_list.first;
restricted != NULL;
restricted=restricted->next)
(*file)<<"\n";
+ (*file)<<"% Shit list\n";
for(welcome=shit_list.first; welcome != NULL; welcome=welcome->next)
(*file)<<"SHIT "<<welcome->body->pattern<<" "<<
welcome->body->time_max - current_time<<" "<<
welcome->body->comment<<"\n";
+ (*file)<<"\n";
+ (*file)<<"% End of config file\n";
error = 0;
}
else error = 1;
}
else no_authorized = 1;
}
+ else if(eq("cr", buffer) || eq("ctcpreply", buffer))
+ {
+ if(level >= LEVEL_OP)
+ {
+ ctcp_reply = !ctcp_reply;
+ if(ctcp_reply) tell(chat, nick, "CTCP reply ON\n");
+ else tell(chat, nick, "CTCP reply OFF\n");
+ }
+ else no_authorized = 1;
+ }
+ else if(eq("ac", buffer) || eq("anticlones", buffer))
+ {
+ if(level >= LEVEL_OP)
+ {
+ anti_clone = !anti_clone;
+ if(anti_clone) tell(chat, nick, "Anti-clones ON\n");
+ else tell(chat, nick, "Anti-clones OFF\n");
+ }
+ else no_authorized = 1;
+ }
else if(eq("ao", buffer) || eq("antifloodoff", buffer))
{
if(level >= LEVEL_OP)
r = next_word(buffer_time, r, SMALL_BUFFER_SIZE);
duration = string_to_seconds(buffer_time);
anti_flood_off_until = current_time + duration;
+ anti_flood = 1;
}
+ else
+ {
+ anti_flood_off_until = current_time;
+ anti_flood = !anti_flood;
+ }
+
+ if(!anti_flood)
+ tell(chat, nick, "Anti-flood off\n");
if(anti_flood_off_until > current_time)
{
string_duration = seconds_to_string(anti_flood_off_until -
tell(chat, nick, IRC_buffer);
}
- else tell(chat, nick, "Anti-flood on\n");
+ else
+ tell(chat, nick, "Anti-flood on\n");
}
else no_authorized = 1;
}
{
if(dont_flood_server() || (level >= LEVEL_FRIEND))
{
- char *a;
- if(cop_mode) a = "ON"; else a = "OFF";
+ char *cop, *ao, *ac, *cr;
+ if(cop_mode) cop = "ON"; else cop = "OFF";
+ if(anti_flood) ao = "ON"; else ao = "OFF";
+ if(anti_clone) ac = "ON"; else ac = "OFF";
+ if(ctcp_reply) cr = "ON"; else cr = "OFF";
if(father)
{
sprintf(IRC_buffer,
"control_char '%c' op_delay %ds deban_delay %ds "
- "cop-mode %s"
+ "cop-mode %s anti-flood %s anti-clone %s ctcp-reply %s"
" your level is %d. I am a father with %d sons.\n",
- control_char, op_delay, deban_delay, a,
+ control_char, op_delay, deban_delay,
+ cop, ao, ac, cr,
level, nb_sons);
tell(chat, nick, IRC_buffer);
}
{
sprintf(IRC_buffer,
"control_char '%c' op_delay %ds deban_delay %ds "
- "cop-mode %s"
- " your level is %d. I'm a clone.\n",
- control_char, op_delay, deban_delay, a,
+ "cop-mode %s anti-flood %s anti-clone %s ctcp-reply %s"
+ " your level is %d. I am a son.\n",
+ control_char, op_delay, deban_delay,
+ cop, ao, ac, cr,
level);
tell(chat, nick, IRC_buffer);
}
}
else if(eq("db", buffer) || eq("deban", buffer))
{
- if(level >= LEVEL_OP)
+ if(level >= LEVEL_FRIEND)
{
while(r != NULL)
{
tropbot_cmd(NULL, prefix, nick, msg);
}
- version = 0;
- ping = 0;
- for(k=0; k<n_ctcp; k++)
+ if(ctcp_reply)
{
- r = slice_ctcp[k];
- r = next_word(buffer, r, SMALL_BUFFER_SIZE);
-
- // Reply the CTCP VERSION
- if(eq("VERSION", buffer) && !version)
+ version = 0;
+ ping = 0;
+ for(k=0; k<n_ctcp; k++)
{
- if(dont_flood_server())
+ r = slice_ctcp[k];
+ r = next_word(buffer, r, SMALL_BUFFER_SIZE);
+
+ // Reply the CTCP VERSION
+ if(eq("VERSION", buffer) && !version)
{
- version = 1;
- sprintf(IRC_buffer, "NOTICE %s :"
- "\001VERSION \002TropBot\002 " VERSION OPTIONS
- ", " SYSTEM " system, " DATE ". "
- "Contact THX-1138 on IRCNet, or <francois.fleuret@inria.fr>"
- "\001\n",
- nick);
- write_irc(IRC_buffer);
+ if(dont_flood_server())
+ {
+ version = 1;
+ sprintf(IRC_buffer, "NOTICE %s :"
+ "\001VERSION \002TropBot\002 " VERSION OPTIONS
+ ", " SYSTEM " system, " DATE ". "
+ "Contact THX-1138 on IRCNet, or <francois.fleuret@inria.fr>"
+ "\001\n",
+ nick);
+ write_irc(IRC_buffer);
+ }
}
- }
- // Reply the CTCP PING
- else if(eq("PING", buffer) && !ping)
- {
- ping = 1;
- if(r != NULL)
- if(dont_flood_server())
- {
- ping = 1;
- r = next_word(buffer, r, SMALL_BUFFER_SIZE);
- sprintf(IRC_buffer,
- "NOTICE %s :\001PING %s\001\n", nick, buffer);
- write_irc(IRC_buffer);
- }
- }
- // DCC (chat)
- else if(eq("DCC", buffer))
- {
- if(level >= LEVEL_OP)
+ // Reply the CTCP PING
+ else if(eq("PING", buffer) && !ping)
{
+ ping = 1;
if(r != NULL)
+ if(dont_flood_server())
+ {
+ ping = 1;
+ r = next_word(buffer, r, SMALL_BUFFER_SIZE);
+ sprintf(IRC_buffer,
+ "NOTICE %s :\001PING %s\001\n", nick, buffer);
+ write_irc(IRC_buffer);
+ }
+ }
+ // DCC (chat)
+ else if(eq("DCC", buffer))
+ {
+ if(level >= LEVEL_OP)
{
- r = next_word(buffer, r, SMALL_BUFFER_SIZE);
- if(eq("CHAT", buffer))
+ if(r != NULL)
{
- if(accepting_dcc_chat(prefix, nick, level, r) != 0)
+ r = next_word(buffer, r, SMALL_BUFFER_SIZE);
+ if(eq("CHAT", buffer))
{
- sprintf(IRC_buffer, "NOTICE %s :\002Error\002"
- " can't connect\n", nick);
+ if(accepting_dcc_chat(prefix, nick, level, r) != 0)
+ {
+ sprintf(IRC_buffer, "NOTICE %s :\002Error\002"
+ " can't connect\n", nick);
+ write_irc(IRC_buffer);
+ }
+ }
+ else
+ {
+ sprintf(IRC_buffer,
+ "NOTICE %s :I can only DCC CHAT\n", nick);
write_irc(IRC_buffer);
}
}
- else
- {
- sprintf(IRC_buffer,
- "NOTICE %s :I can only DCC CHAT\n", nick);
- write_irc(IRC_buffer);
- }
}
- }
- else if(dont_flood_server())
- {
- sprintf(IRC_buffer,
- "NOTICE %s :Sorry, can't accept DCC from you\n",
- nick, buffer);
- write_irc(IRC_buffer);
+ else if(dont_flood_server())
+ {
+ sprintf(IRC_buffer,
+ "NOTICE %s :Sorry, can't accept DCC from you\n",
+ nick, buffer);
+ write_irc(IRC_buffer);
+ }
}
}
}
l = level_person(prefix, NULL);
- if((l < LEVEL_FRIEND) && (restricted_list.Matches(prefix)))
+ if(anti_clone && (l < LEVEL_FRIEND) && (restricted_list.Matches(prefix)))
restricted = check_restricted(where, prefix);
else restricted = 0;
{
NodeList<DelayModeChange *> *md;
- if(current_time > anti_flood_off_until) check_flood();
+ if(anti_flood && (current_time > anti_flood_off_until)) check_flood();
check_delay_mode_change();
send_mode(current_channel);
last_answer_time = 0;
anti_flood_off_until = 0;
+ // The bot does NOTHING at first
+ anti_flood = 0;
+ anti_clone = 0;
+ ctcp_reply = 0;
+ cop_mode = 0;
+
src = buffer;
endsrc = buffer;
delay = socket_delay;