Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

I give up

 [1/9] from: ptretter::charter::net at: 8-Sep-2000 9:46


I cant figure it out - doc after doc port after port - its killin me. How do you join an irc channel? I did the open port stuff I can do it with telnet but not with REBOL. Look at my script below and tell me whats wrong. I understand I havent accounted for everything that IRC RFC states but should I think have enough to contact the server and join the channel but doesnt work. Any ideas? Paul Tretter ------------------------------------------ REBOL[] irc-port: open/direct/string/no-wait [ scheme: 'tcp host: "irc.mindspring.com" port-id: 6667 ] while [data: copy irc-port] [prin data] insert irc-port "NICK tret^/" close irc-port irc-port: open/direct/string/no-wait [ scheme: 'tcp host: "irc.mindspring.com" port-id: 6667 ] insert irc-port "USER tret rebol.dyndns.org irc.mindspring.com tret^/" close irc-port irc-port: open/direct/string/no-wait [ scheme: 'tcp host: "irc.mindspring.com" port-id: 6667 ] insert irc-port reform "JOIN #REBOLGODS^/" close irc-port

 [2/9] from: russ:portone at: 8-Sep-2000 13:01


Perhaps the following (keeping as close to your code as possible) will help... it's very basic but at least you see responses from the IRC server, on the basis of which you'll be able to add more to do what you desire. REBOL[] size: 10000 b: make string! size irc-port: [ scheme: 'tcp host: "us.dal.net" port-id: 7000 ] port: open irc-port insert port "NICK tret^/" insert port "USER tret rebol.dyndns.org irc.mindspring.com tret^/" insert port "JOIN #REBOLGODS^/" insert port "WHOIS tret^/" forever [ if 0 < length? b [print b clear b] ; display replies and clear buffer read-io port b size ; get next replies from server ] ; use ESC to stop program and then manually enter "close port" ; or just wait for port to time out and close itself on error Russ ---- At 09:46 AM 9/8/2000 -0500, you wrote:

 [3/9] from: ptretter:charter at: 8-Sep-2000 12:26


This helps greatly. Now i need to master pong response to server pings. Im curious why you didnt have to close the port every time you made a send. Paul Tretter

 [4/9] from: russ:portone at: 8-Sep-2000 15:29


Cuz once the port is open, you can keep sending as long as you like... and close it only when done. That's the way ports work. Of course, the way this now stands there's no really safe closing taking place... but you can put that in later when you /QUIT IRC or whatever. Re ping/pong... you'll see them coming at you with this program.. if it stays alive long enough... and you can figure how to parse them and respond. I've done a whole IRC client in REBOL, but not in position to release it in total. It was quite a while ago, so I need lots of head scratching to go back and figure things out... but will help if you're REALLY stuck. Russ PS: Here's the section of my code that does the PONG... but you'll have to infer what 'p is.. and how I parsed it from the PING message received from server (you can ignore my debug and logging mode lines): if (find/case first p "PING") [ ; system PING (reply with PONG) if debug [ foreach item p [prin item] prin newline ] insert irc rejoin["PONG " second p newline] if debug [ print rejoin["PONG " second p newline] ] if logging [ append log rejoin["PONG " second p newline] ] --------- At 12:26 PM 9/8/2000 -0500, you wrote:

 [5/9] from: peoyli:algonet:se at: 8-Sep-2000 12:46


I've done a client too, it is available at http://www.algonet.se/~peoyli/RebIRC, but its code needs some more work.. I mostly wrote this to learn Rebol and the IRC protocol, and it was meant to be a bot that jumps into a channel and gets the userlist and leaves again (to make the channel's people's page more interesting).. My solution to the PING/PONG stuff was something like.. handle-irc-cmd: func [] [ switch/default/case irc/command reduce[ "PING" [ insert irc-port rejoin ["PONG " (first irc/params) newline] prin #"^G" ] ... with "irc" being an object which consists of irc-obj: make object! [ prefix: make object! [full: nick: user: host: string!] command: string! params: block! ] (as described in the RFC) /PeO

 [6/9] from: ptretter:charter at: 8-Sep-2000 16:50


Is this line "prefix: make object! [full: nick: user: host: string!]" supposed to be replaced with the actual nick user and host portions or is this proper syntax! Paul Tretter

 [7/9] from: ptretter:charter at: 8-Sep-2000 16:50


If I were to parse the "b" from the read-io what type does read-io deliver is it type port?. If so how do you parse port datatypes? Paul Tretter

 [8/9] from: russ:portone at: 9-Sep-2000 7:49


Paul, "b" is just what comes in from the port. As you can see by the second line of code, 'b is simply a string. You see it's contents when this program runs, as all this does is print 'b over and over as the data arrives. Check out the docs/examples on 'parse... it's very powerful and exactly what you're gonna need to do the work here. Russ --- At 04:50 PM 9/8/2000 -0500, you wrote:
>If I were to parse the "b" from the read-io what type does read-io deliver >is it type port?. If so how do you parse port datatypes?
<<quoted lines omitted: 11>>
>b: make string! size <snip>

 [9/9] from: ptretter:charter at: 9-Sep-2000 10:06


Thanks Russ. I am already hard at work on this and getting good results. I thank you for your help. For anyone that wants to deal with ports this thread should help everyone.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted