Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.10 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. #----------------------------------------------------------
  4. #This script bypasses the idle time crap on Mortal Realms.
  5. #
  6. #The original closed source version was written around 1993.
  7. #
  8. #The script starts in non-interactive mode (aka bot mode).
  9. #Press ctrl-c to get into interactive mode and 'esc ^]' to
  10. #get back into non-interactive mode.
  11. #
  12. #And now a few comments...
  13. #
  14. #a)The script only works on the Linux Operating System.
  15. #  This is because the program relies on the concept of
  16. #  "psuedo terminal". As far as I know, the closest you
  17. #  can get to a "psuedo terminal" in Windows is using something
  18. #  like cygwin.
  19. #
  20. #b)Using something like 'esc ^]' to get back into non-interactive
  21. #  mode is something that is mentioned python pexpect module,
  22. #  but not in the actual pexpect document itself.
  23. #
  24. #c)I send the 'return key' every 20 second in non-interactive-mode
  25. #  because I can't figure how how to make the pexpect 'timeout value'
  26. #  play nicely with the Mortal Realms game site 'timeout value'. This
  27. #  shouldn't be an issue since call to read() gets blocked the other 19
  28. #  seconds, and hence, isn't jacking up the CPU usage (on either side
  29. #  of the connection).
  30. #---------------------------------------------------------
  31.  
  32. import pexpect, time, signal, getpass
  33.  
  34. x = 1
  35.  
  36. def mode(sig, data):
  37.     global x
  38.     x = x + 1
  39.    
  40. def get_name():
  41.     user = raw_input("Username: ")
  42.     password = getpass.getpass("Password: ")
  43.     idle(user,password)
  44.    
  45. def idle(user,password):
  46.     y = 1
  47.    
  48.     mud = pexpect.spawn('telnet game.mortalrealms.com 4321')
  49.     mud.expect('Who art thou:')
  50.     mud.sendline(user)
  51.     print mud.before,mud.after,
  52.     mud.expect('Password:')
  53.     mud.sendline(password)
  54.     mud.expect('Press return to continue:')
  55.     mud.sendline('\n')
  56.     print mud.before, mud.after,
  57.          
  58.     while mud.isalive():
  59.         if ((y % x ) == 0):
  60.             mud.sendline('\n')
  61.             time.sleep(20)
  62.         else:
  63.             mud.interact()
  64.             y = y + 1
  65.    
  66. if __name__ == "__main__":
  67.     signal.signal(signal.SIGINT, mode)
  68.     get_name()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement