Advertisement
WayGroovy

jibbajabba.py 1.2

Jul 9th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #/usr/bin/env python
  2.  
  3. import random
  4. import sys
  5. import markovgen
  6. import string
  7. import os
  8. from time import sleep
  9.  
  10. def is_punct_char(char):
  11. return char in string.punctuation
  12.  
  13. def is_not_punct_char(char):
  14. return not is_punct_char(char)
  15.  
  16. def randfile(path):
  17. return random.choice(os.listdir(path))
  18.  
  19. sleep(random.randint(20,120))
  20.  
  21. n = random.randint(5,20)
  22.  
  23. counter = 1
  24.  
  25. while counter <= n :
  26. path = '/home/minecraft/McMyAdmin2/Exec/eBooks/'
  27. filename = randfile(path)
  28. pathfile = path
  29. pathfile += filename
  30. file_ = open(pathfile)
  31. # from http://agiliq.com/blog/2009/06/generating-pseudo-random-text-with-markov-chains-u/
  32. markov = markovgen.Markov(file_)
  33. sentence = markov.generate_markov_text().capitalize().replace("\"","\\\'")
  34. senlen = len(sentence)
  35. if is_not_punct_char(sentence[senlen - 1]) :
  36. sentence += '.'
  37. command_sayrandom = "screen -S McMyAdmin -p 0 -X stuff \"$(printf \"say "
  38. command_sayrandom += sentence
  39. command_sayrandom += " \\r\\n\")\""
  40. os.system(command_sayrandom)
  41. counter += 1
  42. sleep (random.randint(30,120))
  43.  
  44. print "done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement