Content-Type: text/plain;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I have been working on an IRC Bot script.  Currently its rather powerful =
but has along way to go and needs alot of cleanup work done.  Anyway I =
thought I would include it as it may benefit others.  You should copy =
all the files to the same directory.  I have more work to do on the bot =
commands and the connect function as well as dcc file send operations.

Paul Tretter
EFNET #rebol






-- Attached file included as plaintext by Listar --
-- File: irc48.r

REBOL [
    Title: "REBBOT"
    Comment: {Still to do:  botnet features.
         - channel routing of bot output
         - add support for MSN protocol
         - add console view function to botcommands
         - create timeout to handle dcc connection or other port connections
         - need flood control for the dcc sessions and channel management.
         - change the partyline to advertise to everyone partings.
         - add channel limit controls
         - add directory support
         - add ctcp commands support
         - add support for ident
         - add ison support with nick stealer
         - add link looker
         - add partyline kicking
         - create channel triggers and channel actions based on parsed data
         - create connect routine for specified server.
    }
    version: "REBBOT 1.45 - Copyright 2001 by VeiN"
]
secure [file [allow write]]
irc-input-buffer: make string! 0
dcc-input-buffer: make string! 0
bot-channels: []
server-list: load %servers.txt
dcc-chat-flag: help-flag: message-flag: limit-flag: off
masters: make block! 0
trusted: make block! 0
whoisports: make block! 0
party-line: make block! 0
chan-flood-flag: off
chan-flood-list: make list! 0
protected: make block! 0
auto-op: make block! 0
dcc-open-client: banmask-flag: banhost-flag: none
secured: false
start: now/time
message-flag: off
recycle/on
dec2tuple: func [long] [
        to-tuple reduce [
                to-integer long / 16777216
                to-integer long / 65536 // 256
                to-integer long / 256 // 256
                to-integer long // 256
        ]
]

error-proc: func [errormsg] [
    write/append %error.log reduce [now newline probe errormsg/id newline 
errormsg/arg1 newline newline]
]

interface: does [
    create-defaults: false
    config-query: Confirm "Would you like to load defaults? (Y or N) "
    either config-query [
        defaults: load %defaults.txt
        botname: defaults/1
        altbotname: defaults/2
        botpassword: defaults/3
        joinchannel: defaults/4
        dversion: defaults/5
        logging: defaults/6
    ][
        botname: ask "Enter a name for the bot -> "
        altbotname: ask "Enter an alternate name for the bot -> "
        botpassword: ask "Enter password for bot -> "
        joinchannel: ask "Enter initial channel for bot -> "
        dversion: ask "Enter the default version reply for ctcp responses -> "
        logging: Confirm "Would you like logging turned on? (Y or N) "
        create-defaults: Confirm "Would you like to save these settings as default 
values? (Y or N) "
    ]
    if create-defaults [
        save %defaults.txt reduce [botname altbotname botpassword joinchannel dversion 
logging]
    ]
    
]

connect: does [
    system/schemes/default/timeout: 30
    forever [foreach server server-list [
            idents: open/direct/lines tcp://:113
            ident-flag: on
            print ["Connecting to " server]
            irc-port: [
                scheme: 'tcp
                host: to-string server
                port-id: 6667
            ]
            ircserv: to-string server
            either error? connect-error: try [irc-open-port: open/lines/direct/no-wait 
irc-port][
                connect-error: disarm connect-error
                error-proc connect-error
                Print "Error Generated at CONNECT Function!"
            ][
                system/schemes/default/timeout: 120
                handshake
                exit
           ]
         ]
         if tail? server-list [server-list: head server-list]
         connect
    
    ]
]

handshake:  does [
    insert irc-open-port rejoin ["NICK " botname]
    insert irc-open-port "USER reb rebol.dyndns.org ircserv reb^/"
    insert irc-open-port rejoin ["JOIN " joinchannel]
    insert bot-channels joinchannel
]

getirc-port-data: does [
    either error? getirc-port-data-error: try [irc-input-buffer: copy/part 
irc-open-port 1] [
        getirc-port-data-error: disarm getirc-port-data-error
        error-proc getirc-port-data-error
        Print "Error Generated at GETIRC-PORT-DATA function!"
        
    ][
        if type? irc-input-buffer = block! [irc-input-buffer: to-string 
irc-input-buffer]
        if not tail? irc-input-buffer [
            ircparser
            print irc-input-buffer
            pong
            ; notice-parser
            protector
            auto-op-func
            privmsg-parser
            whois-parser
        ]
    ]
]

ircparser: does [
    if find/part irc-input-buffer ":" 1 [irc-input-buffer: remove head 
irc-input-buffer]
    parse-all-irc-input-buffer: parse/all copy irc-input-buffer ""
    parse-irc-input-buffer: parse irc-input-buffer ""
    modecmd: parse-irc-input-buffer/2
    direction: parse-irc-input-buffer/3
    type-incoming: parse-irc-input-buffer/1
    if type-incoming = ircserv [
           server-incoming: make object! [
            server: type-incoming/1
            servcode: parse-irc-input-buffer/2
            servmsg: if found? find copy irc-input-buffer ":" [
                return find copy irc-input-buffer ":" 
            ]
        ]
    ]
    if type-incoming = "error" [
        close irc-open-port
        server-list: next server-list connect
    ] 
    
    if type-incoming = ircserv [if server-incoming/servcode = "433" [botname: 
altbotname handshake]]
    if not none? type-incoming [
        if find type-incoming "!" [
            header: parse copy irc-input-buffer "!@"
            message-flag: on
            message: make object! [
            nick: header/1
            username: header/2
            host: header/3
            mask: remove/part copy host ((length? first parse/all copy host ".") + 1)
            data: if find irc-input-buffer ":" [
                    either not empty? find/tail irc-input-buffer ":" [
                        data: second parse/all copy irc-input-buffer ":"
                    ][
                        data: none
                    ]
                  ]      
            dataparse: if data [dataparse: parse data ""]
            ]
        
        ]
    ]
]


irc-port-send: func [block][  
    append irc-open-port rejoin block
]


protector: does [
    if all [message-flag not empty? protected][
        if message/nick <> botname [
            protected: head protected
            if all [modecmd = "KICK"][
                foreach item protected [if found? parse parse-irc-input-buffer/4 item [
                    irc-port-send ["MODE " parse-irc-input-buffer/3 " +b " 
message/nick]
                    irc-port-send ["Kick " parse-irc-input-buffer/3 " " message/nick]]
                ]
            ]
            if all [modecmd = "MODE" parse-irc-input-buffer/4 = "-o"][
                foreach item protected [if found? parse parse-irc-input-buffer/5 item [
                    irc-port-send ["MODE " parse-irc-input-buffer/3 " +b " 
message/nick]
                    irc-port-send ["Kick " parse-irc-input-buffer/3 " " message/nick]
                    irc-port-send ["MODE " parse-irc-input-buffer/3 " +o " 
parse-irc-input-buffer/5]]
                ]
            ]
            if all [modecmd = "MODE" parse-irc-input-buffer/4 = "+b"][
                foreach item protected [if found? parse parse-irc-input-buffer/5 item [
                    irc-port-send ["MODE " parse-irc-input-buffer/3 " +b " 
message/nick]
                    irc-port-send ["Kick " parse-irc-input-buffer/3 " " message/nick]
                    irc-port-send ["MODE " parse-irc-input-buffer/3 " -b " 
parse-irc-input-buffer/5]]
                ]
            ]
        ]
    ]
]
        
auto-op-func: does [
    auto-op: head auto-op
    if all [not empty? auto-op modecmd = "join"][
        foreach item auto-op [if found? find auto-op message/nick [
            irc-port-send ["MODE " (remove pick parse-irc-input-buffer 3) " +o " 
message/nick]]
        ]
    ]
]

    

notice-parser: does [
    if secured [
        if all [modecmd = "notice" type-incoming <> ircserv][
            if all [message/dataparse/1 = "DCC" message/dataparse/2 = "chat"][
                dcc-ip: copy message/dataparse/3
                remove head dcc-ip
                remove back tail dcc-ip
                    dcc-chat-flag: on
            ]
        ]
    ]    
]

secured: does [
    ; this function verify's whether a nick is a master and is passed to other 
functions/commands
    masters: head masters
    trusted: head trusted
    if message-flag [
        if message/nick = botname [return true]    
        if found? find masters message/nick [
            position: index? find masters message/nick
            either message/host = first at trusted position [
                return true
            ][
                remove find masters message/nick
                print ["removing " message/nick " from Masters list"] 
                remove first at trusted position
                return false
            ]
        ]
        if found? find trusted message/host [
            position: index? find trusted message/host
            either message/nick = first at masters position [
                return true
            ][
                remove find trusted message/host
                print ["removing " message/host " from Trusted list"]
                remove at masters position
                return false
            ]
        ]
    ]
    
]

dcc-port-send: func [block][insert bot-port-send rejoin block]

dcc-parser: does [
    if secured [
        if dcc-chat-flag [
            dcc-client-port: message/dataparse/5
            if value? to-word message/nick [
                if found? find waitports get to-word message/nick [
                    remove find waitports get to-word message/nick    
                    close get to-word message/nick
                ]
            ]
            if all[not none? dcc-client-port not none? dcc-ip][
                dcc-connect: [
                    scheme: 'tcp
                    host: dcc-ip
                    port-id: to-integer dcc-client-port
                    user-data: message/nick
                ]
            ]
            
            either error? error-dcc-open-client: try [dcc-open-client: 
open/lines/direct/no-wait dcc-connect][
                error-dcc-open-client: disarm error-dcc-open-client
                error-proc error-dcc-open-client
                Print "Error Generated at DCC-PARSER Function!"
            ][
                insert dcc-open-client read %help.txt
                dcctemp: make set-word! message/nick
                mold dcctemp :dcc-open-client
                append waitports get make word! message/nick
            ] 
            dcc-chat-flag: off
            dcc-client-port: none
            dcc-connect: none
            dcc-open-client: none
            
        ]
    ]
]



bot-commands: does [
    whoisports: head whoisports
    party-line: head party-line
    either error? error-bot-incoming: try [bot-incoming: parse dcc-input-buffer ""][
        error-bot-incoming: disarm error-bot-incoming
        error-proc error-bot-incoming
        Print "Error Generated at BOT-COMMANDS Function!"
    ][
        bot-parse-incoming: parse/all dcc-input-buffer " "
        if bot-incoming/1 = ".ban" [irc-port-send ["MODE " bot-incoming/3 " +b " 
bot-incoming/2]]
        if bot-incoming/1 = ".unban" [irc-port-send ["MODE " bot-incoming/3 " -b " 
bot-incoming/2]]
        if bot-incoming/1 = ".banhost" [irc-port-send ["WHOIS " bot-incoming/2]
            banhost-flag: bot-incoming/2
            banhost-channel: bot-incoming/3
            
        ]
        if bot-incoming/1 = ".banmask" [irc-port-send ["WHOIS " bot-incoming/2]
            banmask-flag: bot-incoming/2
            banmask-channel: bot-incoming/3
        ]
            
        if bot-incoming/1 = ".kick" [irc-port-send ["kick " bot-incoming/3 " " 
bot-incoming/2]]
        if bot-incoming/1 = ".uptime" [dcc-port-send [now/time - start]]
        if bot-incoming/1 = ".shutdown" [
            waitports: next head waitports
            irc-port-send ["quit"] 
            close irc-open-port
            foreach port waitports [close port]
            halt
            
        ]
        
        if bot-incoming/1 = ".lock" [irc-port-send ["MODE " bot-incoming/2 " +i "]]
        if bot-incoming/1 = ".unlock" [irc-port-send ["MODE " bot-incoming/2 " -i"]]
        if bot-incoming/1 = ".topic" [irc-port-send ["TOPIC " bot-incoming/2 " :" 
reform at bot-incoming 3]]
        if bot-incoming/1 = ".secret" [irc-port-send ["MODE " bot-incoming/2 " +s"]]
        if bot-incoming/1 = ".nosecret" [irc-port-send ["MODE " bot-incoming/2 " -s"]]
        if bot-incoming/1 = ".invite" [irc-port-send ["INVITE " bot-incoming/2 " " 
bot-incoming/3]]
        if bot-incoming/1 = ".time" [dcc-port-send [now/time]]
        if bot-incoming/1 = ".date" [dcc-port-send [now/date]]
        if all [bot-incoming/1 = ".unregister" bot-incoming/2 <> none][unregister 
bot-incoming/2]
        if bot-incoming/1 = ".op" [irc-port-send ["MODE " bot-incoming/3 " +o " 
bot-incoming/2]]
        if bot-incoming/1 = ".deop" [irc-port-send ["MODE " bot-incoming/3 " -o " 
bot-incoming/2]]
        if bot-incoming/1 = ".voice" [irc-port-send ["MODE " bot-incoming/3 " +v " 
bot-incoming/2]]
        if bot-incoming/1 = ".unvoice" [irc-port-send ["MODE " bot-incoming/3 " -v " 
bot-incoming/2]]
        if bot-incoming/1 = ".join" [irc-port-send ["join " bot-incoming/2 " " 
bot-incoming/3]
            insert bot-channels bot-incoming/2
        ]
        if all [bot-incoming/1 = ".part" not none? bot-incoming/2][irc-port-send 
["part " bot-incoming/2]
            bot-channels: head bot-channels
            if error? part-error: try [remove find bot-channels bot-incoming/2][
                part-error: disarm part-error
                dcc-port-send [bot-incoming/2 " is not in channels distribution"]
            ]
        ]
        if bot-incoming/1 = ".masters" [dcc-port-send [masters]]
        if bot-incoming/1 = ".trusted" [dcc-port-send [trusted]]
        if bot-incoming/1 = ".say" [irc-port-send ["PRIVMSG " bot-incoming/2 " :" (at 
bot-parse-incoming 3)]]
        if bot-incoming/1 = ".list" [dcc-port-send [bot-channels]]
        if bot-incoming/1 = ".help" [dcc-port-send [read %help.txt]]
        if bot-incoming/1 = ".change-nick" [irc-port-send ["NICK " bot-incoming/2]]
        if bot-incoming/1 = ".key" [irc-port-send ["MODE " bot-incoming/2 " +k " 
bot-incoming/3]]
        if bot-incoming/1 = ".unkey" [irc-port-send ["MODE " bot-incoming/2 " -k " 
bot-incoming/3]]
        if bot-incoming/1 = ".change-password" [
            botpassword: bot-incoming/2
            dcc-port-send ["The BOT password has been changed to: " botpassword]
        ]
        if bot-incoming/1 = ".send" [irc-port-send [(at bot-parse-incoming 2)]] 
        if bot-incoming/1 = ".comments" [dcc-port-send [system/script/header/comment]]
        if bot-incoming/1 = ".ver" [dcc-port-send [system/script/header/version]]
        if all [bot-incoming/1 = ".partyline" bot-incoming/2 = "on"][
            either find party-line get to-word bot-port-send/user-data [dcc-port-send 
["you are already on the party line!"]
            ][
                append party-line bot-port-send
                party-line head party-line
                foreach port party-line [
                    append port rejoin [bot-port-send/user-data " is now on the 
partyline!"]
                ]
            ]
        ]
        if all [bot-incoming/1 = ".partyline" bot-incoming/2 = "off"][ 
            party-line: head party-line
            while [not tail? party-line][
                partyindex: first party-line
                if partyindex/user-data = bot-port-send/user-data [
                    remove party-line
                    dcc-port-send [bot-port-send/user-data ", you have PARTED the 
partyline!"]
                ]
                if not tail? party-line [party-line: next party-line]
               
            ]
        ]
        if all [bot-incoming/1 = ".partyline" bot-incoming/2 = "info"][
            party-line: head party-line
            either empty? party-line [
                dcc-port-send ["No one is currently on the Partyline!"]
            ][
                foreach item party-line [dcc-port-send [item/user-data " is currently 
on the Partyline!"]]
            ]
        ]
        if bot-incoming/1 = ".status" [
            foreach port waitports-active [dcc-port-send [port/user-data ", is 
currently in dcc session."]]
        ]
        if bot-incoming/1 = ".debug" [
            dcc-port-send ["The value of " bot-incoming/2 " is " if value? get make 
word! bot-incoming/2 [get make word! bot-incoming/2]]
                         
        ]
        if bot-incoming/1 = ".whois" [irc-port-send ["whois " bot-incoming/2]
            append whoisports bot-port-send
        ]
        if bot-incoming/1 = ".dir" [dcc-port-send [read %.]]
        if bot-incoming/1 = ".protect" [append protected bot-incoming/2
            dcc-port-send [bot-incoming/2 ", has been added to the protected list"]
        ]
        if bot-incoming/1 = ".vprotect" [dcc-port-send [head protected]]
       
        
        if all [bot-incoming/1 = ".rprotect" not none? bot-incoming/2 ][
            protected: head protected
            if found? find protected bot-incoming/2 [
                remove find protected bot-incoming/2
                dcc-port-send [bot-incoming/2 " was removed from the protected!"]
            ]
        ]
        if bot-incoming/1 = ".auto-op" [append auto-op bot-incoming/2
            dcc-port-send [bot-incoming/2 ", has been added to the auto-op list!"]
        ]
        if all [bot-incoming/1 = ".rauto-op" not none? bot-incoming/2][auto-op: head 
auto-op
            remove find auto-op bot-incoming/2
            dcc-port-send [bot-incoming/2 ", has been removed from the auto operators 
list."]
        ]
        if bot-incoming/1 = ".lauto-op" [dcc-port-send [auto-op]]
        if bot-incoming/1 = ".error-log" [dcc-port-send [read %error.log]]
        if bot-incoming/1 = ".close" [
            either all [not none? bot-incoming/2 value? to-word bot-incoming/2][
                Print ["CLOSING DCC SESSION OF - " bot-incoming/2]
                remove find head waitports get to-word bot-incoming/2
                remove find head party-line get to-word bot-incoming/2
                close get to-word bot-incoming/2
                unset to-word bot-incoming/2
            ][
                dcc-port-send ["UNABLE TO PROCESS REQUEST - Either the user doesnt 
have a DCC" newline
                    "port open or you mispelled the users name.  Use the .STATUS 
command to" newline
                    "verify port usage."
                ]
            ]
        ]
        
        if bot-incoming/1 = ".cycle" [close irc-open-port server-list: next 
server-list connect
            foreach port waitports-active [
                append port rejoin [botname ", is now reconnecting to Internet Relay 
Chat Network"]
            ]
            waitports-active: head waitports-active
        ]
              
        if bot-incoming/1 = ".p" [dcc-port-send [read %protection.txt]]
        if bot-incoming/1 = ".b" [dcc-port-send [read %manage.txt]]
        if all [bot-incoming/1 = ".call" not none? bot-incoming/2 value? to-word 
bot-incoming/2][
             append get to-word bot-incoming/2 reform [at bot-incoming 3]
        ]
        if all [bot-incoming/1 = ".fchan" bot-incoming/2 = "on" not error? to-integer 
bot-incoming/3 not error? to-time to-integer bot-incoming/4][
            print [true]
            chan-flood-flag: true
            chan-lines: to-integer bot-incoming/3
            chan-watch: to-time to-integer bot-incoming/4
             
        ]
        if all [bot-incoming/1 = ".fchan" bot-incoming/2 = "off"][
            chan-flood-flag: false
            dcc-port-send ["Channel Flood Protection is now DISABLED."]
        ]
        if bot-incoming/1 = ".test" [irc-port-send ["PRIVMSG ARTERY :" 
to-char(1)"VERSION"to-char(1)]]
        if all[bot-incoming/1 = ".sversion" not none? bot-incoming/2][
            dversion: at bot-incoming 2
            dcc-port-send ["The ctcp version response has now been set to: " at 
bot-incoming 2]
        ]
        if bot-incoming/1 = ".dversion" [
            dversion: defaults/5
            dcc-port-send ["The default ctcp version response has now been set to: " 
defaults/5]
        ]
        if all [bot-incoming/1 = ".limit" not none? bot-incoming/2 not error? 
limit-interval: try [to-integer bot-incoming/3]][
            limit-flag: on
            limitcount: 0
            limitchan: bot-incoming/2
            irc-port-send ["NAMES " bot-incoming/2]
        ]
            
            
        
        
            
    ]
]

flag-processor: does [
    if limit-flag [
        if modecmd = "353" [limitcount: length? (find/tail parse-irc-input-buffer 
limitchan)]
        if modecmd = "366" [irc-port-send ["MODE " limitchan " +l " (limitcount + 
limit-interval)]]
    ]
    
    
    
    if all [chan-flood-flag message-flag][
        if not empty? chan-flood-list [
            foreach item chan-flood-list [
                access-nick: copy item
                access-nick/qtime: now/time - access-nick/ctime
                if access-nick/qtime > access-nick/ctime + chan-watch [remove item]
            ]
        chan-flood-list: head chan-flood-list
        ]
        access-nick: join "&" message/nick
        either not value? to-word :access-nick [
            chantemp: make set-word! access-nick
            chantempobj: make object! [
                nick: message/nick
                ctime: now/time
                lines: 1 ; the number of lines entered in the channels since queued
                qtime: 0 ; time in queue
            ]
            append chan-flood-list (mold chantemp :chantempobj)
        ][
            access-nick: get to-word join "&" message/nick 
            Print "pass1"
            either access-nick/lines > chan-lines [
                irc-port-send ["KICK " direction " " message/nick " :Flooding will not 
be Tolerated!"]
                
            ][
                access-nick/lines: access-nick/lines + 1
                
            ]
        ] 
        
    ]
 
]
            

ctcp-parser: does [ 
    if find irc-input-buffer rejoin ["PRIVMSG " botname " :" 
to-char(1)"VERSION"to-char(1)][
        irc-port-send ["NOTICE " message/nick " :" to-char(1)"VERSION " dversion 
to-char(1)]
    ]
    if find/any irc-input-buffer rejoin ["PRIVMSG " botname " :" to-char(1)"PING " "*" 
to-char(1)][
        irc-port-send ["NOTICE " message/nick " :" to-char(1) "PING " 
message/dataparse/2 to-char(1)]
    ]
]


unregister: func [unreg-nick][
    if not none? unreg-nick [
        masters: head masters
        trusted: head trusted
        either error? unreg-error: try [pos: index? find masters unreg-nick][
            disarm unreg-error
        ][
            remove masters pos
            remove trusted pos
            dcc-port-send [unreg-nick " has been removed from the MASTERS LIST"]
        ]
    ]
]

getdcc-port-data: does [
    waitports: head waitports
    if (length? waitports) > 1 [
        waitports-active: next head copy waitports
        foreach dccport-item waitports-active [
            bot-port-send: :dccport-item
            either error? error-dcc-input-buffer: try [dcc-input-buffer: copy/part 
dccport-item 1] [
                error-dcc-input-buffer: disarm error-dcc-input-buffer
                error-proc error-dcc-input-buffer
                Print "Error Generated at GETDCC-PORT-DATA Function!"                  
           
            ][
                if type? dcc-input-buffer = block! [dcc-input-buffer: to-string 
dcc-input-buffer] 
                if find dcc-input-buffer "none" [
                    remove find waitports get to-word bot-port-send/user-data
                    remove find waitports-active get to-word bot-port-send/user-data
                    if find party-line get to-word bot-port-send/user-data [
                        remove find party-line get to-word bot-port-send/user-data
                    ]
                ]
                if (length? dcc-input-buffer) > 0 [print [bot-port-send/user-data " - 
DCC - "dcc-input-buffer]]
                bot-commands
                party-line: head party-line
                if all [dcc-input-buffer/1 <> #"." found? find party-line 
bot-port-send dcc-input-buffer <> ""][        
                    while [not tail? party-line][fetchnick: first party-line
                        if fetchnick/user-data = bot-port-send/user-data [party-line: 
next party-line]
                        if not tail? party-line [append first party-line rejoin 
[bot-port-send/user-data "--> " dcc-input-buffer]]
                        party-line: next party-line
                    ]
                ]
             ]
         ]   
     ]
]
 

chat-parser: does [
    if secured [
        if type-incoming <> ircserv [
            if all [message/dataparse/1 = "DCC" message/dataparse/2 = "chat" 
message/dataparse/3 = "chat"][
                if not none? message/dataparse/4 [dcc-ip: copy message/dataparse/4]
                if parse dcc-ip [integer!] [
                    dcc-ip: dec2tuple load dcc-ip
                    dcc-chat-flag: on
                ]
            ]
        ]
    ]    
]    

whois-parser: does [
    if all [banhost-flag = parse-irc-input-buffer/4 modecmd = "311" ][
        irc-port-send ["MODE " banhost-channel " +b *!*@" parse-irc-input-buffer/6]
        banhost-flag: none
    ]
    if all [banmask-flag = parse-irc-input-buffer/4 modecmd = "311" ][
        banmask: find/tail parse-irc-input-buffer/6 "."
        irc-port-send ["MODE " banmask-channel " +b *!*@*." banmask]
        banmask-flag: none
    ]
    
    whoisports: head whoisports
    if (length? whoisports) > 0 [
        whois-send-port: first whoisports
        if not none? any [
            find modecmd "311"
            find modecmd "319"
            find modecmd "312"
            find modecmd "318"
            ][
            whoisdata: reform at parse-irc-input-buffer 4
            append whois-send-port whoisdata
            if modecmd = "318" [remove whoisports]
            
        ]
    ]
]
        

privmsg-parser: does [
    if modecmd = "PRIVMSG" [
        master-parser
        chat-parser
        dcc-parser
        
    ]
]

pong: does [
    if type-incoming = "PING" [
        irc-port-send ["PONG " ircserv]
        print ["Sending PONG to " ircserv]
    ]
    ; this command must be evaluated after the ircparser function
]

master-parser: does [
    if message-flag [        
        if all [message/dataparse/1 = "register" message/dataparse/2 = botpassword 
direction = botname][
            masters: head masters
            trusted: head trusted   
            either not found? find masters message/nick [
                append masters message/nick 
                append trusted message/host
                irc-port-send ["PRIVMSG " message/nick " :Greetings " message/nick " 
you have been added to the masters list."]
            ][
                irc-port-send ["PRIVMSG " message/nick " :You are already registered."]
           ]           
        ]
    ]
]


; --------------------------------- Start Evaluation 
------------------------------------

interface
connect
waitports: [irc-open-port idents]
while [true][
     
    if error? error-wait: try [waiting-port: wait waitports][
        connect
        error-wait: disarm error-wait
        error-proc error-wait
        Print "Error Generated DURING EVENT LOOP WHILE WAITING ON PORT DATA!"
    ]
        
    either all [ident-flag same? :waiting-port :idents] [
        ident-connection: first idents
        ident-buffer: first ident-connection
        if find/any reform ident-buffer "* , *" [
            insert ident-connection rejoin [ident-buffer " : USERID : UNIX : REBOL"]
        ]
        remove find head waitports 'idents
        close ident-connection
        
                
                
    ] [
        getirc-port-data
        getdcc-port-data
        flag-processor
        ctcp-parser
        message-flag: off
    ]
    
]
halt        



-- Attached file included as plaintext by Listar --
-- File: help.txt

version 1.45

             ######  ####### ######  ######  ####### #######
             #     # #       #     # #     # #     #    #
             #     # #       #     # #     # #     #    #
             ######  #####   ######  ######  #     #    #
             #   #   #       #     # #     # #     #    #
             #    #  #       #     # #     # #     #    #
             #     # ####### ######  ######  #######    #



   This REBOL script was created by VeiN #rebol efnet Copyright 2001
   REBBOT requires a REBOL interpreter which can be found at www.rebol.com
   Special thanks to Kinners n0p3x and frontline

   Note: the Main Help Menu contains submenus to other commands.   
   

****************************** MAIN HELP MENU ****************************

 .ban/unban (nick)(#channel)    - to ban or unban user
 .banhost (nick)(#channel)      - to ban a users hostmask
 .banmask (nick)(#channel)      - to ban a users mask
 .kick (nick)(#channel)         - to kick user
 .join (#channel) (key)         - to join bot to channel
 .part (#channel)               - to part bot from channel
 .op/deop (nick) (#channel)     - to op or deop someone
 .unregister                    - unregister nick with bot
 .unkey/key #channel code       - to set/remove channel key
 .say (#channel/nick) msg       - say a message to a channel or nick
 .voice/unvoice nick #channel   - to voice or unvoice a user
 .send commands                 - to send any irc commands enclose the command in ""
 .whois nick                    - to query user data
 .lock/unlock (#channel)        - to make a channel invite only
 .secret/nosecret (#channel)    - to make a channel secret 
 .invite (nick)(#channel)       - to invite a user to a channel
 .topic (#channel)(msg)         - to set the topic on a channel
 .noopsmsg/opsmsg #channel      - to change the topic flag
 .noext/ext #channel            - to allow/disallow external msgs
 .time                          - to display current time
 .date                          - to display current date
 .partyline on/off              - to join/part the partyline
 .partyline info                - to show whos on the partyline
 .status                        - to display dcc session status
 .call (nick)(msg)              - to send a message to a dcc session user
 .away                          - to set an away message for the bot
 .auto-op (nick)                - to auto-op a user on join  
 .rauto-op (nick)               - to remove a user from auto op list
 .lauto-op                      - to list user on the auto op list
 .close (nick)                  - to close a dcc session/port
 .dir                           - to list contains of current directory
 .b                             - to display BOT MANAGER MENU
 .p                             - to display PROTECTION MENU
 .help                          - to display this help menu
 
********************************  End Help ***********************************
-- Attached file included as plaintext by Listar --
-- File: manage.txt

****************************** BOT MANAGER MENU ******************************

 .change-nick (nick)            - to change bot nickname
 .change-password (pwd)         - to change registration password
 .shutdown                      - quits bot and closes open ports
 .masters                       - to display a list of masters
 .trusted                       - to display trusted hostmasks
 .comments                      - to list internal script comments
 .ver                           - to list bot version
 .cycle                         - to force bot to reconnect to IRC network
 .uptime                        - to get bot uptime
 .error-log                     - to display error log file
 .sversion (string)             - to set the ctcp version response
 .dversion                      - to set the ctcp version response to defaults
 .bot                           - to display this menu

********************************** END ***************************************
-- Attached file included as plaintext by Listar --
-- File: protection.txt

******************************* PROTECTION MENU ******************************

 .protect (nick)                - to protect users in the channel from ban kick or deop
 .vprotect                      - to view protected users
 .rprotect (nick)               - to remove a user from protected
 .fchan on (lines)(seconds)     - to enable channel flood protection
 .fchan off                     - to shut off channel flood protection

*********************************** END **************************************
-- Attached file included as plaintext by Listar --
-- File: servers.txt

;irc.emory.edu
irc.east.gblx.net
irc.core.com
irc.west.gblx.net
irc.mindspring.com
irc.mcs.com
irc.mcs.net
irc.prison.net
irc.light.se
irc.exodus.net
irc.lightning.net
irc.isdnet.fr
irc.powersurfr.com
irc.total.net
irc.plur.net
irc.magic.ca
irc.ins.net.uk
irc.inter.net.il
irc.enitel.no
irc.homelien.no
irc.du.se
irc.hemmet.chalmers.se
irc.gigabell.de
efnet.demon.co.uk
efnet.vuurwerk.nl
irc.colorado.edu
efnet.cs.hut.fi
hub.il
irc.umn.edu
irc-h.total.net
irc.total.net



-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to