cog icon indicating copy to clipboard operation
cog copied to clipboard

Cache command prefix regex

Open imbriaco opened this issue 9 years ago • 0 comments

We build regular expressions to strip the command prefix from command text in a number of places, often for each message we receive. Since this pattern does not change during the runtime of Cog, we should compile the necessary patterns during initialization of the processes that they're relevant for. These patterns are not identical in every place they're used so we can't do that globally, but we could cache in each adapter for example.

A good example of this pattern exists in the Cog.Adapters.HipChat.Connection Genserver: https://github.com/operable/cog/blob/master/lib/cog/adapters/hipchat/connection.ex#L17

imbriaco avatar Jun 23 '16 23:06 imbriaco