import requests import json import sys import time import config def send_msg(msg): new_status = {'body': msg} headers = {'Authorization': f'Bearer {config.auth_bearer}'} response = requests.post(f'{config.api_url}/api/integrations/chat/send', data=json.dumps(new_status), headers=headers) return response.json() def main(): for nag in config.nags: print(f'Sending \"{nag}\"...') send_msg(nag) time.sleep(config.interval) # Wait between messages try: while True: main() time.sleep(config.interval) except KeyboardInterrupt: print('\nExiting program...') sys.exit() except Exception as error: print(f'\n{error}\n') sys.exit()