Paste Code
Paste Blends
Paste Images
#!/usr/bin/env python
import sys
import telnetlib
import re

HOST = "wettbewerb.linux-magazin.de"
PORT = "3333"

tn = telnetlib.Telnet(HOST,PORT)
print tn.read_until("\n")
tn.write("AUTH zahlenzerkleinerer.de auf gehts!\n")
dran = re.compile(".*Du bist dran!.*")
win = re.compile("WIN ([0-9]{1,2}) ([0-9]{1,2}) (.*)")
loo = re.compile("DEF ([0-9]{1,2}) ([0-9]{1,2}) (.*)")
switchIt = 0
play = True
while play:
line = tn.read_until("\n")
print line
if dran.search(line):
if switchIt > 4:
tn.write("SAVE sicher ist sicher\n")
switchIt = 0
else:
tn.write("ROLL weiter geht es\n")
switchIt += 1
if win.match(line):
print "GEWONNEN"
print "mit %s zu %s"%(win.match(line).group(1),win.match(line).group(2))
#tn.write("exit\n") nicht noetig da der Server die Verbindung beendet
play = False
if loo.match(line):
print "VERLOREN"
print "mit %s zu %s"%(loo.match(line).group(1),loo.match(line).group(2))
#tn.write("exit\n")
play = False
  1. #!/usr/bin/env python
  2. import sys
  3. import telnetlib
  4. import re
  5.  
  6. HOST = "wettbewerb.linux-magazin.de"
  7. PORT = "3333"
  8.  
  9. tn = telnetlib.Telnet(HOST,PORT)
  10. print tn.read_until("\n")
  11. tn.write("AUTH zahlenzerkleinerer.de auf gehts!\n")
  12. dran = re.compile(".*Du bist dran!.*")
  13. win = re.compile("WIN ([0-9]{1,2}) ([0-9]{1,2}) (.*)")
  14. loo = re.compile("DEF ([0-9]{1,2}) ([0-9]{1,2}) (.*)")
  15. switchIt = 0
  16. play = True
  17. while play:
  18.         line = tn.read_until("\n")
  19.         print line
  20.         if dran.search(line):
  21.                 if switchIt > 4:
  22.                         tn.write("SAVE sicher ist sicher\n")
  23.                         switchIt = 0
  24.                 else:
  25.                         tn.write("ROLL weiter geht es\n")
  26.                         switchIt += 1
  27.         if win.match(line):
  28.                 print "GEWONNEN"
  29.                 print "mit %s zu %s"%(win.match(line).group(1),win.match(line).group(2))
  30.                 #tn.write("exit\n") nicht noetig da der Server die Verbindung beendet
  31.                 play = False
  32.         if loo.match(line):
  33.                 print "VERLOREN"
  34.                 print "mit %s zu %s"%(loo.match(line).group(1),loo.match(line).group(2))
  35.                 #tn.write("exit\n")
  36.                 play = False
  37.  
go to heaven