开发者

Python IRC bot help [duplicate]

This question already has answers here: 开发者_运维知识库 Closed 11 years ago.

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜