Python IRC bot help [duplicate]
Possible Duplicate:
Python IRC bot question
How do I implement functionality into an existing Python IRC bot framework that ill accept Python source a line at a time, accepting multi-line statements and preserving the results for later use? Like, if I want to define a function from my IRC window and then be able to call that function later as well as treat my bot as a Python interpreter, how is that possible? I have seen someone do it before, but they wouldn't give me the source code.
My bot will run on a Linux VPS.
I'd look at eval()
, as it runs strings as Python code:
eval('print 3 + 1') # Outputs: 4
You can use this function to evaluate strings as Python code (in your case lines of IRC chat). Be very careful with this, as it allows arbitrary access to the Python interpreter, which can 'splode your computer if someone else gets hold of this thing.
Can you elaborate a bit more on what you're trying to achieve with this?
精彩评论