Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IRC Message Parsing
#1
Hey all I am pretty much brand new to coding. I figured a fun way to learn would be to start doing coding challenges online.
For one of my challenges the object is to connect to an IRC channel and send a private message to a bot; get a reply from the bot (this bots message changes every time.) & then reply back with an answer.

It answers in this format 123 / 1234 it gives two numbers each time the command is sent two it.

So far I have been able to get my bot to connect, Take a command and send a PM to the bot. I am seeing the reply but I'm having trouble parsing the data and storing it so my bot can make its answer.

I'm trying to split the PRIVMSG but am curious if there is a way to use the find function with a regular expression? or if someone could point me in the right direction to a better function.

Here is a snippet of the code not the entire thing just to get an idea what im up to
while 1:		
		ircmsg = ircsocket.recv(2048).decode("UTF-8")
		ircmsg = ircmsg.strip('\n\r')
		print(ircmsg)

		if ircmsg.find('PRIVMSG') != -1:
			
			name = ircmsg.split('!',1)[0][1:]
			message = ircmsg.split('PRIVMSG', 1)[1].split(':',1)[1]
			response = ircmsg.split("PRIVMSG", 1)[1].split('/',1)[1]
	
			if len(name) < 17:
				
				if message.find("solve " + botnick) != -1:
					sendmsg("Solving....")
					ircsocket.send(bytes("PRIVMSG "+ "cyberchron " + " !ep1" + " ", "UTF-8"))

				if response.find(response) != -1:
					sendmsg(response)## Will spit out the last 4 digits This is where im unsure how to parse out a messages sent back.
Thanks in advance :D
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020