From 65a4a649a6798f7e922b0a32de690260c83e0451 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 4 Aug 2010 21:48:47 +0100 Subject: To address bugs #77 and #661, add some code that should avoid triggering infinite loops between keyboard and chair. --- root_commands.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'root_commands.c') diff --git a/root_commands.c b/root_commands.c index fe445d26..6bd953fc 100644 --- a/root_commands.c +++ b/root_commands.c @@ -916,6 +916,35 @@ static void cmd_yesno( irc_t *irc, char **cmd ) if( irc->queries == NULL ) { + /* Alright, alright, let's add a tiny easter egg here. */ + static irc_t *last_irc = NULL; + static time_t last_time = 0; + static int times = 0; + static const char *msg[] = { + "Oh yeah, that's right.", + "Alright, alright. Now go back to work.", + "Buuuuuuuuuuuuuuuurp... Excuse me!", + "Yes?", + "No?", + }; + + if( last_irc == irc && time( NULL ) - last_time < 15 ) + { + if( ( ++times >= 3 ) ) + { + irc_usermsg( irc, "%s", msg[rand()%(sizeof(msg)/sizeof(char*))] ); + last_irc = NULL; + times = 0; + return; + } + } + else + { + last_time = time( NULL ); + last_irc = irc; + times = 0; + } + irc_usermsg( irc, "Did I ask you something?" ); return; } -- cgit v1.2.3