Commit Graph

82 Commits

Author SHA1 Message Date
diamondburned 997b156e2f Changed Namer to a Name method in Authenticator
This commit removes the Namer interface and use a normal Name() method
instead. This is because we don't want to add icons into Authenticators.
2020-10-26 22:25:55 -07:00
diamondburned 65273770ca Added Namer and Description into Authenticator
This commit embeds the Namer interface into Authenticator as well as
adding the new Description method, both of which returns a text.Rich.
These methods are added to provide contextual clues to the user about
each Authenticator method.

Frontends can use the Name as the title, so the name should be short,
concise, and not include the name of the service.
2020-10-26 22:21:21 -07:00
diamondburned 524bd06b7a Clarified ID uniqueness
This commit clarifies the rules regarding ID uniqueness and guarantees
when it comes to the backend and frontend. This piece of documentation
was added into the top package section.
2020-10-26 21:48:28 -07:00
diamondburned 642f13a8c3 Allow multiple implementations of Authenticator
This commit breaks the API to allow backends to return a slice of
Authenticators instead of a single Authenticator in the Service
interface. This is because some services might allow for more than one
method of authentication.

Note that the representation of multiple authenticators depends on the
frontend. One may choose to use tabs, notebooks, stacks, or anything
that is reasonable.
2020-10-26 21:44:09 -07:00
diamondburned 289eda1c25 Clarified Commander split rules; added ArgsIndexed
This commit clarified the word split rules when it comes to the
Commander interface. Specifically, this interface now has an edge case
of having split rules similarly to shell words (or shell syntax).

The implementation of these split rules is added into package split,
similarly to SplitIndexed. It is called ArgsIndexed. For the most parts,
it will behave similarly to shell syntax.
2020-10-14 18:08:35 -07:00
diamondburned 05f8ec0cbf Changed Commander to use []byte over io.Writer
This commit breaks the Commander interface. Prior to this, the Run
method would take in an io.Writer and do its tasks in the background.
Although this has lots of potential for usages, it is also very
overkill. Moreover, it makes IPC harder, since it now has to send over
fragments of data in synchronized order.

This commit gets rid of the io.Writer and only take a []byte for return
along with the error. This makes it easier for both the frontend and
backend to implement most commands, as well as making it easier for data
to be transferred over the wire.
2020-10-13 22:22:02 -07:00
diamondburned 4864d61476 Changed ServerUpdate's PreviousID API
Prior to this commit, the PreviousID method ambiguously confused two
different behaviors for the same result, that is when the returned ID is
empty.

This commit adds a return boolean to the method to differentiate those
two behaviors.
2020-10-09 12:11:23 -07:00
diamondburned 0ebf0c3302 Clarified ServerUpdate behavior
Prior to this commit, the PreviousID method of ServerUpdate seemed to be
a big unknown. This commit clarified that unknown by declaring two
conditions: when PreviousID returns an empty and non-empty ID.

The above change allows ServerUpdate events to both modify existing
servers as well as inserting new ones.
2020-10-09 11:51:16 -07:00
diamondburned d62231a4ef Fixed Backlogger method name
This commit fixes a mistake in the Backlogger interface, that is the
Backlog method was called Backlogger incorrectly.
2020-10-09 10:27:38 -07:00
diamondburned cfc0e00c8a Shorter, more idiomatic method names
This commit breaks several cchat interfaces to rename some method names
and make them shorter. These new method names are more idiomatic.
2020-10-09 10:09:38 -07:00
diamondburned 32fa6266db Fixed Bitwise codegen being flipped 2020-10-08 23:58:58 -07:00
diamondburned 89b5ede1d8 Regenerated code to adhere to codegen header
This commit regenerates all files to adhere to the arguably-official
convention of having a standardized comment format to allow
distinguishing between written and generated files.

Refer to https://golang.org/s/generatedcode for more information.
2020-10-04 14:33:57 -07:00
diamondburned 5f7316cf9d Actioner.Actions to take a message ID
This commit restores the old API prior to the repository commits to make
the Actions method of the Actioner interface take in a message ID and
return a slice of strings.
2020-10-04 11:45:18 -07:00
diamondburned dd4e230e0f Fixed UnreadContainer's comment
Prior to this commit, UnreadContainer's comments mentioned deprecated
SetUnread and such methods. It now reflects the new API.
2020-10-03 23:17:32 -07:00
diamondburned 99f7224d32 Mentioned now returns bool
Prior to this commit, the Mentioned method in MessageCreate didn't
return anything. This is a regression. It now returns a boolean that
indicates mentioned.
2020-10-03 23:14:54 -07:00
diamondburned 555931f974 Added Avatar() into Author
This commit adds the Avatar method into the Author interface. It returns
the URL if one, or it can return an empty string if either the service
does not support avatars or the user doesn't have avatars.
2020-10-03 23:08:24 -07:00
diamondburned aaa29f35b0 Author now has Name() over Namer
Prior to this commit, interface Author embedded interface Namer. This
doesn't work, as it is discouraged to keep a working state inside the
implementation of Author, but Namer's embedded Iconer requires a state.

The commit changed Author to use a Name method instead, which is only a
getter. It will no longer satisfy interface Name.
2020-10-03 22:52:21 -07:00
diamondburned 1588cfef9c Fixed IconContainer.SetIcon; added ImageContainer
This commit fixes IconContainer's SetIcon, which was SetImage prior to
this commit. Before the code generation commits, this container
originally had SetIcon.

This commit also adds back ImageContainer, which was a regression during
the code generation changes. It has the SetImage method.
2020-10-03 22:06:50 -07:00
diamondburned 2d93bf62ea Regenerated with Backlogger and fixes 2020-09-27 20:37:27 -07:00
diamondburned f515470458 Generated code now compiles; added DO NOT EDIT 2020-09-27 19:30:36 -07:00
diamondburned 516532ee01 Repository changes; regenerated code
This commit fixes some trivial errors in the repository package. The
changes are breaking.

This commit also replaced the old cchat and text Go source code files
with ones generated straight from the repository. To regenerate, run

    go generate ./...

The code is generated using the Jennifer library. In the future, all
generated code (including package empty and the RPC library) will use
Jennifer.
2020-09-27 18:41:17 -07:00
diamondburned 8b8c46a714 Refactored to a completely new API
This commit refactors entirely the ways cchat interfaces extend others.
Prior to this commit, interfaces extend itself simply by implementing
methods. This change is crucial to allow structs to decide whether or
not an interface is extended during runtime.

The current change adds the "As" methods into interfaces. When said, for
example, "Messenger extends Server," we now have the Server interface
implementing the AsMessenger method instead of before where the struct
implementing Server also implemented Messenger's methods.

For future references, these method will be called asserter methods.

The biggest motivation for this change is that these asserter methods
can allow backends to decide whether or not certain features are
implemented during runtime. For example, not all servers may support
sending messages. The asserting method is also simpler than the actual
type assertions done before.

Another motivation is to prepare cchat for an API that can reasonably be
translated to something that can be transferred over the wire. Although
the API itself will likely not be transferred over actual networking,
there are lots of plans for IPC-ing the API. This could mean that
developers would be able to develop the backends and frontends in any
programming language.

A downside to this is that the API is more restricted in terms of
extending beyond interfaces defined in the package. The initial goal of
this was to allow certain frontends to check for additional interfaces
outside of cchat that certain services could implement. However, this
goal is mostly moot, as interfaces like these require prior extensive
knowledge from both the developers of the backend and frontend
libraries.
2020-09-25 19:31:01 -07:00
diamondburned 62711b89f2 Fixed superfluous Lister in Session 2020-09-07 18:30:12 -07:00
diamondburned 214233cf3d Fixed error: Messager -> Messenger
This commit breaks existing v0.1.0 code to fix a grammatical error.
2020-09-07 17:19:18 -07:00
diamondburned ab2b4d48fa Fixed assert example in package header
This commit fixed an error in the package header from the previous
commit.
2020-09-05 19:46:58 -07:00
diamondburned 40dbe21c82 Shorter interface names; "Is" method in interfaces
This commit introduces many breaking changes that will break all current
code, both in the frontend and backend.

This commit changes the previous interface names to shorter versions.
This is done because, with the addition of the parent interface being
embedded in every extension interfaces, it is pointless to have the
name indicate this relationship. Furthermore, shorter and concise names
are more idiomatic.

This commit also introduces the "Is" method that is in every extension
interfaces. The purpose of this method is to provide an alternative
mechanism to check if an interface is extended.

Prior to the "Is" method, the only way for a backend to indicate
channels that can either be sent a message or not is to use two
separate types. Now, backends could implement a single type and return a
true or false on the Is method.

This method has a major disadvantage: it makes type assertions longer
and more complex. Refer to the "assert extension interfaces" example for
an example.

Despite the above disadvantage, this change is needed by the RPC
implementation in the future. Thus, it is worth the trouble of checks
being more verbose.
2020-09-05 19:39:34 -07:00
diamondburned cd018ef8f9 Added ID type; Added backlog interfaces
This commit adds the ID type, which is a type alias to a string. This
change does not break any APIs and is done purely for documentation
purposes.

This commit also adds backlog interfaces to add support for services
capable of storing and showing chat history.

A subtle behavior change with the above change would be that
MessageContainer implementations are now required to add a mechanism to
invalidate old containers when needed. For example, the MessagePrepender
passed into MessagesBefore must be invalidated by the frontend when the
channel in view is changed. This prevents stray messages from old
channels coming in.

There are many ways to invalidate a container, but the easiest way would
be to attach an optionally atomic boolean into the store and completely
separate the store from the view (aka widget).
2020-08-19 15:58:36 -07:00
diamondburned 3f4d50fa92 Added a Description and Placeholder field for auth entry
This commit adds 2 extra string fields into the authentication entry
struct. The objective is to allow backends to hint additional
information that the user might want to know while authenticating.

Frontends that cannot do placeholders can opt for another way to display
the information, such as adding it into the name, surrounded by
parentheses.
2020-07-29 16:55:28 -07:00
diamondburned c45d874a80 Added member list support; moved documentation off README and into GoDoc
This commit adds member list support for servers capable of showing
messages. This includes both backend and frontend interfaces.

A UserStatus type was added with the appropriate constants for this purpose,
but it could be used in the future for other purposes.

All cchat documentation has been moved off of the README and into
GoDoc's documentation sections. This is done to free up the README for
other useful information about the project that doesn't have to do with
the code itself.
2020-07-19 10:37:51 -07:00
diamondburned 9974fcc636 Changes ServerMessageUnreadIndicator to return a cancel callback
This commit is a breaking change. It changes the UnreadIndicate method
to require returning an additional stop callback similar to that in
Nickname.

The motivation for this change was that frontends need a way to announce
cancellation before it destroys its server containers. This may happen
when the backend wants to replace in the container a completely new
list. As such, old lists will be destroyed, and the frontend will call
UnreadIndicate again. Because of that, the old callbacks must be cleaned
up.
2020-07-16 18:40:18 -07:00
diamondburned 1fe254db60 Added documentation to clarify attachments 2020-07-09 16:13:17 -07:00
diamondburned 106b543f09 Adds message attachments
This commit adds message attachments. More specifically, the
MessageAttachment struct was added to represent a single attachment.
Interfaces are added as well, that is ServerMessageAttachmentSender and
SendableMessageAttachments.

For the most parts, the frontend will use SendableMessageAttachments,
which extends the usual SendableMessage.
2020-07-09 16:03:35 -07:00
diamondburned (Forefront) c8d6c89a08 Added Time into Typer 2020-07-01 13:32:54 -07:00
diamondburned (Forefront) 78767a3f2f Undo latest changes that added RoundIconContainers
This commit undos these latest changes and replaced them with the new
ImageContainer API as well as Image boolean in CompletionEntry.

These changes, unlike the earlier commits, are not breaking changes.
They are only additions.

ImageContainer is added for future usages, which translates to the
previous commits' IconContainer. The current IconContainer translates to
the previous commits' RoundIconContainer.
2020-07-01 10:49:44 -07:00
diamondburned (Forefront) e7aa6fb885 Added secondary text into completion entry; added RoundIconContainer
This change was done without breaking the existing API. Initially, the
idea was to use a URL fragment to indicate if an icon should be round.
That, however, was a bad idea, as URL fragments are part of the URL
string and would require additional effort to parse them. As such,
RoundIconContainer was added.

Frontends don't need to round icons from RoundIconContainer, and as
such, may call IconContainer in the implementation. The choice of using
round icons is up to the backend implementations.
2020-06-30 19:43:42 -07:00
diamondburned (Forefront) d754f011ba Clarified RunCommand's documentation
This clarification applies on the latest release; however, no releases
will be made for it.
2020-06-29 19:57:11 -07:00
diamondburned (Forefront) a8cfc54f6d Breaking: Added stop callbacks to functions that take in containers
This breaking change was done to provide a clean API for backends to
remove event handlers when they're not needed anymore. It also moves the
cancellation logic from the backend to the frontend, making it easier
for backends.
2020-06-29 13:27:00 -07:00
diamondburned (Forefront) 88879d45f2 Added typing capabilities and indicator interfaces
This commit adds typing capabilities and indicator interfaces into
cchat. The objective is to provide an API for typing event APIs similar
to Discord's and IRCv3's.
2020-06-29 11:39:59 -07:00
diamondburned (Forefront) 88834ab465 Added MessageEditable into ServerMessageEditor
This is a breaking change, as it modifies the ServerMessageEditor
interface.

This breaking change is done with the assumption that not all services
will support editing every single message. For example, Discord only
allows editing your own messages.

With the introduction of a MessageEditable method, services shouldn't
have to return an error to indicate that a message isn't editable
anymore.
2020-06-27 23:31:34 -07:00
diamondburned (Forefront) 5d2cd4a57b MessageActions now takes in a message ID.
This change was done to add support to messages that may have more or
less actions. For example, this lets the backend only display the
"Delete" option when the message can be deleted.

Documentation is also corrected and further done in this commit.
2020-06-20 15:52:04 -07:00
diamondburned (Forefront) 6c7cd5feb2 Added UnreadIndicator and ServerMessageIndicator for unread indicators 2020-06-20 15:02:05 -07:00
diamondburned (Forefront) 6bb1d742a2 Clarified IO rules for ServerMessageEditor 2020-06-17 13:39:52 -07:00
diamondburned (Forefront) 7698aa5fc2 Removed some arguments such as context to reduce complexity 2020-06-14 18:46:59 -07:00
diamondburned (Forefront) 8768baf196 Added usage of context.Context into the API for cancellation 2020-06-14 16:00:18 -07:00
diamondburned (Forefront) 391004677b Added error handling behavior documentation for Disconnect 2020-06-13 16:33:33 -07:00
diamondburned (Forefront) 831a6ea7e6 Added Disconnect into the server requirement 2020-06-13 16:29:30 -07:00
diamondburned (Forefront) 4a7f7a7994 Added Raw into CompletionEntry 2020-06-10 17:38:59 -07:00
diamondburned (Forefront) b38dc6c6b4 Added extra docs 2020-06-10 16:10:03 -07:00
diamondburned (Forefront) 8fdf82883a Moved package split to utils 2020-06-10 12:19:13 -07:00
diamondburned (Forefront) b6eca8eafa Improved documentation for CompleteEntry 2020-06-09 21:05:59 -07:00