Last active
January 1, 2020 06:10
-
-
Save amigojapan/e21e07223861d9e17a0a5513b5a0c88d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| server$ = "irc.freenode.net" | |
| nick$ = "you_nick_here" | |
| channel$ = "#qb64" | |
| client = _OPENCLIENT("TCP/IP:6667:" + server$) | |
| line$ = "nick " + nick$ + CHR$(10) + CHR$(13) + "user a a a a" + CHR$(10) + CHR$(13) | |
| PUT #client, , line$: SLEEP 2 | |
| line$ = "join " + channel$ + CHR$(10) + CHR$(13) | |
| PUT #client, , line$: SLEEP 2 | |
| DO | |
| _DELAY 0.05 ' 50ms delay (20 checks per second) | |
| GET #client, , buff$ | |
| IF buff$ <> "" THEN | |
| PRINT buff$ | |
| PRINT "" | |
| PRINT user_input$; | |
| IF INSTR(1, buff$, "PING") = 1 THEN 'handle PING | |
| s$ = MID$(buff$, 5, LEN(buff$)) 'get orwell.freenode.net | |
| line$ = "PONG" + s$ + CHR$(10) + CHR$(13) | |
| PRINT "pong reached", line$ | |
| PUT #client, , line$: SLEEP 2 | |
| END IF | |
| END IF | |
| k$ = INKEY$ | |
| IF k$ <> "" THEN | |
| IF k$ = CHR$(8) THEN | |
| user_input$ = MID$(user_input$, 1, LEN(user_input$) - 1) | |
| PRINT "" | |
| PRINT user_input$; | |
| ELSE IF k$ = CHR$(13) THEN | |
| line$ = "privmsg " + channel$ + " : " + user_input$ + CHR$(10) + CHR$(13) | |
| PUT #client, , line$: SLEEP 2 | |
| user_input$ = "" | |
| PRINT "" | |
| ELSE | |
| user_input$ = user_input$ + k$ | |
| PRINT k$; 'echo user input ; eliminates new lines | |
| END IF | |
| END IF | |
| END IF | |
| LOOP | |
| CLOSE client |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment