Repository with my personal site
voytechnology / cheapskate Goto Github PK
View Code? Open in Web Editor NEWUniversal Bot
Universal Bot
CodeFactor found an issue: Missing argument for Fatalf("%s"): format reads arg 3, have only 2 args
It's currently on:
plugins\plugins.go:125
Commit dce0327
I am not sure is the current plugin interface the best that could be. I feel like there is a way to simplify it somehow. Perhaps we should copy the approach of things like Gin HTTP Framework with Middleware.
We can also take a look at Terraform Providers.
Either way, I am not too happy with it, and would definatelly need an improvement. Python decorators would be nice but (un)fortunately are not available in Go.
/clap /clap CLAP IN BETWEEN
generates CLAP ๐ ๐ ๐ IN ๐ ๐ ๐ BETWEEN
. This should be somehow stopped with only one ๐ being created between words.
Right now none of the plugins require configuration, but it will change soon, as things such as Facebook or Github would definitely need API keys to work.
I guess the easiest way to configure it would be to have plugins.config.<name>.*
, where <name>
is the name of the plugin. This way on plugin creation we can call Configure(config map[string]interface{})
where the the passed in data would correspond to *
.
eg.
cheapskate.toml
plugins:
config:
facebook:
email: _________@______
password: ____________
and Config passed into the plugin would only have the fieldsemail
and password
available.
This is a meh security measure, as all plugins still have access to settings
package which contains all the values.
Facebook is one of the primary integration platforms.
It should listen for the webhooks and then send back a response whenever there is a response.
Currently the plugin system is rather limited with how it can handle responses. Essentially currently the flow goes like this:
integration -> Action(Origin: integration: Data: /uppercase /clap clap between every single word)
v
AddAction
v
uppercase -> Action(Origin: cmd/regex, Target: integration, Data: /CLAP CLAP BETWEEN EVERY SINGLE WORD)
v
AddAction (Target is set, go directly to target)
v
integration
This means that if the resulting data from command or regex is only intended for integration. I guess an option is to have Action as a linked list (see note), and once there is nothing else to do, the Action with the final data would be passed back to integration. Not sure how that will look as a flow tho.
Other way is simply to ignore the target in most cases, and return when there is nothing to be done.
Essentially turning the flow into:
integration -> Action(Origin: integration, Data: /uppercase /clap clap between every single word)
v
AddAction
v
uppercase -> Action(Origin: integration, Data: /CLAP CLAP BETWEEN EVERY SINGLE WORD)
v
AddAction
v
clap -> Action(Origin: integration: Data: CLAP ๐ BETWEEN ๐ EVERY ๐ SINGLE ๐ WORD)
v
AddAction (nothing else to be done, go back to integration
v
integration
I guess the problem is that we loose insight into what plugin handled the action, but this can be somewhat mitigated via good logging
Linked List Note: hah, college is actually useful sometimes. This is the first time I actually see a need for doubly linked list (I think)
Right now we take a dummy approach to how the hooks are registered. We should consider the hook structure, and how the plugins can be bound. For example, Prometheus might use /metrics
, so we cannot allow that to be bounded, but I am not sure is prometheus as a plugin such a good idea, I feel like it should be in the core of the project.
This means we should potentially be limiting the binding space for the integration plugins to something like /plugins/<registered-path>
, this clears the root (/
) to more core stuff.
All plugins from steely must be ported to cheapskate. Please mark this issue when adding PRs with steely plugins.
/clap /clap
- #12)(my god. there is a lot of them.)
In case a plugin panics, we should not kill the entire bot, but gracefully recover. We can perhaps state that a plugin has panicked, and ping the admin of the bot. In case of core panic we should gracefully stop, ideally also pinging maintainers, or creating a github issue with failure details.
We should be using HTTPS for the webhooks as many sites don't accept non-https hook endpoints (and we care about security)
All the settings should be set using ENV VARS. The code in the settings
package already has the basic code, but for some reason it doesn't work. Investigate and fix why it doesn't work.
Currently all the available plugins are in the plugins
directory, but as shown by Steely, with 80+ plugins it can become a bit annoying.
There are several approaches that can be taken to make sure we have easier time with cheapskate and plugins:
Remain in repo - This approach pretty much means we don't do anything, we just have the plugin there, and improve it like any other file. This has the benefit of deploying all the plugins with the main system, eliminating the need of additional build steps.
Use Hashicorp's go-plugin - It looks like a pretty nice solution, and would allow to write plugins in other languages because it just uses gRPC, but every single plugin would be its own binary, making deployment that much more difficult, but at least all the plugins would be found in the single configurable plugin.location
setting
Serve plugins as separate services - This is probably the worst idea, as it would mean that each plugin would become its own separate bot, and cheapskate would only serve as proxy and adapter (converting from integration to cheapskate message format that would be served to all plugins). In a way, its pretty similar to idea 2, but we would accept plugin registration using HTTP interface and then the message would be send to the plugin and returned. It would be pretty difficult to manage.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.