rendered paste bodyfrom twisted.words.protocols import irc
from twisted.internet import reactor, protocol
import time, sys, os
class NthMachine(irc.IRCClient):
nickname = 'NthMachine'
realname = 'NthDegree Bot'
channel = 'gNewSense'
def connectionMade(self): irc.IRCClient.connectionMade(self)
def connectionLost(self, reason):
irc.IRCClient.connectionLost(self, reason)
def signedOn(self): self.join(self.channel)
def privmsg(self, user, channel, msg):
user = user.split('!', 1)[0]
if channel == self.nickname:
msg = 'I dont respond to PMs'
self.msg(user, msg)
return
if msg.startswith('~'):
botfile = open("botchat.txt")
chatback = (botfile.readline() msg)
self.msg(channel, '%s try wiki.gnewsense.org/Help %s' % (user, msg[len(self.nickname + ':'):]))
return
if msg.startswith('~' + ''):
self.msg(channel, '%s try wiki.gnewsense.org/Help %s' % (user, msg[len(self.nickname + ':'):]))
return
class NthMachineFactory(protocol.ClientFactory):
protocol = NthMachine
def __init__(self): pass
def clientConnectionLost(self, connector, reason): connector.connect()
def clientConnectionFailed(self, connector, reason): reactor.stop()
if __name__ == '__main__':
f = NthMachineFactory()
reactor.connectTCP('chat.eu.freenode.net', 6667, f)
reactor.run()