IMHO you make too much assumptions on the IRC-protocoll in your parser.
Here's the more complete irc-parsing-function of my IRC-Bot:

    parse-msg: func [str [string!] 
                   /local _sender _par_tk _nick_tk _usr_tk _svr_tk _tpar_tk 
                                _trl_tk _cmd_tk _white _nonwhite _parch _space
                                _middle _params _message] [
        _white: charset [#" " #"^-" #"^@" #0 #"^M" #"^/"]
        _nonwhite: complement _white
        _parch: complement charset " ^-^@^M^/:"
        _space: [some _white]
        _middle: [_parch any _nonwhite]
        _params: [_space  [ copy _tpar_tk _middle (append _par_tk _tpar_tk)   
                      _params | [#":" copy _trl_tk to end ]]]
        _message: [opt [#":" [[copy _nick_tk to "!" skip 
                         copy _usr_tk to "@" skip 
                         copy _svr_tk to " " skip]
                        |copy _nick_tk to " " skip]] 
                         copy _cmd_tk to " " 
                 _params]
        clear _par_tk: []
        set [_nick_tk _usr_tk _svr_tk
        _tpar_tk _trl_tk _cmd_tk] none
        parse/all str _message
        _sender: either _usr_tk [reduce ['nick _nick_tk 
                                                     'user _usr_tk 
                                                     'host _svr_tk]]
                                        [_nick_tk]
        make object! [
            sender: _sender
            command: _cmd_tk
            parameters: copy _par_tk
            trailing-arg: _trl_tk
        ]
    ]

It's not absolutely ready yet, but it works for all IRC-messages

On Sat, 30 Sep 2000, you wrote:
> I was creating a script for IRC when I noticed that the find command
> doesn't seem to work right from reading the port and parsing the data but
> does when reading from the console with the same functions.  I am reading
> in a typical message string into iput-buffer for example (Port is opening a
> port to irc):
>
> ircparser: func [/local a b c][
>     a: parse/all copy input-buffer "!"
>     sendnick: pick a 1
>     b: pick a 2
>     print b
>     sendmsg: find b ":"
>     print sendmsg
>     c: parse copy input-buffer
>     senduser: pick c 2
>     sendcmd: pick c 3
>     sendchan: pick c 4
> ]
>
> while [true][
>
>   wait port
>
>   input-buffer: copy first port
>
>   if find/part input-buffer ":" 1 [
>      input-buffer: remove head input-buffer
>      ircparser
>   ]
>
> _________________________________ Console Windows _______________
> NOTICE AUTH :*** Looking up your hostname...
> NOTICE AUTH :*** Found your hostname, cached
> NOTICE AUTH :*** Checking Ident
> NOTICE AUTH :*** No Ident response
> none
> ** Script Error: find expected series argument of type: series port bitset.
> ** Where: sendmsg: find b ":"
> print
>
> ________________________________________________________________
>
> Anyone know what the problem is?
>
> Seems to work ok if I recreate the issue from the console.

Reply via email to