Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to register behavior on bot startup #132

Closed
unode opened this issue Jul 30, 2020 · 2 comments
Closed

How to register behavior on bot startup #132

unode opened this issue Jul 30, 2020 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested

Comments

@unode
Copy link
Collaborator

unode commented Jul 30, 2020

The plugin initialization code calls the on_init() function, if it exists, but since no arguments are passed, there's no context to send a message or connection to access.

What is the recommended way to send or queue a message to be sent to a specific channel or user?

I'd like to register behavior that is initiated by the bot instead of as a response to @listen_to or @respond_to.
For instance, sending a message when the bot first starts, send a notification, etc.

@attzonko
Copy link
Owner

Great question. The only way I can think of today to possibly do what you ask is to use the scheduling functionality that was added. I am not 100% sure it will meet your needs, but it has the potential.

@attzonko attzonko added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested labels Jul 31, 2020
@unode
Copy link
Collaborator Author

unode commented Aug 1, 2020

I tried using the schedule code and it works but I couldn't figure out how to access the connection object.
Is there some global that can be used and is properly initialized by the time the scheduler runs the first time?

unode added a commit to unode/mmpy_bot that referenced this issue Aug 12, 2020
unode added a commit to unode/mmpy_bot that referenced this issue Aug 13, 2020
unode added a commit to unode/mmpy_bot that referenced this issue Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants