summaryrefslogtreecommitdiff
path: root/index.py
diff options
context:
space:
mode:
authorlittleblack111 <jerrylam110209@gmail.com>2023-08-30 21:25:16 +0800
committerlittleblack111 <jerrylam110209@gmail.com>2023-08-30 21:25:16 +0800
commit138f2cefa7118c0ae8abd5b38ebb203bea73c66e (patch)
treea45fa3b5846d121746759ce127fdb07a53956372 /index.py
parent4c4a43e638f86f8d8cb1c2ad364f3b619d61faec (diff)
init
Diffstat (limited to 'index.py')
-rw-r--r--index.py40
1 files changed, 35 insertions, 5 deletions
diff --git a/index.py b/index.py
index 45ae944..6f8118d 100644
--- a/index.py
+++ b/index.py
@@ -1,8 +1,38 @@
-from flask import Flask
-from main import main as rcommand
+from requests import get
+from time import sleep
-app = Flask(__name__)
+# Set up the necessary variables
+token = 'MTE0MDk5MjQ2NjU2MTAwNzYxNw.GRZ07p.dwkI7bttQzfqr17OHFw2p0eCYtIplJrJF0P1oo'
+user_id = ['898077475723161621', '912011643947479081']
+channel_id = '1140999625680101396'
+
+# Set the API endpoint
+url = f'https://discord.com/api/v9/channels/{channel_id}/messages'
+
+# Set the headers with the bot token for authentication
+headers = {'Authorization': f'Bot {token}'}
+
+old_message = ""
-@app.route("/")
def main():
- return rcommand()
+ global old_message
+ # Make the API request to fetch messages from the channel
+ response = get(url, headers=headers)
+
+ # Check if the request was successful (status code 200)
+ if response.status_code == 200:
+ messages = response.json()
+ # Process the user's messages
+ message = [message for message in messages if message['author']['id'] in user_id][0]['content']
+ if message != old_message:
+ return message
+ old_message = message
+ else:
+ sleep(1)
+ else:
+ return f'Error: {response.status_code} - {response.text}'
+
+if __name__ == "__main__":
+ while 1:
+ print(main())
+