Guest User

Untitled

a guest
Jul 22nd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. from twisted.words.protocols import irc
  2. from twisted.internet import protocol, reactor
  3. import re
  4. import datetime
  5.  
  6. def startup():
  7. reactor.connectTCP("irc.freenode.net", 6667, botstarter())
  8. reactor.run()
  9.  
  10. class URLTracker(irc.IRCClient):
  11. nickname = "mwbot"
  12.  
  13. def getURL(self, message):
  14. if 'freenode.pl' in message:
  15. return True
  16. if 'we\\\'re' in message:
  17. return True
  18. if 'javascript based flood spam' in message:
  19. return True
  20.  
  21. def signedOn(self):
  22. self.join("#plone")
  23.  
  24. def connectionMade(self):
  25. irc.IRCClient.connectionMade(self)
  26.  
  27. def connectionLost(self, reason):
  28. irc.IRCClient.connectionLost(self, reason)
  29.  
  30. def privmsg(self, user, channel, msg):
  31. url = self.getURL(msg)
  32. if url:
  33. self.mode(channel, True, 'b', user=user)
  34.  
  35.  
  36. class botstarter(protocol.ClientFactory):
  37. protocol = URLTracker
  38.  
  39. def clientConnectionLost(self, connector, reason):
  40. connector.connect()
  41.  
  42. def clientConnectionFailed(self, connector, reason):
  43. print "Could not connect, %s" % (reason)
  44.  
  45. startup()
Add Comment
Please, Sign In to add comment