Results 1 to 16 of 16

Thread: IRC bot - By akwardsaw

  1. #1
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default IRC bot - By akwardsaw

    this is mah project that i'v been working on for the past few days, and i figure that its good enough for an "official" release,

    thanks too:
    Tootoot, i sorta based it off of his bot(and took the CRLF )
    Harry, and noidea for helping me

    the commands:
    .fact - generates a random fact
    .rape ;nick - rapes the nick with a random item
    .mball ;question - answers the question randomly, ;p
    .nick ;nick* - changes the bots nick
    .fun ;on/off* - turns fun mode on or off. when on the bot will message the channel, when off it will notice the user
    .changemaster ;master* - changes the new master
    .master - says the current master of the bot

    *only usable by the master

    how to set it up:

    SCAR Code:
    const
      nick = '';  //bots default nick
      realname = '';  //your name
      port = 6667;  //irc port
      server = ''; //the irc server
      timeout = 0; //leave
      Chan = '#'; //channel for the bot to join. remember the #
      master = ''; //the default master of the bot

    script:
    SCAR Code:
    program New;

    const
      nick = '';
      realname = '';
      port = 6667;
      server = '';
      timeout = 0;
      Chan = '';
      master = '';
     
      CRLF = #13#10; //dont touch, and thanks to Tootoot :D
     
    procedure A_Debug(msg: string);
    begin
      writeln(msg);
      alert(msg);
      status(msg);
      terminatescript;
    end;

    type
      TMessage = record
      mess, user, time : string;
      line : TStringArray;
    end;

    var
      c, p: integer;
      s, a : string;
      Curr_Master : String;
      TheMessage : TMessage;
      is_fun : boolean;

    function Connect: integer;
    begin
      p:= port;
      repeat
        result:= OpenConnection(server, p, timeout);
        if result < 0 then inc(p);
      until (port = 7000) or (c >= 0);
      if result < 0 then exit;
      writeln('Connection Open');
      writeln(' ');
      writeln('Server: ' + server);
      writeln('Port: ' + inttostr(port));
      writeln('Connection: ' + inttostr(c));
      writeln(' ');
    end;

    function setfun : string;
    begin
      if is_fun then result := 'PRIVMSG ' + chan else result := 'NOTICE ' + themessage.user;
    end;

    procedure setup;
    begin
      if (not SendConnectionData(c, 'USER ' + nick + ' * * :' + realname + CRLF) and
        SendConnectionData(c, 'NICK '+ nick + CRLF) and
           SendConnectionData(c, 'JOIN ' + Chan + CRLF)) then
        A_Debug('Joining messed up');
      writeln('Nick Set:' + nick);
      writeln('User Set: ' + realname);
      writeln('Joined Channel: ' + chan);
      writeln(' ');
      wait(1000);
    end;

    Function Contain(Stringz, Strings : String) : Boolean;
    Begin
      Result := Pos(Stringz, Strings) <> 0;
    End;

    function parse(messge : string) : string;

    begin
      with themessage do
      begin
        user := between(':', '!~', messge);
        mess := between('PRIVMSG', CRLF, messge);
        result := user + ': ' + mess;
      end;
    end;

    procedure ping;
    begin
      SendConnectionData(c, 'PONG ' + chan + CRLF);
    end;

    function GetFact: string;
    var a: string;
    begin
      a:= getpage('http://www.randomfunfacts.com/');
      result:= TrimEx('        ', between('<td bordercolor="#FFFFFF"><font face="Verdana" size="4"><strong><i>', '</i></strong></font>&nbsp;</td>', a));
    end;

    procedure changenick(mess : string);
    begin
      if not (themessage.user = Curr_Master) then exit;
      Themessage.line := explode(';', mess);
      if length(themessage.line) < 2 then exit;
      SendConnectionData(c, 'NICK '+ Themessage.line[1] + CRLF);
    end;

    procedure changemaster(mess : string);
    begin
      if not (themessage.user = Curr_Master) then exit;
      Themessage.line := explode(';', mess);
      if length(themessage.line) < 2 then exit;
      Curr_Master := themessage.line[1];
    end;

    procedure rape(mess : string);
    var
      arr : TStringArray;
    begin
      Arr := ['Cactus', 'Bat', 'Rake', 'Cat', themessage.user, 'Spoon', 'Knife', 'Spork',
              'AwkwardSaw'];
      themessage.line := explode(';', mess);
      if length(themessage.line) < 2 then exit;
      SendConnectionData(c, setfun + ' Akwardbot rapes ' + Themessage.line[1] + ' with a ' + arr[random(high(arr))] + CRLF);
    end;

    procedure magicball(mess : string);
    var
      arr : TStringArray;
    begin
      arr := ['Yes', 'No', 'Mabey', 'Dont hold your breath', 'Hell yeah!'];
      themessage.line := explode(';', mess);
      if length(themessage.line) < 2 then
        exit;
      SendConnectionData(c, setfun + ' The answer to: ' + themessage.line[1] + ' is: ' + arr[random(high(arr))] + CRLF);
    end;

    procedure fun(mess : string);
    begin
      if not (themessage.user = Curr_Master) then exit;
      Themessage.line := explode(';', mess);
      if length(themessage.line) < 2 then
      begin
        writeln(':(');
        exit;
      end;
      case lowercase(themessage.line[1]) of
        'off' : is_fun := false;
        'on' : is_fun := true;
      end;
      writeln(themessage.line[0] + ' - ' + themessage.line[1]);
      writeln(booltostr(is_fun));
    end;

    procedure respond(mess : string);
    begin
      if contain('.fact', lowercase(parse(mess))) then
        SendConnectionData(c, setfun + ' ' + getfact + CRLF);
      if contain('.nick', lowercase(parse(mess))) then
        changenick(lowercase(parse(mess)));
      if contain('.changemaster', lowercase(parse(mess))) then
        changemaster(lowercase(parse(mess)));
      if contain('.master', lowercase(parse(mess))) then
        SendConnectionData(c, setfun + ' my current master is: ' + curr_master + CRLF);
      if contain('.rape', lowercase(parse(mess))) then
        rape(parse(mess));
      if contain('.mball', lowercase(parse(mess))) then
        magicball(parse(mess));
      if contain('.fun', lowercase(parse(mess))) then
        fun(parse(mess));
    end;

    var
      t : integer;
    begin
      if Connect < 0 then A_Debug('Connection Problems');
      setup;
      Curr_Master := master;
      writeln('Master: ' + Curr_Master);
      is_fun := false;
      repeat
        t := GetSystemTime;
        repeat
          if not IsConnectionOpen(c) then A_Debug('Connection Closed');
          ReadConnectionData(c, s);
            if contain('PRIVMSG', s) then
              writeln(parse(s));
            respond(s);
            a:= s;
        until getsystemtime - t > 10000;
        ping;
     until false;
    end.

    note: i made this script for easy to edit/change > functionality(as long as it works )

    which means, you can easily make your own command if you want, and add it to the database if you know anything about scripting

    enjoy,
    Last edited by Awkwardsaw; 01-12-2010 at 01:36 PM.
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  2. #2
    Join Date
    Apr 2007
    Location
    Melbourne, Aus
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks! this is pretty sweet, gj man

  3. #3
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by IRC
    <NCDS> .mball;can I make an IRC bot?
    -DaBoss- The
    <NCDS> .mball ; can I make an IRC bot?
    -DaBoss- The
    lol

  4. #4
    Join Date
    Apr 2007
    Location
    Melbourne, Aus
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Cant get this to work, it comes up with:
    Code:
    Successfully compiled (110 ms)
    Connection Open
     
    Server: irc.rizon.net
    Port: 6667
    Connection: 0
     
    Nick Set: *NAME*
    User Set: *NAME*
    Joined Channel: SRL
     
    Master: jimmy_mac
    Connection Closed
    Successfully executed

  5. #5
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by jimmy_mac View Post
    Cant get this to work, it comes up with:
    Code:
    Successfully compiled (110 ms)
    Connection Open
     
    Server: irc.rizon.net
    Port: 6667
    Connection: 0
     
    Nick Set: *NAME*
    User Set: *NAME*
    Joined Channel: SRL
     
    Master: jimmy_mac
    Connection Closed
    Successfully executed
    Do you allow the script to connect?

  6. #6
    Join Date
    Apr 2007
    Location
    Melbourne, Aus
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yep i did

  7. #7
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Sweet job dude, this is really cool. I believe YakMan also made one of these before too!

  8. #8
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by jimmy_mac View Post
    yep i did
    is "SRL" the channel you wanted to join?
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  9. #9
    Join Date
    Apr 2007
    Location
    Melbourne, Aus
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Awkwardsaw View Post
    is "SRL" the channel you wanted to join?
    I tried it with this aswell: "#SRL" still didnt work.

  10. #10
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by jimmy_mac View Post
    I tried it with this aswell: "#SRL" still didnt work.
    to join #srl, you must be registered + identified(unless they changed it recently)
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  11. #11
    Join Date
    Apr 2007
    Location
    Melbourne, Aus
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    am registered, and i'm identified. i tried it with my original username aswell.. still not working unfortunately.

  12. #12
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by jimmy_mac View Post
    am registered, and i'm identified. i tried it with my original username aswell.. still not working unfortunately.
    post the part in the script that identifies your nick then pl0x,
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  13. #13
    Join Date
    Apr 2007
    Location
    Melbourne, Aus
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Code:
    procedure setup;
    begin
      SendConnectionData(c, '/ns identify *MY PASSWORD*');
      wait(300);
      if (not SendConnectionData(c, 'USER ' + nick + ' * * :' + realname + CRLF) and
        SendConnectionData(c, 'NICK '+ nick + CRLF) and

  14. #14
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by jimmy_mac View Post
    Code:
    procedure setup;
    begin
      SendConnectionData(c, '/ns identify *MY PASSWORD*');
      wait(300);
      if (not SendConnectionData(c, 'USER ' + nick + ' * * :' + realname + CRLF) and
        SendConnectionData(c, 'NICK '+ nick + CRLF) and
    change that to

    SCAR Code:
    procedure setup;
    begin
      wait(300);
      if SendConnectionData(c, 'USER ' + nick + ' * * :' + realname + CRLF) and
        SendConnectionData(c, 'NICK '+ nick + CRLF) and
      SendConnectionData(c, 'identify *MY PASSWORD*' + CRLF) and
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  15. #15
    Join Date
    Apr 2007
    Location
    Melbourne, Aus
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    After changing that it still doesnt connect but i get this now, sorry for the hassle mate:
    Code:
    Successfully compiled (91 ms)
    Connection Open
     
    Server: irc.rizon.net
    Port: 6667
    Connection: 0
     
    Nick Set:AnOldMan
    User Set: An Old Man
    Joined Channel: #SRL
     
    Master: jimmy_mac
    : :4,WHOIS:1 CHANTYPES=# :are supported by this server
    irc.nuu.cc 372 AnOldMan :-  o Want a vhost? /msg hostserv help request
    :irc.nuu.cc 372 AnOldMan :- 
    :irc.nuu.cc 372 AnOldMan :- _______ Open Proxy's & Transit Provider ______________________________
    :irc.nuu.cc 372 AnOldMan :- 
    :irc.nuu.cc 372 AnOldMan :-  o The use of this server & network is a privilege, not a right.
    :irc.nuu.cc 372 AnOldMan :- 
    :irc.nuu.cc 372 AnOldMan :-  o IRC is a free media, therefore no person or entity involved
    :irc.nuu.cc 372 AnOldMan :-  o with *.rizon.net and irc.nuu.cc takes any responsibility
    :irc.nuu.cc 372 AnOldMan :-  o whatsoever for the opinions expressed or the actions taken by
    :irc.nuu.cc 372 AnOldMan :-  o users. Absolutely no warranty is either expressed or implied.
    :irc.nuu.cc 376 AnOldMan :End of /MOTD command.
    :AnOldMan:  AnOldMan :VERSION

  16. #16
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    idk,

    try it on a private chan, where you dont need identifying
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •