-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .extra import RedirectEnum, stats_builder | ||
from .server import handle_basic_response | ||
from .views import BasicButtons | ||
from .zmq_utils import server_url, bot_url # plaeholder for now proper methods soon. | ||
from .zmq_utils import bot_url, server_url # plaeholder for now proper methods soon. |
4e29e60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given your requirements, you want the server to both send data periodically in a structured format (e.g., JSON) and respond to specific requests for additional data about a particular user ID. The bot will listen for incoming data and can request further information by sending a user ID to the server. Here's an update to the code with these details incorporated:
Let's update the script with this functionality:
Key Modifications:
Make sure to fill in the
need_more_info()
function based on what actually determines the necessity for additional data in your application. Adjust data handling to your specific data format and business logic.(here's chatgpt's response it was weird using it)
4e29e60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the bot listens for incoming data from local port 5554
server sends new data to it(only on api endpoint)
the server listens for connections from port 5555
bot asks for data it needs if the user_id is not found
does this makes sense?
I am unsure how to use pyzmq for that tho
(this is the main thing)
4e29e60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bot listener -> receives new data for a user
It properly json.dumps the data
Bot receiver ->
Recives the dump and puts into bot.guild_data (should call that oauth data actually)
fixed (guild_data (weird name) to oauth_data):
872c13a
Server receiver:
Recives fetch request to get data(will see if it has the user id if so returns yes)
if not it returns a failed dictionary
also server will have a delete method to delete data if the user runs /clear-data
GuildInfoBotTool/cogs/commands.py
Line 109 in 872c13a
(this should be enough)
4e29e60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The chatgpt thing explains it fairly well though
4e29e60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Earlier chatgpt:
The provided example script creates an asynchronous ZeroMQ setup with PULL and PUSH sockets communicating over TCP port 5555. The script demonstrates an infinite loop where one coroutine (
sender
) sends timestamps to another coroutine (receiver
) over a local connection.To adapt this example to your specified requirements:
receiver
coroutine to listen on port 5554 for incoming data.sender
coroutine as is, with the server sending on port 5555.receiver
to request data if a specific user_id is not found.Here’s how you can modify your existing script to fit these requirements:
In this example, the
server_sender
function acts as the server sending regular updates via PUSH and listening for requests via PULL. Thebot_receiver
listens on port 5554 for incoming data and requests more data if necessary. Adjust thehandle_request
andrequest_data
functions to implement your specific logic regarding what data needs to be sent based on requests and user ID checks.Make sure that the overall architecture and flow align with your actual network conditions, data formats, and use case requirements.
4e29e60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the vaccum man (very spooky)
4e29e60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
app and bot must be in specific methods for proper lookups.
app.state.oauth_data -> server stuff
bot.oauth_data -> bot stuff
4e29e60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
4e29e60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
4e29e60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/zeromq/pyzmq/blob/acfcaf111b9253e621d53c6ca306e9225fb4061b/examples/asyncio/coroutines.py
This is the example.
4e29e60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also do not trust chatgpt but here it is providing a thing.