I'm writing a script that will print a random line of text from a file into an XCHAT channel. So far it works fine, but I want to add one last bit of functionality.
I have logs with, for example, "Oct 23 12:07:59 (nickname> " appearing before every line of text. I just want to print the parts of the lines that follow the "(nickname>", how can I do this?
__module_name__ = "ran.py"
__module_version__ = "1.0"
__module_description__ = "script to add random text to channel messages"
import xchat
import random
def ran(message):
message = random.choice(open("E:/logs/myfile.log", "r").readlines())
return(message)
def ran_cb(word, word_eol, userdata):
message = ''
message = ran(message)
xchat.command("msg %s %s"%(xchat.get_info('channel'), message))
return xchat.EAT_ALL
xchat.hook_command("ran", ran_cb, help="/ran to use")