IRC Python Bot:最佳方法 [英] IRC Python Bot: Best Way

查看:57
本文介绍了IRC Python Bot:最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个基本上执行以下操作的机器人:

I want to build a bot that basically does the following:

  1. 听房间并与用户互动,并鼓励他们PM机器人.
  2. 一旦用户PMed,机器人就会使用各种AI技术与客户端互动.

我应该只在Python中使用IRC库还是Socket,还是我需要更多的bot框架?

Should I just use the IRC library or Sockets in python or do I need more of a bot framework.

你会怎么做?

谢谢!

这是我当前正在使用的代码,但是,我还没有使用它.

Here is the code I'm currently using, however, I haven't gotten it to work.

#!/usr/bin/python 
import socket
network = 'holmes.freenet.net'
port = 6667
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
irc.connect ( ( network, port ) )
irc.send ( 'NICK PyIRC\r\n' )
irc.send ( 'USER PyIRC PyIRC PyIRC :Python IRC\r\n' )
irc.send ( 'JOIN #pyirc\r\n' )
irc.send ( 'PRIVMSG #pyirc :Can you hear me?\r\n' )
irc.send ( 'PART #pyirc\r\n' )
irc.send ( 'QUIT\r\n' )
irc.close()

推荐答案

使用扭曲

Use Twisted or Asynchat if you want to have a sane design. It is possible to just do it with sockets but why bother doing it from scratch?

这篇关于IRC Python Bot:最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆