Skip to main content

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:

  1. Fork the repository.
  2. Create a new branch for your changes.
  3. Make your changes and commit them.
  4. Push your changes to your fork.
  5. Create a pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

emp_hooks-0.0.8.post1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

emp_hooks-0.0.8.post1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file emp_hooks-0.0.8.post1.tar.gz.

File metadata

  • Download URL: emp_hooks-0.0.8.post1.tar.gz
  • Upload date:
  • Size: 9.5 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

Hashes for emp_hooks-0.0.8.post1.tar.gz
Algorithm Hash digest
SHA256 977c68c92a34070c0d9787add95b6150cd625f726805e6f9deff7539e53e584c
MD5 88b39237df119e1eba0ca0f02adc25a9
BLAKE2b-256 822b8fc4057de9f198c23740f77634d3b2235dfccdd32735b271203a4990cb0b

See more details on using hashes here.

File details

Details for the file emp_hooks-0.0.8.post1-py3-none-any.whl.

File metadata

  • Download URL: emp_hooks-0.0.8.post1-py3-none-any.whl
  • Upload date:
  • Size: 16.5 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

Hashes for emp_hooks-0.0.8.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 d40a7eaa3162d06fd0240670b77f88ac42d0d9ac0c130730c3594f56944d4b63
MD5 c1c510a9afdb714632692e2f29257986
BLAKE2b-256 9b3a76df433bfb80215ef6ad19e7456f69067353d2088ba17bfa43e9fc1894ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page