HawkLens is built to be extensible. If you want to add support for a new social platform or data source, follow this guide.
Every plugin must implement the Plugin interface defined in pkg/plugins/plugin.go:
type Plugin interface {
Name() string
Description() string
Fetch(ctx context.Context, query string) ([]Result, error)
}Create a new directory in internal/plugins/[platform].
Create a struct that satisfies the Plugin interface.
package myplatform
import (
"context"
"github.com/ismailtsdln/HawkLens/pkg/plugins"
)
type MyPlugin struct{}
func (p *MyPlugin) Name() string { return "myplatform" }
func (p *MyPlugin) Description() string { return "Scrapes data from MyPlatform" }
func (p *MyPlugin) Fetch(ctx context.Context, query string) ([]plugins.Result, error) {
// 1. Authenticate (optional)
// 2. Fetch data
// 3. Map to plugins.Result
return []plugins.Result{...}, nil
}In your plugin's package, add an init() function or register it in internal/cli/init.go.
import "github.com/ismailtsdln/HawkLens/pkg/plugins"
func init() {
plugins.Register(&MyPlugin{})
}When mapping your platform's data to the plugins.Result struct, aim for consistency:
- Platform: Use lowercase name (e.g.,
twitter). - DataType: Specify the content type (e.g.,
tweet,video,post). - Data: A map containing the raw but relevant fields.
- For text content, use the key
text,title, orcaption.
- For text content, use the key
Create a [platform]_test.go file in your package. Use the plugins.GetPlugin() function to retrieve and verify your implementation.