Guest User

Untitled

a guest
Oct 20th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: UTF-8 -*-
  3.  
  4. from twisted.words.protocols import irc
  5. from twisted.internet import reactor, protocol
  6. from twisted.python import log
  7. from twisted.python.util import InsensitiveDict as IDict
  8. import re, random, time
  9.  
  10.  
  11. class ircclient(irc.IRCClient):
  12. #Nick
  13. nickname = "cj"
  14. #Real name
  15. realname = "Carl Johnson"
  16. #Username
  17. username = "carl"
  18. ##Nickserv password
  19. #password = "NONE"
  20. #CTCP VERSION reply
  21. versionName = "GSF"
  22. def signedOn(self):
  23. self.join(self.factory.channel)
  24. def privmsg(self, user, channel, msg):
  25. user = user.split('!', 1)[0]
  26. if msg.startswith('!ascii '):
  27. ascii = msg.split()
  28. text = open('/home/anthony/a/%s.txt' % ascii[1], 'r')
  29. for line in text:
  30. line = line[0:len(line)-1]
  31. self.msg(channel, line)
  32.  
  33. elif msg.startswith('!wavy '):
  34. incrementing = True
  35. x = 0
  36. ascii = msg.split()
  37. text = open('/home/anthony/a/%s.txt' % ascii[1], 'r')
  38. for line in text:
  39. self.msg(channel, ' '*x + line)
  40. if incrementing:
  41. x+=1
  42. if x == 10:
  43. incrementing = False
  44. else:
  45. x-=1
  46. if x == 0:
  47. incrementing = True
  48.  
  49. elif msg.startswith('!color '):
  50. ascii = msg.split()
  51. derp = ''
  52. derp = str(random.randint(0,9))
  53. text = open('/home/anthony/a/%s.txt' % ascii[1], 'r')
  54. for line in text:
  55. line = line.replace(ascii[2], derp)
  56. self.msg(channel, line)
  57.  
  58. elif msg.startswith('!sex'):
  59. self.msg(channel, 'NO THATS GROSS')
  60.  
  61. if msg.startswith('!fb'):
  62. x = 0
  63. for user in range(6):
  64. self.msg(channel, 'hey ' + user)
  65. x+=1
  66.  
  67. class ircprotocol(protocol.ClientFactory):
  68. protocol = ircclient
  69.  
  70. def __init__(self, channel):
  71. self.channel = channel
  72. def clientConnectionLost(self, connector, reason):
  73. connector.connect()
  74. def clientConnectionFailed(self, connector, reason):
  75. print "connection failed:", reason
  76. reactor.start()
  77. if __name__ == '__main__':
  78. f = dittoprotocol("#grove")
  79. reactor.connectTCP("irc.gorf.us", 6667, f)
  80. reactor.run()
Add Comment
Please, Sign In to add comment