summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <jerrylam110209@gmail.com>2023-08-15 21:39:13 +0800
committerlittleblack111 <jerrylam110209@gmail.com>2023-08-15 21:40:15 +0800
commit8b287fb77abf0da54de387fcebf67ca7daa5c6c3 (patch)
treea0e24fe46c770bc5ec1d57b2e64cba66c30e807f
parent88a940f35d5a4d88050e7b9e5073f3514c5d44d0 (diff)
updated
-rw-r--r--__pycache__/index.cpython-311.pycbin0 -> 576 bytes
-rw-r--r--__pycache__/main.cpython-311.pycbin0 -> 1626 bytes
-rw-r--r--index.py8
-rw-r--r--main.py38
-rw-r--r--test.py2
5 files changed, 48 insertions, 0 deletions
diff --git a/__pycache__/index.cpython-311.pyc b/__pycache__/index.cpython-311.pyc
new file mode 100644
index 0000000..b5b9acd
--- /dev/null
+++ b/__pycache__/index.cpython-311.pyc
Binary files differ
diff --git a/__pycache__/main.cpython-311.pyc b/__pycache__/main.cpython-311.pyc
new file mode 100644
index 0000000..815e977
--- /dev/null
+++ b/__pycache__/main.cpython-311.pyc
Binary files differ
diff --git a/index.py b/index.py
new file mode 100644
index 0000000..9e12c53
--- /dev/null
+++ b/index.py
@@ -0,0 +1,8 @@
+from flask import Flask
+from main import main as rcommand
+
+app = Flask(__name__)
+
+@app.route("/")
+def main():
+ return f"<p>{rcommand()}</p>"
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..6f8118d
--- /dev/null
+++ b/main.py
@@ -0,0 +1,38 @@
+from requests import get
+from time import sleep
+
+# 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 = ""
+
+def main():
+ 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())
+
diff --git a/test.py b/test.py
new file mode 100644
index 0000000..0e2546d
--- /dev/null
+++ b/test.py
@@ -0,0 +1,2 @@
+from main import main as a
+print(a())