Explorar o código

Initial commit

DeadTOm hai 3 días
pai
achega
7b1c768abe
Modificáronse 1 ficheiros con 32 adicións e 0 borrados
  1. 32 0
      nagbot.py

+ 32 - 0
nagbot.py

@@ -0,0 +1,32 @@
+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()