Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: UTF-8 -*-
- from twisted.words.protocols import irc
- from twisted.internet import reactor, protocol
- from twisted.python import log
- class ircclient(irc.IRCClient):
- #Nick
- nickname = "cj"
- #Real name
- realname = "Carl Johnson"
- #Username
- username = "carl"
- ##Nickserv password
- #password = "NONE"
- #CTCP VERSION reply
- versionName = "GSF test"
- def signedOn(self):
- self.join(self.factory.channel)
- def privmsg(self, user, channel, msg):
- hostmask = user
- nick = user.split('!', 1)[0]
- parts = msg.split(' ')
- if (list(parts[0])[0] == '!'):
- command = ''.join(list(parts[0])[1:])
- try:
- method = getattr(self, ('cmd_' + command))
- print method
- method(self, hostmask, nick, parts, channel)
- except NameError, AttributeError:
- print "Error ocurred while trying to run %s" % ('cmd_' + command)
- pass
- def cmd_ascii(self, irc, hostmask, nick, parts, channel):
- #if args[1].find('..\\') == True:
- #self.msg(channel, 'NOPE.')
- #else:
- text = open('C:\\Users\\j\\Desktop\\python\\irc\\a\\%s.txt' % parts[1], 'r')
- for line in text:
- line = line[0:len(line)-1]
- irc.msg(channel, line)
- class ircprotocol(protocol.ClientFactory):
- protocol = ircclient
- def __init__(self, channel):
- self.channel = channel
- def clientConnectionLost(self, connector, reason):
- connector.connect()
- def clientConnectionFailed(self, connector, reason):
- print "connection failed:", reason
- reactor.start()
- if __name__ == '__main__':
- f = ircprotocol("#bzb")
- reactor.connectTCP("irc.gorf.us", 6667, f)
- reactor.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement