|
@@ -10,12 +10,12 @@ import os
|
|
logging.basicConfig(filename=config.log_file, level=logging.INFO)
|
|
logging.basicConfig(filename=config.log_file, level=logging.INFO)
|
|
|
|
|
|
|
|
|
|
-def get_now(): # This creates and returns a time stamp
|
|
|
|
|
|
+def get_now(): # This creates a timestamp for the log
|
|
now = str(time.strftime("%Y/%m/%d %H:%M:%S"))
|
|
now = str(time.strftime("%Y/%m/%d %H:%M:%S"))
|
|
return now
|
|
return now
|
|
|
|
|
|
|
|
|
|
-def send_ownchat(msg):
|
|
|
|
|
|
+def send_ownchat(msg): # Sends the message to Owncast chat
|
|
msg_body = {'body': msg}
|
|
msg_body = {'body': msg}
|
|
headers = {'Authorization': config.auth_bearer}
|
|
headers = {'Authorization': config.auth_bearer}
|
|
response = requests.post(f'{config.api_url}/api/integrations/chat/send', data=json.dumps(msg_body),
|
|
response = requests.post(f'{config.api_url}/api/integrations/chat/send', data=json.dumps(msg_body),
|
|
@@ -23,7 +23,7 @@ def send_ownchat(msg):
|
|
return response.json()
|
|
return response.json()
|
|
|
|
|
|
|
|
|
|
-class CommandBot(ClientXMPP):
|
|
|
|
|
|
+class CommandBot(ClientXMPP): # The XMPP bot
|
|
|
|
|
|
def __init__(self, jid, password):
|
|
def __init__(self, jid, password):
|
|
ClientXMPP.__init__(self, jid, password)
|
|
ClientXMPP.__init__(self, jid, password)
|
|
@@ -45,7 +45,7 @@ class CommandBot(ClientXMPP):
|
|
if msg['type'] in ('chat', 'normal'):
|
|
if msg['type'] in ('chat', 'normal'):
|
|
self.msg = msg
|
|
self.msg = msg
|
|
self.cmd = self.msg['body'] # Get the body out of the message
|
|
self.cmd = self.msg['body'] # Get the body out of the message
|
|
- self.cmd = self.cmd.lower() # Convert it to lower case to avoid problems looking up available commands
|
|
|
|
|
|
+ self.cmd = self.cmd.lower()
|
|
self.sender = self.msg['from'] # Get sender
|
|
self.sender = self.msg['from'] # Get sender
|
|
self.sender = str(self.sender) # Convert to string so split() can work with it
|
|
self.sender = str(self.sender) # Convert to string so split() can work with it
|
|
self.sender = self.sender.split('/')[0] # Only save the information before the forward slash
|
|
self.sender = self.sender.split('/')[0] # Only save the information before the forward slash
|