Path: blob/master/examples/plugin/customscanner.go
988 views
package main12import (3"github.com/sundowndev/phoneinfoga/v2/lib/number"4"github.com/sundowndev/phoneinfoga/v2/lib/remote"5)67type customScanner struct{}89type customScannerResponse struct {10Valid bool `json:"valid" console:"Valid"`11Info string `json:"info" console:"Info"`12Hidden string `json:"-" console:"-"`13}1415// Name returns the unique name this scanner.16func (s *customScanner) Name() string {17return "customscanner"18}1920// Description returns a short description for this scanner.21func (s *customScanner) Description() string {22return "This is a dummy scanner"23}2425// DryRun returns an error indicating whether26// this scanner can be used with the given number.27// This can be useful to check for authentication or28// country code support for example, and avoid running29// the scanner when it just can't work.30func (s *customScanner) DryRun(n number.Number, opts remote.ScannerOptions) error {31return nil32}3334// Run does the actual scan of the phone number.35// Note this function will be executed in a goroutine.36func (s *customScanner) Run(n number.Number, opts remote.ScannerOptions) (interface{}, error) {37data := customScannerResponse{38Valid: true,39Info: "This number is known for scams!",40Hidden: "This will not appear in the output",41}42return data, nil43}4445func init() {46remote.RegisterPlugin(&customScanner{})47}484950