Skip to content

Instantly share code, notes, and snippets.

@sheki
Created July 9, 2011 17:59
Show Gist options
  • Save sheki/1073803 to your computer and use it in GitHub Desktop.
Save sheki/1073803 to your computer and use it in GitHub Desktop.
A sample IRC file.
from twisted.words.protocols import irc
from twisted.internet import protocol
import sys
from twisted.internet import reactor , ssl
class MomBot(irc.IRCClient):
def _get_nickname(self):
return self.factory.nickname
nickname = property(_get_nickname)
def signedOn(self):
self.join(self.factory.channel)
print "Signed on as %s." % (self.nickname,)
def joined(self, channel):
print "Joined %s." % (channel,)
def privmsg(self, user, channel, msg):
print msg
class MomBotFactory(protocol.ClientFactory):
protocol = MomBot
def __init__(self, channel, nickname='YourMomDotCom',username="abhishekk",password):
self.channel = channel
self.nickname = nickname
self.username = username
self.password = password
def clientConnectionLost(self, connector, reason):
print "Lost connection (%s), reconnecting." % (reason,)
connector.connect()
def clientConnectionFailed(self, connector, reason):
print "Could not connect: %s" % (reason,)
if __name__ == "__main__":
chan = sys.argv[1]
reactor.connectSSL('irc.corp.flipkart.com', 6667, MomBotFactory('#' + chan,nickname='abhishekk'),ssl.ClientContextFactory(),password=sys.argv[2])
reactor.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment