# IRC bot test

**URL:** <https://www.ruby-forum.com/t/irc-bot-test/104804>\
**Category:** Ruby\
**Created:** [May 22, 2007, 8:27pm UTC](https://www.ruby-forum.com/t/irc-bot-test/104804 "2007-05-22T20:27:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deniz\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/53a042/32.png) [@Deniz\_D](https://www.ruby-forum.com/u/Deniz_D)\
**Post date:** [May 22, 2007, 8:27pm UTC](https://www.ruby-forum.com/t/irc-bot-test/104804/1 "2007-05-22T20:27:17Z")

</div>

Hey!

I’m trying to create a very simple IRC bot using Ruby. I don’t have very  
much experience with sockets programming and I have a rather simple  
question for you.

I have been able to receive information from the connection to the  
server and identify to it and all of that, and I have been able to  
implement timestamps when the program prints to stdout. The problem is  
that I use a receive buffer at 512 bytes and sometimes the rows get  
“split” like this:

20:13:13 !! :irc.du.se 372 krisss :- Maybe buy shells to IRC from at  
[http://www.KIREnet.com](http://www.KIREnet.com). If that one  
20:13:13 !! :irc.  
20:13:13 !! du.se 372 krisss :- mentioned before isnt’t enough,  
[http://www.JEAH.net](http://www.JEAH.net) is around, too!

How should I go about making it printing it “correctly”?

–Deniz D.

---

<div class="post-metadata">

**Author:** ![Deniz\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/53a042/32.png) [@Deniz\_D](https://www.ruby-forum.com/u/Deniz_D)\
**Post date:** [May 22, 2007, 9:08pm UTC](https://www.ruby-forum.com/t/irc-bot-test/104804/2 "2007-05-22T21:08:22Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

If it’s of any interest, I already have an IRC bot written in Ruby at  
[http://ltbot.sourceforge.net](http://ltbot.sourceforge.net)  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFGUz832vy7v+d+psQRAuqpAJ42MdueU7UB21B2nPB5MhMTPgXEVACg6v73  
FNx/lGfgAB/jRYNX+lmEH4Q=  
=I2p9  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Deniz\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/53a042/32.png) [@Deniz\_D](https://www.ruby-forum.com/u/Deniz_D)\
**Post date:** [May 22, 2007, 10:29pm UTC](https://www.ruby-forum.com/t/irc-bot-test/104804/3 "2007-05-22T22:29:30Z")

</div>

Deniz D. wrote:

> The problem is  
> that I use a receive buffer at 512 bytes and sometimes the rows get  
> “split” like this:

That’s indeed the problem IMHO which is why I suggest you solve that  
instead. You can use gets("\r\n") to get one full message at a time.

Regards  
Stefan
