UltrosBot / Ultros

Connecting communities, one squid at a time! Ultros is a multi-protocol chat bot written in Python, designed with both the user and developer in mind
http://ultros.io
Artistic License 2.0
23 stars 7 forks source link

Formatter #24

Open rakiru opened 10 years ago

rakiru commented 10 years ago

Convert a message such as "{BOLD}foo{BOLD_END}" into the correct formatting for the given protocol.

This should probably be a class instantiated as proto_instance.formatter (Mumble could use a generic HTML one then, for instance, or a subclass of one, and protocols with no formatting could use one that does nothing (or markdown-style)). Actual format of messages still to be discussed.

Should missing formatting support (such as a protocol not support italics) do nothing, or attempt to format it another way? Should a formatter that can support certain formatting, but not natively (such as Mumble/HTML not having colour reverse support) do nothing, or attempt the formatting its own way?

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

rakiru commented 10 years ago

Also, all formatters should subclass a generic formatter.

This generic formatter could actual parse/tokenise the input message and call other methods to handle it (either on a per-token basis or as a list of tokens), and by default simply return an empty string (or markdown) for formatting charaters/strings.

It could also contain generic formatting functions, such as limiting a string length and appending "...", etc. On this note, see #11 (some of that stuff could be done with the python standard library).

gdude2002 commented 10 years ago

Well, if a protocol has no formatter, supply a generic one that removes formatting tokens.

Are you good at tokenizing and such? 'cause I'm really not. xD

rakiru commented 10 years ago

How hard can it be? :P

gdude2002 commented 10 years ago

It's something I was never able to wrap my head around :P

gdude2002 commented 10 years ago

It just occurred to me that formatters should go both ways. That is to say..

We should definitely plan for this as some protocols are going to have odd formatting.

gdude2002 commented 10 years ago

Raising this to blocker status, we really need this one.