110REM >EIRC 220REM The simplest IRC client you can write. Maybe. 330REM (C) Justin Fletcher, 1998 440: 550END=PAGE+1024*16 660REM Change these if you wish 770host$="irc.stealth.net" 880port=6667 990nick$="eirc" 10100ourchan$="#acorn" 11110: 12120REM Start connecting to a host 13130SYS "ESocket_ConnectToHost",host$,port TO handle 14140REPEAT 15150 SYS "ESocket_CheckState",handle TO state 16160 IF state<-1 THENSYS "ESocket_Forget",handle:SYS "ESocket_DecodeState",state TO a$:ERROR 1,"Failed ("+a$+")" 17170UNTIL state=4 18180: 19190REM We are now connected 20200PRINT"Connected" 21210: 22220REM Log on to the server 23230SYS "ESocket_SendLine",handle,"USER "+nick$+" x x :"+nick$ 24240SYS "ESocket_SendLine",handle,"NICK "+nick$ 25250SYS "ESocket_SendLine",handle,"JOIN "+ourchan$ 26260REM Install a monitor so that we don't waste time 27270SYS "ESocket_Monitor",0,handle TO monitor 28280SYS "ESocket_ResetMonitor",monitor,0 TO polladdr% 29290: 30300REM If we crash, we should tidy up after ourselves 31310ON ERROR SYS "XESocket_Forget",handle:SYS "XESocket_Forget",monitor:ERROR EXT ERR,REPORT$+" at line "+STR$ERL 32320: 33330REM Memory buffer for our data 34340bufsize%=1024 35350DIM buf% bufsize% 36360: 37370input$="":REM The input line 38380REPEAT 39390 REM In a taskwindow we should yield until there is data 40400 SYS "OS_UpCall",6,polladdr% 41410 IF !polladdr%<>0 THEN 42420 REM Reset the monitor for the time being 43430 SYS "ESocket_ResetMonitor",monitor,0 TO polladdr% 44440 REPEAT 45450 REM Read lines from the connection until this buffer is empty 46460 SYS "ESocket_ReadLine",handle,buf%,bufsize%,%100 TO ,str,len 47470 IF str<>0 AND $str<>"" THEN 48480 line$=$str 49490 IF LEFT$(line$,4)="PING" THEN 50500 REM Ping's must be replied to immediately 51510 SYS "ESocket_SendLine",handle,"PONG "+MID$(line$,6) 52520 ELSE 53530 REM Extract source info 54540 from$=MID$(LEFT$(line$,INSTR(line$+" "," ")-1),2) 55550 line$=MID$(line$,INSTR(line$+" "," ")+1) 56560 uid$=LEFT$(from$,INSTR(from$+"!","!")-1) 57570 com$=LEFT$(line$,INSTR(line$+" "," ")-1) 58580 line$=MID$(line$,INSTR(line$+" "," ")+1) 59590 REM remove the input line 60600 IF input$<>"" THENFORI=1TOLEN(input$):VDU127:NEXT 61610 CASE FNupper(com$) OF 62620 WHEN "PRIVMSG" 63630 REM Extract the destination 64640 chan$=LEFT$(line$,INSTR(line$+" "," ")-1) 65650 line$=MID$(line$,INSTR(line$+" "," ")+2):REM Skip : 66660 IF LEFT$(line$,1)=CHR$1 THEN 67670 REM CTCP, so respond to it 68680 line$=MID$(line$,2,LEN(line$)-2) 69690 com$=LEFT$(line$,INSTR(line$+" "," ")-1) 70700 line$=MID$(line$,INSTR(line$+" "," ")+1) 71710 CASE FNupper(com$) OF 72720 WHEN "PING" 73730 REM Ping lag timing 74740 line$="PONG "+line$ 75750 PRINTuid$;" pinged us" 76760 WHEN "VERSION" 77770 REM Version checking 78780 line$="VERSION EIRC 1.00 (c) Justin Fletcher" 79790 PRINTuid$;" wanted our version" 80800 WHEN "ACTION" 81810 PRINT"* ";uid$;" ";line$ 82820 line$="" 83830 OTHERWISE 84840 REM everything else is an error 85850 line$="ERRMSG "+com$+" not understood" 86860 PRINT"CTCP '";com$;"' from ";uid$;" (";line$;")" 87870 ENDCASE 88880 IF line$<>"" THEN 89890 SYS "ESocket_SendLine",handle,"NOTICE "+uid$+" :"+CHR$1+line$+CHR$1 90900 ENDIF 91910 ELSE 92920 REM Somebody said something... 93930 PRINT"<";uid$;"> ";FNsafe(line$) 94940 ENDIF 95950 WHEN "JOIN" 96960 REM We (or someone else) has joined the channel 97970 chan$=LEFT$(line$,INSTR(line$+" "," ")):REM Skip : 98980 IF LEFT$(chan$,1)=":" THENchan$=MID$(chan$,2) 99990 PRINTuid$;" has joined ";chan$ 1001000 WHEN "PART" 1011010 REM Someone else has left the channel 1021020 chan$=LEFT$(line$,INSTR(line$+" "," ")-1) 1031030 IF LEFT$(chan$,1)=":" THENchan$=MID$(chan$,2) 1041040 PRINTuid$;" has left ";chan$ 1051050 WHEN "QUIT" 1061060 REM Someone else has quit IRC 1071070 PRINTuid$;" quit IRC" 1081080 OTHERWISE 1091090 REM Some unknown command 1101100 PRINTuid$;":";com$;":";FNsafe(line$) 1111110 ENDCASE 1121120 REM Re-display our input line 1131130 PRINTinput$; 1141140 ENDIF 1151150 ENDIF 1161160 UNTIL str=0 1171170 ENDIF 1181180 b$=INKEY$(0) 1191190 IF b$<>"" THEN 1201200 CASE b$ OF 1211210 WHEN CHR$13 1221220 SYS "ESocket_SendLine",handle,"PRIVMSG "+ourchan$+" :"+input$ 1231230 REM Remove the line 1241240 IF input$<>"" THENFORI=1TOLEN(input$):VDU127:NEXT 1251250 REM We said it... 1261260 PRINT"<"+nick$+"> ";input$ 1271270 input$="" 1281280 WHEN CHR$127,CHR$8 1291290 REM Backspace 1301300 IF input$<>"" THENVDU127 1311310 input$=LEFT$(input$) 1321320 OTHERWISE 1331330 REM Ad to current input 1341340 input$+=b$ 1351350 PRINTb$; 1361360 ENDCASE 1371370 ENDIF 1381380 REM Has the socket closed 1391390 SYS "ESocket_Closed",handle,%0 TO closed 1401400UNTIL closed 1411410SYS "ESocket_Forget",handle 1421420SYS "ESocket_Forget",monitor 1431430END 1441440: 1451450DEFFNupper(a$):LOCAL c$,b$,I 1461460FORI=1TOLEN(a$) 1471470c$=MID$(a$,I,1):IF c$>="a"ANDc$<="z"THENc$=CHR$(ASC(c$)-32) 1481480b$+=c$:NEXT:=b$ 1491490 1501500REM Remove control codes 1511510DEFFNsafe(line$) 1521520LOCAL I 1531530FORI=1TOLEN(line$) 1541540 IF MID$(line$,I,1)<" " THENMID$(line$,I,1)="*" 1551550NEXT 1561560=line$ 157