elif data.find('PRIVMSG') != -1:
message = ':'.join(data.split (':')[2:])
if message.lower().find('code') == -1:
nick = data.split('!')[ 0 ].replace(':',' ')
destination = ''.join (data.split(':')[:2]).split (' ')[-2]
function = message.split( )[0]
print nick + ' : ' + function
arg = data.split( )
args = ''
for index,item in enumerate(arg) :
if index > 3 :
if args == '':
args = item
else :
args += ' ' + item
if data.find('.topic') != -1:
nick = data.split('!')[ 0 ].replace(':','')
for line in open('masters.txt'):
if nick in line:
sck.send('TOPIC ' + " " + chan + " " + args + '\r\n')
When I try to do something like .topic 1 2 3 4 5 6 7 8 9 10
it changes the topic of the channel to 3 4 5 6 7 8 9 10
instead of of the whole thing 1 2 3 4 5 6 7 8 9 10
I'm wondering why does it start from the 3rd string and not from the beginning? Do I need to split or strip something from the string?
I fixed the bug in my code.
if data.find('.topic') != -1:
nick = data.split('!')[ 0 ].replace(':','')
for line in open('masters.txt'):
if nick in line:
sck.send('TOPIC ' + " " + chan + " :" + args + '\r\n')
this one works, I needed to add " :"
after declaring the channel variable so it can read the data properly.