Skip to content

Instantly share code, notes, and snippets.

@InNoobWeTrust
Created April 22, 2020 20:32
Show Gist options
  • Save InNoobWeTrust/264a647cd697cf5969844d714811e1b3 to your computer and use it in GitHub Desktop.
Save InNoobWeTrust/264a647cd697cf5969844d714811e1b3 to your computer and use it in GitHub Desktop.
Small script to automate the process of adding users to a specific group in MsTeams. Why not use "PowerShell Module for Teams"? Because it's suck with the reliability, can't wait hours or days for teams client to sync the changes 😫
#!/usr/bin/env python
import os
import sys
import time
import pyautogui as gui
def loading_line(iteration=1, message='Running...'):
loading_symbols = ['|', '/', '-', '\\', '|', '/', '-', '\\']
print(f'{loading_symbols[iteration % len(loading_symbols)]} {message}')
def delay_load(delay=2.0, message="Waiting..."):
time_per_frame = 1.0 / 8.0
delay = float(delay)
wait_time = 0.0
print()
for i in range(int(delay / time_per_frame)):
sys.stdout.write("\033[F")
sys.stdout.write("\033[K")
wait_time += time_per_frame
loading_line(iteration=i, message=f'{message} ({wait_time}s)')
time.sleep(time_per_frame)
print()
data = input("Path to data file: ")
if not os.path.isfile(data):
print(f'Error! {data} is not a file')
sys.exit(-1)
with open(data, 'rt') as f:
content = f.read().splitlines()
print('Point mouse to input box but not giving it the focus')
input('Press Enter to continue...')
input_box = gui.position()
print(f'Mouse position: {input_box}')
delay = float(input('Delay between adding users: '))
wait_time = float(input('Wait time for matching user to appear: '))
delay_load(delay=2.0, message='Starting...')
gui.click(input_box)
for i, line in enumerate(content):
gui.typewrite(line)
time.sleep(wait_time)
gui.typewrite(['down', ])
time.sleep(0.1)
gui.typewrite(['enter', ])
delay_load(delay=delay, message=line)
print('Finished!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment