Search code examples
pythonsocketsirctypeerror

IRC Bot TypeError (python)


  if data.find('!search') != -1:
     nick = data.split('!')[ 0 ].replace(':','')
     conn = httplib.HTTPConnection("www.md5.rednoize.com")
     conn.request("GET", "?q=" + arg) 
     response = conn.getresponse()
     data = response.read() 
     result = re.findall('<div id="result" >(.+?)</div', data)
     if result:
        sck.send('PRIVMSG ' + chan + result + '\r\n')
     else:
           sck.send('PRIVMSG ' + chan + " :" ' could not find the hash' + '\r\n')

When I run this code I get this error:

conn.request("GET " + "?q=" + arg)
TypeError: cannot concatenate 'str' and 'list' objects

How can I fix this?


Solution

  • Where does arg come from? Do you know what it's supposed to contain?

    arg is apparently a list, not a string. Try replacing arg with str(arg[0]) and see if that works.