如何在Godaddy上运行python IRC bot?

时间:2017-12-22 16:58:06

标签: python shared-hosting irc

我有一个关于Godaddy(共享主机)的托管计划。我喜欢运行用python编写的IRC bot。

import platform
import random
import socket
import sys
from subprocess import call


reload(sys)
sys.setdefaultencoding('utf8')

server = "irc.freenode.net"
channel = "#PSN"
botnick = "MyBot"
sentUser = False
sentNick = False

irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "\nConnecting to:" + server
irc.connect((server, 6667))

try:
   while 1:
      text = irc.recv(2048)
      if len(text) > 0:
         print text
      else:
         continue

      if text.find("PING") != -1:
         irc.send("PONG " + text.split()[1] + "\n")

      if sentUser == False:
         irc.send("USER " + botnick + " " + botnick + " " + botnick + " :Official NeOnSec Bot\n")
         sentUser = True
         continue

      if sentUser and sentNick == False:
         irc.send("NICK " + botnick + "\n")
         sentNick = True
         continue

      if text.find("255 " + botnick) != -1:
         irc.send("JOIN " + channel + "\n")

      if text.find(":!host") != -1:
         irc.send("PRIVMSG " + channel + " :" + str(platform.platform()) + "\n")

except KeyboardInterrupt:
   irc.send("QUIT :I have to go for now!\n")
   print "\n"
   sys.exit()

不幸的是,当我使用ssh shell在我的服务器上运行它时,我收到此错误:

Connecting to:chat.freenode.net
Traceback (most recent call last):
  File "bot.py", line 19, in <module>
    irc.connect((server, 7000))
  File "<string>", line 1, in connect
socket.error: [Errno 111] Connection refused

我该如何解决这个问题?

0 个答案:

没有答案