Changeset 416:919e547ea0c9

Show
Ignore:
Timestamp:
06/21/2010 05:12:02 PM (20 months ago)
Author:
Sidgyck <sidgyck@…>
Branch:
default
Message:

[NEW]: "!misc decide [choice 1] [choice 2] ... [choice n]" make a decision for you

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/plugins/misc/miscplugin.cpp

    r392 r416  
    1212        BasePlugin(parent) 
    1313{ 
    14         commands << "TEST" << "DATE" << "TIME" << "SAY"; 
     14        commands << "TEST" << "DATE" << "TIME" << "SAY" << "DECIDE"; 
    1515 
    1616        sayJidDisabled_=DataStorage::instance()->getInt("cmd/disable_misc_sayjid"); 
     
    7878                return true; 
    7979        } 
     80        if (cmd=="DECIDE") 
     81        { 
     82                QStringList choices = parser.getTokens(); 
     83                if (choices.count() <= 3) 
     84                { 
     85                        reply(s, "You have no choice."); 
     86                        return true; 
     87                } 
     88                srand( time(NULL) ); 
     89                int r = random() % (choices.count()-2); // strip misc and decide tokens 
     90                reply(s, choices[r+2]); 
     91                return true; 
     92        } 
    8093        return false; 
    8194}