Advertisement
Guest User

Untitled

a guest
Jan 21st, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. from twisted.words.protocols import irc
  2. from twisted.internet import reactor, protocol, defer
  3. from twisted.python import log
  4.  
  5. class BetBot(irc.IRCClient):
  6.  
  7. nickname = "INSERT YOUR TWITCH USERNAME"
  8. password = "oauth: GENERATE YOUR OAUTH TWITCH TOKEN SOMEWHERE"
  9.  
  10. def connectionMade(self):
  11. irc.IRCClient.connectionMade(self)
  12.  
  13. def connectionLost(self, reason):
  14. irc.IRCClient.connectionLost(self, reason)
  15.  
  16. def signedOn(self):
  17. print "Signed on"
  18. self.join(self.factory.channel)
  19.  
  20. def joined(self, channel):
  21. print "Joined " + channel
  22.  
  23. def privmsg(self, user, channel, msg):
  24. user = user.split('!', 1)[0]
  25.  
  26. def action(self, user, channel, msg):
  27. user = user.split('!', 1)[0]
  28. print user, msg
  29. if "Place your bets!" in msg:
  30. reply = "!bet combo 1%" # This is an example automatic bet - I like to bet only 1% to not get fucked by variance
  31. self.msg(channel, reply)
  32. print "Sent '" + reply + "' to " + channel
  33.  
  34.  
  35. class CobaltBetFactory(protocol.ClientFactory):
  36.  
  37. def __init__(self):
  38. self.channel = "#bot_cobalt"
  39.  
  40. def buildProtocol(self, addr):
  41. p = BetBot()
  42. p.factory = self
  43. return p
  44.  
  45. def clientConnectionLost(self, connector, reason):
  46. connector.connect()
  47.  
  48. def clientConnectionFailed(self, connector, reason):
  49. print "connection failed:", reason
  50. reactor.stop()
  51.  
  52.  
  53. if __name__ == '__main__':
  54. f = CobaltBetFactory()
  55. reactor.connectTCP("irc.twitch.tv", 6667, f)
  56. reactor.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement