Programming

Tuesday 4 January 2022, 23:35  #1
Programming GO back to college challenge
Adam Valin
  • 1 posts

Hello guys,

After a lot of trials, I finally managed to send a message to candy and to receive the two numbers :

:Candy!Candy@root-me.org PRIVMSG botname :907 / 6746

I now want to isolate each of these numbers in a variable to treat them and to do the calculus. Thos numbers are for now string types. Here is my code for this task :

irc.send(bytes("PRIVMSG candy :!ep1 \r\n",’UTF-8’))
resp = irc.recv(2040).decode("UTF-8")
print(resp)
number1 = resp.split(’ ’)[3]
character = ":"
number1 = ’’.join( x for x in number1 if x not in character)
print(number1)
number2 = resp.split(’ ’)[5]
print(number2)

I succeed in isolating those two numbers in two variables as my console printed me precisely this message :
907
6746

So now I want to transform those string types into int types to do the calculus. For now I just add two lines of codes to my actual codes that are :

irc.send(bytes("PRIVMSG candy :!ep1 \r\n",’UTF-8’))
resp = irc.recv(2040).decode("UTF-8")
print(resp)
number1 = resp.split(’ ’)[3]
character = ":"
number1 = ’’.join( x for x in number1 if x not in character)
print(number1)
number2 = resp.split(’ ’)[5]
print(number2)

entier1 = int(number1)
entier2 = int(number2)

But when I add those two lines, number1 and number2 change ... They don’t detect the number as it did before but detect respectively the third and fifth word of the resp recv that is :

:irc.hackerzvoice.net 451 JOIN :You have not registered
:irc.hackerzvoice.net NOTICE Auth :Welcome to -HackerzVoice-!
:irc.hackerzvoice.net 001 botname :Welcome to the HackerzVoice IRC Network botname!botname@lfbn-gre-1-338-145.w90-112.abo.wanadoo.fr
:irc.hackerzvoice.net 002 botname :Your host is irc.hackerzvoice.net, running version InspIRCd-2.0
:irc.hackerzvoice.net 003 botname :This server was created 19:52:09 Aug 12 2013
:irc.hackerzvoice.net 004 botname irc.hackerzvoice.net InspIRCd-2.0 BHIRSWcghiorswx FLMNPRSYabcefhijklmnopqrstvz FLYabefhjkloqv
:irc.hackerzvoice.net 005 botname AWAYLEN=200 CALLERID=g CASEMAPPING=rfc1459 CHANMODES=be,k,FLfjl,MNPRScimnprstz CHANNELLEN=64 CHANTYPES=# CHARSET=ascii ELIST=MU EXCEPTS=e EXTBAN=,NRSUcjmz FNC KICKLEN=255 MAP :are supported by this server
:irc.hackerzvoice.net 005 botname MAXBANS=60 MAXCHANNELS=20 MAXPARA=32 MAXTARGETS=20 MODES=20 NETWORK=HackerzVoice NICKLEN=31 OVERRIDE PREFIX=(Yqaohv)! &@%+ SECURELIST SSL=0.0.0.0:6697 STARTTLS STATUSMSG=! &@%+ :are supported by this server
:irc.hackerzvoice.net 005 botname TOPICLEN=307 USERIP VBANLIST WALLCHOPS WALLVOICES :are supported by this server
:irc.hackerzvoice.net 042 botname 959ADT3MA :your unique ID
:irc.hackerzvoice.net 375 botname :irc.hackerzvoice.net message of the day
:irc.hackerzvoice.net 372 botname :- ██████████ ╻ ╻┏━┓┏━╸╻┏ ┏━╸┏━┓╺━┓╻ ╻┏━┓╻┏━╸┏━╸
:irc.hackerzvoice.net 372 botname :- ████████ ██ ┣━┫┣━┫┃ ┣┻┓┣╸ ┣┳┛┏━┛┃┏┛┃ ┃┃┃ ┣╸
:irc.hackerzvoice.net 372 botname :- ██ ██ ██ ╹ ╹╹ ╹┗━╸╹ ╹┗━╸╹┗╸┗━╸┗┛ ┗━┛╹┗━╸┗━╸
:irc.hackerzvoice.net 372 botname :- ██████████████
:irc.hackerzvoice.net 372 botname :- ██████████ IRC network at irc.hackerzvoice.net.
:irc.hackerzvoice.net 372 botname :-

So number1 is now equal to "You" while number2 is equal to "not".

I really don’t know what to do, can someone explain to me what is happening ?

Thanks a lot,
have a good day and happy new year