title: Python IRC bot for Twitch receiving two messages in one output
body: <p>So I've created a Chat bot for Twitch.tv which has been working fine for multiple months until a couple of days ago. Either the chat is too flooded or twitch changed something with the way they send messages. Either way, in every message received I add a new line when printing into the console and some messages do not have this added line, which means multiple messages can fit in one irc.recv(). I tried editing the size of the recv, but haven't had any success. This is an image of the print that the irc.recv() gives, in case it helps.</p>
  
  <p><a href="http://i.stack.imgur.com/pWeGt.jpg" rel="nofollow">http://i.stack.imgur.com/pWeGt.jpg</a></p>
  
  <p>If you look at the middle, you'll see that the two messages does not have a space between them which means if the second person would do something bannable, the first user would be banned.</p>
  
  <p>And as you can see it could be easy to separate messages by following the ":nick!nick@nick.tmi.twitch.tv PRIVMSG #channel :", but it could also be easy for someone who understands this design to abuse the bot and timeout anyone.</p>
  
  <p>What I hope to achieve is a way to modify the irc.recv() so that it only and always receives exactly one message. </p>
  
  <p>Here are a couple of snippets of the code to get a better understanding of what is going on.</p>
  
  <pre><code># -*- coding: utf-8 -*-
  import socket
  import threading
  import datetime
  import time
  
  
  bot_owner = 'asd'
  nick = 'asdrobot' 
  channel = '#asd'
  server = 'irc.twitch.tv'
  password = 'asd' #login authentication
  
  global irc
  irc = socket.socket()
  irc.connect((server, 6667)) #connects to the server
  irc.send('PASS ' + password + '\r\n')
  irc.send('USER ' + nick + ' 0 * :' + bot_owner + '\r\n')
  irc.send('NICK ' + nick + '\r\n')
  irc.send('JOIN ' + channel + '\r\n')
  
  while True:
          senderdata = irc.recv(1024) #gets output from IRC server
          sendermessage = ''      #Empties variable
          senderuser = ''         #Empties variable
          senderusertemplist = [] #Empties variable
          if(senderdata.find('PRIVMSG') != -1): 
                print senderdata
                try:
                     senderuser = senderdata.split(':')[1]
                     senderuser = senderuser.split('!')[0] #determines the sender of the messages
                except IndexError as e:
                     senderuser = 'ERRORERROR'
                     print 'can not split this data'
                     print e
                sendermessage = senderdata.split(channel)[-1]
                sendermessage = sendermessage.split(':', 1)[-1]
                sendermessagelow = sendermessage.lower()
  </code></pre>
  
  <p>These are just the most important pieces, and by the time the code reaches this point, the problem has already occurred.</p>
  
  <p>If there is no way to "fix" the problem and it's part of how IRC works I'd love to know, but if you know a way to fix it I'd be extremely grateful. </p>
  
  <p>Thank you.</p>