bot.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/usr/bin/python3
  2. import pymumble_py3
  3. import time
  4. import subprocess
  5. import argparse
  6. import re
  7. import os.path
  8. from classfile import *
  9. from tkinter import *
  10. '''
  11. parser = argparse.ArgumentParser(description='Interactive command line bot for mumble')
  12. parser.add_argument('--url', metavar='mumble://example:42069', required=True, help='A url to the mumble server')
  13. parser.add_argument('--name', metavar="BotName", dest='name', required=True, help='name of the bot')
  14. args = parser.parse_args()
  15. s1 = args.url
  16. # parse url
  17. host = re.search('mumble://.{3,250}\.[a-z0-9]{2,5}(:|/|\?)',s1).group(0)[:len(host)-1].replace('mumble://','')
  18. port = 64738
  19. if re.search(':[0-9]{4,5}', s1):
  20. port = re.search('[0-9]{4,5}', s1).group(0)
  21. print("DEBUG: " + str(host))
  22. print("DEBUG: " + str(port))
  23. x = IffyAh(host, port, "cert.pem", "key.pem", args.name)
  24. #x.move_into_every_channel()
  25. def report_server(x):
  26. x.print_user_names()
  27. x.count_channels()
  28. report_server(x)
  29. while True:
  30. tmp = subprocess.call('clear',shell=True)
  31. print()
  32. print("------------------------------------")
  33. print("0: Move into channel with most users")
  34. print("1: Move into every channel")
  35. print("2: Move into random channel")
  36. print("3: Print channel names")
  37. print("4: Print user names")
  38. print("5: Play file")
  39. print("6: Play file stick on users")
  40. print("7: Send global message")
  41. print("8: Robot voice")
  42. print("9: Play classy")
  43. print("99: Quit")
  44. print("------------------------------------")
  45. try:
  46. i = int(input("(select options 0-99)-> "))
  47. except:
  48. i = 90000
  49. if i == 99:
  50. del x
  51. break
  52. if i == 0: x.move_into_most_users_channel()
  53. if i == 1: x.move_into_every_channel(); print("starting long running command...")
  54. if i == 2: x.move_into_random_channel()
  55. if i == 3: x.print_channel_names(); input("press enter to continue")
  56. if i == 4: x.print_user_names()
  57. if i == 5: x.play_file("./audio/grilly.wav")
  58. if i == 6: x.play_file_stick_on_users("./audio/grilly.wav")
  59. if i == 9: x.play_file_stick_on_users("./audio/classy-ad.wav")
  60. if i == 7: x.send_global_message(input("ENTER MESSAGE > "))
  61. if i == 8: voice_text = input("ENTER VOICE MESSAGE > ")
  62. pass
  63. '''
  64. HOST=""
  65. PORT=""
  66. def clicked():
  67. s1 = "Welcome to " + txt1.get()
  68. host = re.search('mumble://.{3,250}\.[a-z0-9]{2,5}(:|/|\?)',s1).group(0)
  69. host = host[:len(host)-1].replace('mumble://','')
  70. port = 64738
  71. if re.search(':[0-9]{4,5}', s1):
  72. port = re.search('[0-9]{4,5}', s1).group(0)
  73. lbl1.configure(text=host)
  74. lbl2.configure(text=str(port))
  75. HOST=host
  76. PORT=port
  77. def connectMumble():
  78. x = IffyAh(lbl1.cget("text"), lbl2.cget("text"), "cert.pem", "key.pem", "DEFAULT")
  79. def report_server(x):
  80. x.print_user_names()
  81. x.count_channels()
  82. report_server(x)
  83. x.m.dc()
  84. window = Tk()
  85. window.title("Mumble Tester")
  86. window.geometry('850x600')
  87. lbl1 = Label(window, text="", font=("Arial Bold", 15))
  88. lbl2 = Label(window, text="", font=("Arial Bold", 15))
  89. txt1 = Entry(window,width=70, font=("Arial Bold", 15))
  90. txt2 = Entry(window,width=10, font=("Arial Bold", 15))
  91. btn = Button(window, text="Click Me", command=clicked, font=("Arial Bold", 15))
  92. connect = Button(window, text="Connect", command=connectMumble, font=("Arial Bold", 15))
  93. btn.grid(column=0, row=0)
  94. lbl1.grid(column=0, row=1)
  95. lbl2.grid(column=0, row=2)
  96. txt1.grid(column=0, row=3)
  97. connect.grid(column=0, row=4)
  98. window.mainloop()