Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 4 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 43 additions and 113 deletions.
  1. +42 −112 irc-bot.bf
  2. +1 −1  irc-bot.min.bf
View
154 irc-bot.bf
@@ -1,95 +1,36 @@
Brainfuck IRC bot
* Comments use ; in place of periods or commas as punctuation
* Meant to operate on 8 bit unsigned memory
-* Expects a good amount of memory; I use 0x10000 bytes; smaller is probably fine
+* Uses a minimum of 35 bytes of memory; more may be needed depending on the length of channel names it works in
* Expects stdin to block until data is available
* If you use netfuck; it'd be useful to know that debug mode outputs every character read from the remote to the console
Send NICK and USER
+++++++++++
+[
+ "NICK " >++++++++>+++++++>+++++++>+++++++>+++
+ "bfbot" >++++++++++>++++++++++>++++++++++>+++++++++++>+++++++++++
+ "\r\n" >+>+
+ "USER " >++++++++>++++++++>+++++++>++++++++>+++
+ "bfbot " >++++++++++>++++++++++>++++++++++>+++++++++++>+++++++++++>+++
+ "a a :" >+++++++++>+++>+++++++++>+++>+++++
+ "bfbot" >++++++++++>++++++++++>++++++++++>+++++++++++>+++++++++++
+ "\r\n" >+>+
+ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-
+]
+"NICK " >--.>+++.>---.>+++++.>++.
+"bfbot" >--.>++.>--.>+.>++++++.
+"\r\n" >+++.>.
+"USER " >+++++.>+++.>-.>++.>++.
+"bfbot " >--.>++.>--.>+.>++++++.>++.
+"a a :" >+++++++.>++.> +++++++.>++.>++++++++.
+"bfbot " >--.>++.>--.>+.>++++++.
+"\r\n" >+++.>.
+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-"NICK bfbot\r\nUSER bfbot a a :bfbot\r\n" (78 73 67 75 32 98 102 98 111 116 13 10 85 83 69 82 32 98 102 98 111 116 32 97 32 58 98 102 98 111 116)
- ++++++++++
- [
- N > +++++++
- I > +++++++
- C > ++++++
- K > +++++++
- > +++
- b > +++++++++
- f > ++++++++++
- b > +++++++++
- o > +++++++++++
- t > +++++++++++
- \r > +
- \n > +
- U > ++++++++
- S > ++++++++
- E > ++++++
- R > ++++++++
- > +++
- b > +++++++++
- f > ++++++++++
- b > +++++++++
- o > +++++++++++
- t > +++++++++++
- > +++
- a > +++++++++
- > +++
- a > +++++++++
- > +++
- : > +++++
- b > +++++++++
- f > ++++++++++
- b > +++++++++
- o > +++++++++++
- t > +++++++++++
- \r > +
- \n > +
- <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-
- ]
- "NICK bfbot\r\nUSER bfbot a a :bfbot\r\n" (78 73 67 75 32 98 102 98 111 116 13 10 85 83 69 82 32 98 102 98 111 116 32 97 32 58 98 102 98 111 116)
- N > ++++++++ .
- I > +++ .
- C > +++++++ .
- K > +++++ .
- > ++ .
- b > ++++++++ .
- f > ++ .
- b > ++++++++ .
- o > + .
- t > ++++++ .
- \r > +++ .
- \n > .
- U > +++++ .
- S > +++ .
- E > +++++++++ .
- R > ++ .
- > ++ .
- b > ++++++++ .
- f > ++ .
- b > ++++++++ .
- o > + .
- t > ++++++ .
- > ++ .
- a > +++++++ .
- > ++ .
- a > +++++++ .
- > ++ .
- : > ++++++++ .
- b > ++++++++ .
- f > ++ .
- b > ++++++++ .
- o > + .
- t > ++++++ .
- \r > +++ .
- \n > .
- <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end of "NICK bfbot\r\nUSER bfbot a :bfbot\r\n"
-
->
cell #0: working cell for iteration and such
cell #1 stdin (pointer currently points here)
[
- Messages come in like this: ":user PRIVMSG bfbot :message"
, Read out one character; see if it's a 'P' (80)
<[-] ++++++++++ [>--------<-] [-]+>
[ Handle NOT a ping
@@ -124,12 +65,8 @@ cell #1 stdin (pointer currently points here)
Write JOIN command 74 79 73 78 32 (user text) 13 10
<[-]++++++++++
>[-]>[-]>[-]>[-]>[-]<<<<<
- [>+++++++ >+++++++ >+++++++ >+++++++ >+++ <<<<<-]
- >++++.
- >+++++++++.
- >+++.
- >++++++++.
- >++.
+ [>+++++++ >++++++++ >+++++++ >++++++++ >+++ <<<<<-]
+ >++++.>-.>+++.>--.>++.
<<<<<[-]>
Write user text:
@@ -167,46 +104,39 @@ cell #1 stdin (pointer currently points here)
<[>
Send 'PRIVMSG #' 80 82 73 86 77 83 71 32 35 without screwing up the channel name buffer
[-]<[-]++++++++++[>++++++++<-]>.
- [-]<[-]++++++++++[>++++++++<-]>++.
- [-]<[-]++++++++++[>+++++++<-]>+++.
- [-]<[-]++++++++++[>++++++++<-]>++++++.
- [-]<[-]++++++++++[>+++++++<-]>+++++++.
- [-]<[-]++++++++++[>++++++++<-]>+++.
- [-]<[-]++++++++++[>+++++++<-]>+.
- [-]<[-]++++++++++[>+++<-]>++.
- [-]<[-]++++++++++[>+++<-]>+++++.
+ [-]<++++++++++[>++++++++<-]>++.
+ [-]<++++++++++[>+++++++<-]>+++.
+ [-]<++++++++++[>+++++++++<-]>----.
+ [-]<++++++++++[>++++++++<-]>---.
+ [-]<++++++++++[>++++++++<-]>+++.
+ [-]<++++++++++[>+++++++<-]>+.
+ [-]<++++++++++[>+++<-]>++.
+ [-]<++++++++++[>+++<-]>+++++.
Send the channel name from our buffer
[-]>[.>]<[<]
Send a space; then a colon (58)
[-]<[-]++++++++++[>+++<-]>++.
- [-]<[-]++++++++++[>++++++<-]>--.
+ [-]<++++++++++[>++++++<-]>--.
Finally; send the user's message
[-]+[ ,. ---------- ]
- <[-]]>
- <[-]]>
- <[-]]>
- <[-]]>[-]+
+ <[-]]
+ [-]]
+ [-]
+ [-]]>[-]+
<[-]>[-]]<[
Handle PING
- ,,, Read out "ING "
+ ,,, Read out "ING" (optimization: we steal the space from this message later on; so we needn't write it)
Write PONG 80 79 78 71 32
[-]++++++++++[
>++++++++
+ >++++++++
+ >++++++++
>+++++++
- >+++++++
- >+++++++
- >+++
<<<<<-
- ]
- >.
- >+++++++++.
- >++++++++.
- >+.
- >++.
- <<<<<
+ ]>.>-.>--.>+.<<<<<
[-]+[ ,. ---------- ] Write out the PING response
- [-]]>+
+ ]>+
]
View
2  irc-bot.min.bf
@@ -1 +1 @@
-++++++++++[>+++++++>+++++++>++++++>+++++++>+++>+++++++++>++++++++++>+++++++++>+++++++++++>+++++++++++>+>+>++++++++>++++++++>++++++>++++++++>+++>+++++++++>++++++++++>+++++++++>+++++++++++>+++++++++++>+++>+++++++++>+++>+++++++++>+++>+++++>+++++++++>++++++++++>+++++++++>+++++++++++>+++++++++++>+>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-]>++++++++.>+++.>+++++++.>+++++.>++.>++++++++.>++.>++++++++.>+.>++++++.>+++.>.>+++++.>+++.>+++++++++.>++.>++.>++++++++.>++.>++++++++.>+.>++++++.>++.>+++++++.>++.>+++++++.>++.>++++++++.>++++++++.>++.>++++++++.>+.>++++++.>+++.>.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>[,<[-]++++++++++[>--------<-][-]+>[[-]+[,<[-]++++++++++[>---<-]>--],<[-]++++++++++[>--------<-][-]+>[[,----------]<->]<[>,<[-]++++++++++[>--------<-]>--<[-]+>[[,----------]<->]<[>,,,,,,,<[-]++++++++++[>---<-]>-----<[-]+>[<[-]>[,<++++++++++[>---<-]>--],,<++++++++++[>-------<-]>----<[-]+>[[-]<->]<[>,<[-]++++++++++>[-]>[-]>[-]>[-]>[-]<<<<<[>+++++++>+++++++>+++++++>+++++++>+++<<<<<-]>++++.>+++++++++.>+++.>++++++++.>++.<<<<<[-]><[-]+[>,-------------<[-]>[<+>+++++++++++++.[-]]<]>[-]++++++++++.+++.<[-]]>+[,----------]<[-]>]<[>[-]>[-]+<+[>,+>[-]>[-]<<[>+>+<<-]>[<+>-]><++++++++++[>---<-]>---<+>[<->[-]]<[<[-]>[-]]<]<-[<-],,<[-]++++++++++[>---<-]>------<+>[[-]+[,----------]<->]<[>[-]<[-]++++++++++[>++++++++<-]>.[-]<[-]++++++++++[>++++++++<-]>++.[-]<[-]++++++++++[>+++++++<-]>+++.[-]<[-]++++++++++[>++++++++<-]>++++++.[-]<[-]++++++++++[>+++++++<-]>+++++++.[-]<[-]++++++++++[>++++++++<-]>+++.[-]<[-]++++++++++[>+++++++<-]>+.[-]<[-]++++++++++[>+++<-]>++.[-]<[-]++++++++++[>+++<-]>+++++.[-]>[.>]<[<][-]<[-]++++++++++[>+++<-]>++.[-]<[-]++++++++++[>++++++<-]>--.[-]+[,.----------]<[-]]><[-]]><[-]]><[-]]>[-]+<[-]>[-]]<[,,,[-]++++++++++[>++++++++>+++++++>+++++++>+++++++>+++<<<<<-]>.>+++++++++.>++++++++.>+.>++.<<<<<[-]+[,.----------][-]]>+]
+++++++++++[>++++++++>+++++++>+++++++>+++++++>+++>++++++++++>++++++++++>++++++++++>+++++++++++>+++++++++++>+>+>++++++++>++++++++>+++++++>++++++++>+++>++++++++++>++++++++++>++++++++++>+++++++++++>+++++++++++>+++>+++++++++>+++>+++++++++>+++>+++++>++++++++++>++++++++++>++++++++++>+++++++++++>+++++++++++>+>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-]>--.>+++.>---.>+++++.>++.>--.>++.>--.>+.>++++++.>+++.>.>+++++.>+++.>-.>++.>++.>--.>++.>--.>+.>++++++.>++.>+++++++.>++.>+++++++.>++.>++++++++.>--.>++.>--.>+.>++++++.>+++.>.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[,<[-]++++++++++[>--------<-][-]+>[[-]+[,<[-]++++++++++[>---<-]>--],<[-]++++++++++[>--------<-][-]+>[[,----------]<->]<[>,<[-]++++++++++[>--------<-]>--<[-]+>[[,----------]<->]<[>,,,,,,,<[-]++++++++++[>---<-]>-----<[-]+>[<[-]>[,<++++++++++[>---<-]>--],,<++++++++++[>-------<-]>----<[-]+>[[-]<->]<[>,<[-]++++++++++>[-]>[-]>[-]>[-]>[-]<<<<<[>+++++++>++++++++>+++++++>++++++++>+++<<<<<-]>++++.>-.>+++.>--.>++.<<<<<[-]><[-]+[>,-------------<[-]>[<+>+++++++++++++.[-]]<]>[-]++++++++++.+++.<[-]]>+[,----------]<[-]>]<[>[-]>[-]+<+[>,+>[-]>[-]<<[>+>+<<-]>[<+>-]><++++++++++[>---<-]>---<+>[<->[-]]<[<[-]>[-]]<]<-[<-],,<[-]++++++++++[>---<-]>------<+>[[-]+[,----------]<->]<[>[-]<[-]++++++++++[>++++++++<-]>.[-]<++++++++++[>++++++++<-]>++.[-]<++++++++++[>+++++++<-]>+++.[-]<++++++++++[>+++++++++<-]>----.[-]<++++++++++[>++++++++<-]>---.[-]<++++++++++[>++++++++<-]>+++.[-]<++++++++++[>+++++++<-]>+.[-]<++++++++++[>+++<-]>++.[-]<++++++++++[>+++<-]>+++++.[-]>[.>]<[<][-]<[-]++++++++++[>+++<-]>++.[-]<++++++++++[>++++++<-]>--.[-]+[,.----------]<[-]][-]][-][-]]>[-]+<[-]>[-]]<[,,,[-]++++++++++[>++++++++>++++++++>++++++++>+++++++<<<<<-]>.>-.>--.>+.<<<<<[-]+[,.----------]]>+]

No commit comments for this range

Something went wrong with that request. Please try again.