2
我試圖導入該文件導入腳本到另一個腳本
到這個文件
def MainLoop(self): #MainLoop is used to make the commands executable ie !google !say etc;
try:
while True:
# This method sends a ping to the server and if it pings it will send a pong back
#in other clients they keep receiving till they have a complete line however mine does not as of right now
#The PING command is used to test the presence of an active client or
#server at the other end of the connection. Servers send a PING
#message at regular intervals if no other activity detected coming
#from a connection. If a connection fails to respond to a PING
#message within a set amount of time, that connection is closed. A
#PING message MAY be sent even if the connection is active.
#PONG message is a reply to PING message. If parameter <server2> is
#given, this message will be forwarded to given target. The <server>
#parameter is the name of the entity who has responded to PING message
#and generated this message.
self.data = self.irc.recv(4096)
print self.data
if self.data.find ('PING') != -1:
self.irc.send(("PONG %s \r\n") % (self.data.split() [ 1 ])) #Possible overflow problem
if "!chat" in self.data:
.....
所以,我可以成功地在導入的文件調用(ipibot)每當 self.data中的'!chat':被調用。
但我不知道如何寫它。這是我迄今爲止
if "!chat" in self.data:
user = ipibot.ipibot()
user.respond
我想聲明我已經採取了看的Python模塊部分以及作爲進口我似乎就是無法抓住它,我猜?
文件 - >類 - >功能是我所理解的。
yes但是我需要它運行在IRC上它只能運行在IDLE – 21days 2011-01-25 03:33:46