thomasleese / smartbot

A supposedly smart IRC bot. (I now use Hubot...)
MIT License
2 stars 5 forks source link

BRFares plugin #22

Closed Muzer closed 10 years ago

Muzer commented 10 years ago

I've been linking to BRFares too much recently. We need a fares searcher using the BRFares API*. My suggestion for its functionality is the following (but you can change it if you like ;)):

1) Query: SmartBot, fares Swaythling to Southampton Air with 16-25 Railcard (OR SmartBot, fares SWG to SOA with YNG) it looks up the stations and the railcard (querysimple should suffice), returning a short list of fares as follows (truncated to a number of items (eg 10) with a "more?" prompt to which you can somehow answer in the affirmitive):

Fares from SWAYTHLING (SWG) to SOUTHAMPTON AIR (SOA): [0] SDR STD ANYTIME DAY R route ANY PERMITTED - £1.80 [1] CDR STD OFF-PEAK DAY R route ANY PERMITTED - £1.65 [2] SDS STD ANYTIME DAY S route ANY PERMITTED - £1.30

If there are lots of fares returned (see the results for Penryn to Truro without a railcard), it should give a list as follows:

Fares from PENRYN CORNWALL (PYN) to TRURO (TRU): [0] 1ST SINGLE fares [1] STD SEASON fares [2] STD RETURN fares [3] STD SINGLE fares [4] 1ST RETURN fares

You may then type a number (eg SmartBot, fares 1) to get a list of fares as above, again with truncation as necessary.

When you have a list of fares, you may then see detailed information about a fare by typing:

SmartBot, fares 0

(for instance)

It would display all information about the fare:

From: BASINGSTOKE (BSK) To: SOUTHAMPTON CTL (SOU) Fare setter: SOUTH WEST TRAINS (SWT) Route: ANY PERMITTED (0) Cross-London Transfer: NO (0) - please note that this only affects whether or not London Underground barriers will accept the ticket, and often has little bearing on actual validity. Ticket: STD (1) OFF-PEAK R (SVR) Ticket type: RETURN (1) Ticket validity: AS ADVERTISED (72), not restricted to particular train or date, restricted by area (??? need to figure out what this means). [tickets with nonzero values for these would also display min_validity and (if they differ) max_validity in some way - eg ", for 7 days"] Reservations required: NO (0) Validity restriction code: UQ (link to pastebin of the text of the "specific_text" field in the undocumented http://www.brfares.com/restrictionspec?code=UQ ) Railcard restriction code: R1 YOUNG PERSON (Y-P): £17.65 [if appropriate, state "minimum fare of £12.00 may apply" - if min_fare is present, use that value, if not, don't display this] CHILD (CHILD): £13.35

If some fares have the "group destination" field not null, these should be displayed instead of the origin/destination at the very start of the json. The flow origin/destination should never be used. See the example below:

From: Basingstoke (BSK) To: LONDON ZONES 1-6 (0035) - Zonal Travelcard [use travelcard_orig/dest and zonal_orig/dest to display "zonal", "travelcard" or "zonal travelcard" here] [...]

Muzer commented 10 years ago

I've sent an email to the BRFares guy asking to clarify a few things. Hopefully will get a response, and this will be more accurate.

Muzer commented 10 years ago

I've started implementing this. i'm sure Leese will hate most of my code.