emp hooks
Project description
Emp Hooks
Emp Hooks is a collection of hooks designed to work in conjunction with empctl. This library provides various hooks to handle events, schedules, and Twitter interactions.
Installation
To install Emp Hooks, use pip:
pip install emp-hooks
Usage
Onchain Hooks
Onchain hooks are used to listen for events on a specific blockchain.
from emp_hooks import onchain
@onchain.on_event(
event=V3SwapEvent,
network=Base,
)
def log_eth_price(event_data: EventData[V3SwapEventType]):
event = event_data.event
amount0 = event.amount0 / 1e18
amount1 = event.amount1 / 1e6
price = abs(amount1 / amount0)
log.debug("ETH Price: %s", price)
Scheduler Hooks
Scheduler hooks are used to schedule functions to run at a specific interval or cron schedule.
from emp_hooks import scheduler
@scheduler.on_schedule(
execution_frequency="0 0 * * *",
)
def periodic_function():
print("Do scheduled task")
Twitter Hooks
Twitter hooks are used to listen for tweets matching a specific query.
from emp_hooks import twitter
@twitter.on_tweet(
query="simmi_io",
)
def on_simmi_tweet(tweet: Tweet):
print(tweet)
Running Hooks
Make sure to import the manager and call run_forever on it.
This will ensure that all hooks are running indefinitely, and will handle the SIGINT and SIGTERM signals to stop the hooks gracefully.
from emp_hooks import manager
if __name__ == "__main__":
manager.hooks.run_forever()
Contributing
To contribute to Emp Hooks, please follow these steps:
- Fork the repository.
- Create a new branch for your changes.
- Make your changes and commit them.
- Push your changes to your fork.
- Create a pull request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file emp_hooks-0.0.10.tar.gz.
File metadata
- Download URL: emp_hooks-0.0.10.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.9 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cfc3095388f32aa4b5834a80a037159036c1841acfb8aa7349fe7cd8faca469
|
|
| MD5 |
2a70c6ed29a5a7902632e6128cf98010
|
|
| BLAKE2b-256 |
cb135da5825f159074eaa65ea46e94ea7d7cf9f63b2f2d4a4ad0c0301c4ce8bf
|
File details
Details for the file emp_hooks-0.0.10-py3-none-any.whl.
File metadata
- Download URL: emp_hooks-0.0.10-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.12.9 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7479b827a0533fc9cbdc3a3a0b2f8fb01dd46878b611ccd0c16153f62d567165
|
|
| MD5 |
8eee2d0a846252b5ba2c32fc1774ea26
|
|
| BLAKE2b-256 |
123a7062ca545a6bc0881909d5b47a23032095f3c40cf247d385ca7a227ce429
|