Skip to main content

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.

Metadata

Release files for emp_hooks 0.0.12.post2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for emp_hooks 0.0.12.post2
File Size Uploaded
emp_hooks-0.0.12.post2.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for emp_hooks 0.0.12.post2
File Interpreter ABI Platform
emp_hooks-0.0.12.post2-py3-none-any.whl Python 3 none any Details

Total release size: 27.3 kB

Release files / emp_hooks-0.0.12.post2.tar.gz

Download URL emp_hooks-0.0.12.post2.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
508abaf36145ec2e8523ac3e145670ad33dd9ac8c04622f620bb9a97957a7165
BLAKE2b-256 checksum
How to use checksums
0a2e619cb226470755cde505a6b1ed1778d137edc4f27c1cc0f69f552d5fa9e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.10 Linux/6.11.0-1013-azure

Release files / emp_hooks-0.0.12.post2-py3-none-any.whl

Download URL emp_hooks-0.0.12.post2-py3-none-any.whl
Size 17.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f95ecdfc0fa733fd7720674b8c3d1c372e4f06ca75e3aff9d3dd43400a041063
BLAKE2b-256 checksum
How to use checksums
388eec013a2d69e30e2fd4b59a08ac4ba74a2910b7afcfaf74db53fe9ab2c983
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.12.10 Linux/6.11.0-1013-azure

Release history Release notifications | RSS feed

This release

0.0.12.post2 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page