Created
November 1, 2018 03:57
-
-
Save jasonblewis/dd5e316c7aa2fbf053a8aa25dbb7a6df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_response(): | |
while(client.connected): | |
client.last_response = client.get_response() | |
if(client.last_response != ''): | |
logging.debug("RAW: {}".format(client.last_response)) | |
if "PING" in client.last_response: # Respond to pongs from the server | |
client.send_pong(client.last_response) # Give the server the timestamped PONG | |
if "Closing Link" in client.last_response: # Server said goodbye | |
client.connected = False # So we're disconnected now, thread ends. | |
try: | |
msg = client.last_response.strip().split(":") # remove leading : | |
host = msg[1] | |
nick = host.split("!")[0] | |
hostarray = host.split(" ") | |
message = msg[2].strip() | |
if hostarray[1] == "PRIVMSG": | |
if hostarray[2].startswith("#"): | |
print("{}: < {}> {}".format(hostarray[2],nick, message)) | |
else: | |
print("PRIVMSG from {}: < {}> {}".format(hostarray[2],nick, message)) | |
else: | |
print("some other message:< {}> {}".format(nick, message)) | |
logging.debug("RAW: {}".format(msg)) | |
except IndexError: | |
print("RAW: {}".format(msg)) # Something went wrong with the next few lines... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment