Skip to content

Instantly share code, notes, and snippets.

@brunsgaard
Created May 25, 2014 00:01
Show Gist options
  • Save brunsgaard/6c9d3f2c6dd344180430 to your computer and use it in GitHub Desktop.
Save brunsgaard/6c9d3f2c6dd344180430 to your computer and use it in GitHub Desktop.
from twisted.internet import reactor
from twisted.words.protocols import irc
from twisted.internet.protocol import ClientFactory
SERVER = "irc.freenode.net"
NICKNAME = 'the_username'
PASSWORD = 'password'
class Bot(irc.IRCClient):
nickname = NICKNAME
password = PASSWORD
def dataReceived(self, data):
print(data)
irc.IRCClient.dataReceived(self, data)
def signedOn(self):
print("\033[91m\n\nYOLO, I was signed on to the server!!!\n\033[0m")
self.quit()
def connectionLost(self, reason):
irc.IRCClient.connectionLost(self, reason)
reactor.stop()
class BotFactory(ClientFactory):
protocol = Bot
if __name__ == "__main__":
reactor.connectTCP(SERVER, 6667, BotFactory())
reactor.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment