myano / jenni

jenni was a python IRC bot. Project is closed. Try Sopel instead, https://sopel.chat/
https://sopel.chat/
Other
235 stars 101 forks source link

Request quotes either by index or nick #229

Closed J3RN closed 8 years ago

J3RN commented 8 years ago

This allows one to say:

.quote Nick

And jenni to spit out a quote beginning with <Nick>, which is the typical format for attributing authors of quotes. It is case sensitive, which can be worked around if desired.

A brief explanation of the code:

  1. I added an import of itertools because of it's handy-dandy compress method, that did exactly what I wanted.
  2. Updated documentation
  3. Checked to see if text is not None. If so, the user did pass an argument, try to treat it as a number. If that works, use that number. If the nick you're trying to reference is a number, sucks. If that didn't work, treat what the user gave as a nick and retrieve the indices of all quotes by that nick. Return an arbitrary one of those indices, if there are any. If there aren't any, give up and complain.

    If text is None, the user did not pass an argument, so just choose a random one.

That may be poorly worded, but that's it. Of course, I'd love feedback.