【发布时间】:2010-10-22 07:46:57
【问题描述】:
我正在编写一个脚本,它将文件中的随机文本行打印到 XCHAT 通道中。到目前为止它工作正常,但我想添加最后一点功能。
我有日志,例如,“Oct 23 12:07:59 (nickname>”出现在每一行文本之前。我只想打印“(nickname>”之后的行的部分,如何我可以这样做吗?
__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")
【问题讨论】:
标签: python string irc text-files