LeastAuthority / leastbot

0 stars 0 forks source link

simplify github event handling. #15

Open nathan-at-least opened 10 years ago

nathan-at-least commented 10 years ago

Github event processing can be simplified and made more consistent to improve maintainability.

What to Change

First, every event has three common sections according to the docs for payloads: sender, repository, and organization, so these details could be formatted generally for all messages.

Next, it may be possible to replace specific event handling functions with standard string.format templates, with two caveates: incorporating multiple items from JSON arrays and special field formatting, such as for URL-encoding ^ characters (see #11).

The Current Design

Currently there is a FunctionTable mapping github event names to arbitrary functions which return formatted messages. Every such function uses python %-interpolation and explicitly selects pieces of the JSON message (using _AttrLookupWrapper). Since the string.format expansions already support attribute lookup, we can replace these functions with simple string templates.

Features Which string.format Lacks

nathan-at-least commented 10 years ago

Adding underspecified tag: this sounds like multiple features/tickets:

In any event, some of those features will be obviated, or their implementations drastically altered by #21 which is ahead in the roadmap (0.2.2 versus undecided).