numberoverzero / bottom

asyncio-based rfc2812-compliant IRC Client
http://bottom-docs.readthedocs.io
MIT License
74 stars 23 forks source link

Send raw messages #42

Closed numberoverzero closed 7 years ago

numberoverzero commented 7 years ago

2.1.0: Client supports two new methods, roughly analogous to send and trigger respectively:

Additionally, there is now a public attribute raw_handlers which is a list of asynchronous functions to invoke during handle_raw. The first function is invoked with the original message and a reference to the next handler; it has full control to send a different message, or not call the next handler at all.

The simplest handler would be:

async def passthrough(next_handler, message):
    await next_handler(message)

The docs include more complex examples, such as transparently redirecting the message on privmsg, or base64 decoding and decrypting messages before passing them to the underlying rfc2812 handler.

By default, Client instances start with an rfc2812 handler. Because Client.raw_handlers is just a list, it can be removed or cleared. Handler order is significant.

Other changes:

codecov[bot] commented 7 years ago

Codecov Report

Merging #42 into master will increase coverage by 0.53%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #42      +/-   ##
==========================================
+ Coverage   98.77%   99.31%   +0.53%     
==========================================
  Files           5        5              
  Lines         409      436      +27     
  Branches      119      119              
==========================================
+ Hits          404      433      +29     
+ Misses          3        2       -1     
+ Partials        2        1       -1
Impacted Files Coverage Δ
bottom/protocol.py 94.59% <100%> (+3.48%) :arrow_up:
bottom/client.py 98.94% <100%> (+0.58%) :arrow_up:
bottom/__init__.py 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dc2b552...cadb738. Read the comment docs.

numberoverzero commented 7 years ago

@DACRepair It's been a while since you opened #32, so there's a good chance you moved on to another library. If you did find a way to make bottom work, I'd love your feedback on the new methods.

I'll let this bake for a week in case anyone else has feedback, after which I'll merge 2.1.0.