Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sundowndev
GitHub Repository: sundowndev/phoneinfoga
Path: blob/master/examples/plugin/customscanner.go
988 views
1
package main
2
3
import (
4
"github.com/sundowndev/phoneinfoga/v2/lib/number"
5
"github.com/sundowndev/phoneinfoga/v2/lib/remote"
6
)
7
8
type customScanner struct{}
9
10
type customScannerResponse struct {
11
Valid bool `json:"valid" console:"Valid"`
12
Info string `json:"info" console:"Info"`
13
Hidden string `json:"-" console:"-"`
14
}
15
16
// Name returns the unique name this scanner.
17
func (s *customScanner) Name() string {
18
return "customscanner"
19
}
20
21
// Description returns a short description for this scanner.
22
func (s *customScanner) Description() string {
23
return "This is a dummy scanner"
24
}
25
26
// DryRun returns an error indicating whether
27
// this scanner can be used with the given number.
28
// This can be useful to check for authentication or
29
// country code support for example, and avoid running
30
// the scanner when it just can't work.
31
func (s *customScanner) DryRun(n number.Number, opts remote.ScannerOptions) error {
32
return nil
33
}
34
35
// Run does the actual scan of the phone number.
36
// Note this function will be executed in a goroutine.
37
func (s *customScanner) Run(n number.Number, opts remote.ScannerOptions) (interface{}, error) {
38
data := customScannerResponse{
39
Valid: true,
40
Info: "This number is known for scams!",
41
Hidden: "This will not appear in the output",
42
}
43
return data, nil
44
}
45
46
func init() {
47
remote.RegisterPlugin(&customScanner{})
48
}
49
50