Python IRC 机器人帮助
可能的重复:
Python IRC 机器人问题
如何在接受 Python 的现有 Python IRC 机器人框架中实现功能一次获取一行,接受多行语句并保留结果以供以后使用?例如,如果我想从 IRC 窗口定义一个函数,然后能够稍后调用该函数并将我的机器人视为 Python 解释器,这怎么可能呢?我以前见过有人这样做,但他们不给我源代码。
我的机器人将在 Linux VPS 上运行。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会看看
eval()
,如它以 Python 代码形式运行字符串:您可以使用此函数将字符串作为 Python 代码进行计算(在您的 IRC 聊天行中)。对此要非常小心,因为它允许任意访问 Python 解释器,如果其他人掌握了这个东西,它可能会“破坏你的计算机”。
您能否详细说明一下您试图通过此实现什么目标?
I'd look at
eval()
, as it runs strings as Python code: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?