Skip to content

Instantly share code, notes, and snippets.

@Gamer92000
Created September 11, 2020 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gamer92000/da21178e8d2029d2768429ad1e6e9389 to your computer and use it in GitHub Desktop.
Save Gamer92000/da21178e8d2029d2768429ad1e6e9389 to your computer and use it in GitHub Desktop.
from telnetlib import Telnet
from time import sleep
import signal
teamSpeakClientQueryPort = 25639
apiKey = "" # set this!
telnet = Telnet('localhost', teamSpeakClientQueryPort)
name = ""
running = True
direction = 0 # 0 = left, 1 = right
def animate(name, i, maX):
hidden_space = len(name)
asci = " "
after_ascis = maX - i + len(name)
before_ascis = i
full_length = after_ascis + before_ascis
if i > full_length:
i = i - i//full_length * full_length - 1
if i < 0:
i = i - i//full_length * full_length + full_length - 1
for n in range(after_ascis + 1):
name += asci
for n in range(before_ascis + 1):
name = asci + name
return name[hidden_space:hidden_space + maX]
def getName():
telnet.write(b"whoami\n")
clid = dict(item.split("=") for item in telnet.read_until(b"\n").decode("ASCII").split())['clid']
telnet.write(f"clientvariable clid={clid} client_nickname\n".encode("ASCII"))
telnet.read_until(b"\n")
name = dict(item.split("=") for item in telnet.read_until(b"\n").decode("ASCII").split())['client_nickname']
return name
def authenticate():
telnet.write(b"auth apikey=" + apiKey.encode("ASCII") + b"\n")
telnet.read_until(b"\n")
def main():
global name
for _ in range(4):
telnet.read_until(b"\n")
authenticate()
name = getName()
n = 0
maxN = 28
while running:
nam = animate(name, n, maxN).replace(" ", "\s")
telnet.write(f"clientupdate client_nickname=!\s{nam} \n".encode("ASCII"))
if direction:
n += 1
n %= maxN
if not direction:
n -= 1
if n < 0: n=maxN
sleep(.2)
def reset(signum, frame):
global running
running = False
sleep(.1)
telnet.write(f"clientupdate client_nickname={name}\n".encode("ASCII"))
if __name__ == "__main__":
signal.signal(signal.SIGINT, reset)
signal.signal(signal.SIGTERM, reset)
main()
telnet.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment