Advertisement
pendekar_langit

root-me-programing-1

Jun 23rd, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.52 KB | None | 0 0
  1. import sys
  2. import socket
  3. import string
  4. import random
  5. import time
  6. import math
  7.  
  8. HOST="irc.root-me.org"
  9. PORT=6667
  10. CHAT_MATE="Candy"
  11. NICK="pendekar_langit_bot"
  12. IDENT="pendekar_langit_bot"
  13. REALNAME="pendekar_langit_bot"
  14. JOIN="#root-me_challenge"
  15. readbuffer=""
  16. challenge = ""
  17.  
  18. s=socket.socket( )
  19. s.connect((HOST, PORT))
  20. time.sleep(3)
  21. s.send("NICK %s\r\n" % NICK)
  22. time.sleep(3)
  23. s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
  24. time.sleep(3)
  25. s.send("JOIN %s\r\n" % JOIN)
  26. # time.sleep(3)
  27. # s.send("PRIVMSG %s :testing my bot" % JOIN)
  28. time.sleep(3)
  29. s.send("PRIVMSG %s :%s\r\n" % (CHAT_MATE, "!ep1"))
  30. time.sleep(1)
  31.  
  32. while 1:
  33.     readbuffer=readbuffer+s.recv(1024)
  34.     temp=string.split(readbuffer, "\n")
  35.     print temp
  36.     readbuffer=temp.pop( )
  37.  
  38.     for line in temp:
  39.         line=string.rstrip(line)
  40.         line=string.split(line)
  41.         print line
  42.         message = line[len(line)-3]+line[len(line)-2]+line[len(line)-1]
  43.         if(message[:1] == ":"):
  44.             message = message[1:]
  45.         client = line[0]
  46.         if(client[:1] == ":"):
  47.             client = client[1:]
  48.             client = client.split("!")
  49.             client = client[0]
  50.         print client
  51.         print message
  52.         if(client == CHAT_MATE):
  53.           var_1 = message.split("/")[0]
  54.           var_2 = message.split("/")[1]
  55.           hasil = math.pow(float(var_1), 1) * math.pow(float(var_2), 2)
  56.           print "PRIVMSG %s :%s\r\n" % (client, int(hasil))
  57.           s.send("PRIVMSG %s :!ep1 -rep %s\r\n" % (client, int(hasil)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement