Compare commits

...

70 Commits
nats ... master

Author SHA1 Message Date
Pedro de Oliveira Guedes 07c484d31d Updating packages. 2022-03-04 14:24:58 -03:00
Pedro de Oliveira Guedes cdf0c422a3 Fixing the QueueGetMyJson function by using pointers. 2022-03-04 14:23:27 -03:00
Paulo Simão 18801a7b94 added QueueGetDataBody 2022-03-03 13:34:42 -03:00
Paulo Simão 03930d5821 Merge branch 'master' of ssh://gitea.digitalcircle.com.br:2222/open/replaycli-go 2022-03-03 03:26:18 -03:00
Paulo Simão 60128fb729 add jobalias to cron 2022-03-03 03:24:27 -03:00
Leonardo Domingues c032f74806 FindUrl 2022-03-01 14:35:17 -03:00
Paulo Simão 98605a3f9b Added QueueWData and QueueWDataWait to cli. Added Once prop to cron (these will be removed upon execution) 2022-03-01 08:05:11 -03:00
Leonardo Domingues fa69db55c8 Captcha identifier 2022-02-09 14:26:25 -03:00
Pedro de Oliveira Guedes 62ad6dcb51 Fixing Image2text method. 2022-01-13 11:02:56 -03:00
Leonardo Domingues 0dff7d0d6a Reversão 2022-01-13 09:49:37 -03:00
Leonardo Domingues dea0595735 . 2022-01-13 09:25:07 -03:00
Leonardo Domingues eb9f833027 Hcaptcha 2022-01-12 18:05:08 -03:00
Pedro de Oliveira Guedes 13626dcde9 Fixing recatcha-v2 and image2text methods. 2021-12-28 12:51:01 -03:00
Pedro de Oliveira Guedes d5c986df8e Fixing chromeSend. 2021-12-28 12:49:57 -03:00
Leonardo Domingues 58fbb932aa Merge branch 'master' of ssh://gitea.digitalcircle.com.br:2222/open/replaycli-go 2021-12-16 16:54:16 -03:00
Leonardo Domingues c9f9a37bc3 Type change 2021-12-16 16:54:10 -03:00
Pedro de Oliveira Guedes 216d2a0851 Fixing test method 2021-12-16 15:03:40 -03:00
Leonardo Domingues 18173ed486 Merge branch 'master' of ssh://gitea.digitalcircle.com.br:2222/open/replaycli-go 2021-12-16 11:08:16 -03:00
Leonardo Domingues 7d1b743b27 Api_Key correction 2021-12-16 11:08:10 -03:00
Pedro de Oliveira Guedes adeb3ae60d Fixing do method. 2021-12-16 09:38:12 -03:00
Pedro de Oliveira Guedes cc26a118a4 Fixing test method. 2021-12-16 08:54:53 -03:00
Leonardo Domingues 2e48c5b2a6 Merge branch 'master' of ssh://gitea.digitalcircle.com.br:2222/open/replaycli-go 2021-12-15 10:44:33 -03:00
Leonardo Domingues f951956db5 AHK and Autoit implemented 2021-12-15 10:44:27 -03:00
Pedro de Oliveira Guedes 0b006b8243 Merge branch 'master' of ssh://gitea.digitalcircle.com.br:2222/open/replaycli-go 2021-12-09 10:33:27 -03:00
Pedro de Oliveira Guedes 2257f3f349 Adicionando comentários para as funções. 2021-12-09 10:30:53 -03:00
Leonardo Domingues b727ad8d39 Fixes 2021-12-07 17:43:32 -03:00
Leonardo Domingues f5f555936b Request fixed 2021-12-07 17:33:39 -03:00
Leonardo Domingues bd3bcefcc2 Type correction 2021-12-07 11:00:51 -03:00
Pedro de Oliveira Guedes 05f2b34703 Deleting entry parameters from "ScreenDs" methods. 2021-12-07 08:30:40 -03:00
Pedro de Oliveira Guedes f6853bc03c Merge branch 'master' of ssh://gitea.digitalcircle.com.br:2222/open/replaycli-go 2021-12-06 15:38:39 -03:00
Leonardo Domingues f54514a87a ScreenShot method -> Fixed 2021-12-06 15:37:55 -03:00
Leonardo Domingues b8e5810103 Proc Methods 2021-12-06 15:15:37 -03:00
Pedro de Oliveira Guedes d84ad7763c Fixing the "ScreenShot" method. 2021-12-06 14:51:06 -03:00
Leonardo Domingues 59e4b137c5 Dialog Methods 2021-12-03 18:14:18 -03:00
Leonardo Domingues 7771f50e1b KB methods 2021-12-03 15:54:05 -03:00
Leonardo Domingues 126ef1e289 Screen Methods 2021-12-03 13:31:00 -03:00
Leonardo Domingues 6bc18cedef New screen methods added 2021-12-03 13:04:03 -03:00
Leonardo Domingues 048c8e0b4e clean 2021-12-03 12:30:25 -03:00
Leonardo Domingues 64d94b13f7 Adição da função Capture 2021-12-03 11:44:32 -03:00
Leonardo Domingues 69d0bdf3e8 Correção de tipos 2021-12-03 10:52:39 -03:00
Leonardo Domingues ade994dac8 Bug fix 2021-12-03 10:50:47 -03:00
Leonardo Domingues 6c1c483496 Correção nos tipos 2021-12-03 10:28:21 -03:00
Leonardo Domingues c03689b9fc Alteração nas variáveis de retorno 2021-12-02 18:35:00 -03:00
Leonardo Domingues 6c981f4196 Correção dos tipos de variável 2021-12-01 17:19:03 -03:00
Leonardo Domingues 393154a0ac Att 2021-12-01 17:12:14 -03:00
Leonardo Domingues 4cfbe8f072 Definição de tipo 2021-12-01 17:08:38 -03:00
Leonardo Domingues 9877e1819c Merge branch 'master' of ssh://gitea.digitalcircle.com.br:2222/open/replaycli-go 2021-12-01 15:27:12 -03:00
Leonardo Domingues 0363cfc1bc Window Methods 2021-12-01 15:27:04 -03:00
Pe-Guedss 992fe90efb Merge branch 'master' of ssh://gitea.digitalcircle.com.br:2222/open/replaycli-go 2021-12-01 14:27:35 -03:00
Pe-Guedss ed392fd245 Fixing ClipRead function (from json to raw). 2021-12-01 14:17:18 -03:00
Leonardo Domingues 44f39c7c16 Notify Methods 2021-12-01 11:22:31 -03:00
Leonardo Domingues e0f1a0ddd4 Correção de bugs 2021-11-29 12:11:14 -03:00
Leonardo Domingues ee65505e8f Drawing methods implemented 2021-11-29 12:04:09 -03:00
Leonardo Domingues f3f5e80160 Methods: Get chrome tabs (all, by url, by title) 2021-11-29 12:02:23 -03:00
Paulo Simão 571810c476 add comments 2021-11-29 10:45:25 -03:00
Paulo Simão befca816d5 add printf to log 2021-11-29 10:44:03 -03:00
Paulo Simão bca0854a85 improvements 2021-11-25 16:50:15 -03:00
Paulo Simão d80a2568ac Merge remote-tracking branch 'origin/master'
# Conflicts:
#	api/dataapi/lib_test.go
2021-11-25 16:49:42 -03:00
Paulo Simão aee712a88a improvements 2021-11-25 16:49:24 -03:00
Leonardo Domingues 17d68433dc Eliminação do lib_test e atualização da key 2021-11-25 13:51:25 -03:00
Leonardo Domingues 59f6b2578a Merge branch 'master' of ssh://gitea.digitalcircle.com.br:2222/open/replaycli-go 2021-11-25 10:50:42 -03:00
Leonardo Domingues 3504facc2e Correções 2021-11-25 10:50:33 -03:00
Paulo Simão ccae321dc9 Merge remote-tracking branch 'origin/master' 2021-11-20 09:21:29 -03:00
Paulo Simão 990ac72c52 add apiproxy 2021-11-20 09:21:22 -03:00
Leonardo Domingues eaaa1a6224 Inclusão de erro 2021-11-09 09:43:25 -03:00
Leonardo Domingues 0b6a1179a1 Merge branch 'master' of ssh://gitea.digitalcircle.com.br:2222/open/replaycli-go 2021-11-08 10:32:36 -03:00
Leonardo Domingues a8daeabffb Função para contar execuções mensais de robôs 2021-11-08 10:32:29 -03:00
Paulo Simão 2543c4bf9a added wingui-display cli 2021-11-06 13:55:42 -03:00
Leonardo Domingues f8acbf0c03 Adição da função 2021-11-05 18:09:09 -03:00
Leonardo Domingues 6ef42d1ccb Implementação de Registro simplificado da LCR 2021-11-05 18:03:02 -03:00
14 changed files with 724 additions and 51 deletions

View File

@ -17,7 +17,7 @@ type Cli struct {
type Req struct {
Site string `json:"site"`
Data string `json:"data"`
Img []byte `json:"img"`
Img string `json:"img"`
To int `json:"to"`
}
@ -26,14 +26,26 @@ func (c *Cli) Recaptchav2(site string, data string) (string, error) {
req := &Req{
Site: site,
Data: data,
Img: nil,
Img: "",
To: 300,
}
err := c.HttpCli().JsonPost("/ipc/anticaptcha/recaptchav2", req, &ret)
return ret, err
}
func (c *Cli) Image2text(site string, data []byte) (string, error) {
func (c *Cli) Hcaptcha(site string, data string) (string, error) {
ret := ""
req := &Req{
Site: site,
Data: data,
Img: "",
To: 300,
}
err := c.HttpCli().JsonPost("/ipc/anticaptcha/hcaptcha", req, &ret)
return ret, err
}
func (c *Cli) Image2text(site string, data string) (string, error) {
ret := ""
req := &Req{
Site: site,

View File

@ -0,0 +1,34 @@
package apiproxy
import "go.digitalcircle.com.br/open/replaycli-go/api"
type APIProxyRequest struct {
Name string `json:"name,omitempty"`
Method string `json:"method,omitempty"`
Url string `json:"url,omitempty"`
Header map[string]string `json:"header,omitempty"`
Body []byte `json:"body,omitempty"`
Readonly bool `json:"readonly"`
}
type APIProxyResponse struct {
Status string `json:"status"`
StatusCode int `json:"status_code"`
Header map[string]string `json:"header,omitempty"`
Body []byte `json:"body,omitempty"`
}
type Cli struct {
*api.ApiCli
}
func (c *Cli) Do(req *APIProxyRequest) (*APIProxyResponse, error) {
res := &APIProxyResponse{}
err := c.HttpCli().JsonPost("/ipc/apiproxy/do", req, res)
return res, err
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
return ret
}

View File

@ -0,0 +1,22 @@
package apiproxy
import (
"log"
"os"
"testing"
)
func TestCli_Do(t *testing.T) {
os.Setenv("REPLAY_APIKEY", "DONTBOTHER")
os.Setenv("REPLAY_ADDR", "https://localhost:8443")
c := NewCli()
res, err := c.Do(&APIProxyRequest{
Method: "GET",
Url: "https://www.slashdot.org",
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("%#v", res)
}

View File

@ -0,0 +1,25 @@
package autohotkey
import (
"go.digitalcircle.com.br/open/replaycli-go/api"
)
type Cli struct {
*api.ApiCli
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
return ret
}
func (c *Cli) Test() (ret []byte, err error) {
ret, err = c.HttpCli().RawPost("/ipc/ahk/test", nil)
return ret, err
}
func (c *Cli) Do(data string) (ret []byte, err error) {
i := []byte(data)
ret, err = c.HttpCli().RawPost("/ipc/ahk/do", i)
return ret, err
}

25
api/autoit/cli.go 100644
View File

@ -0,0 +1,25 @@
package autoit
import (
"go.digitalcircle.com.br/open/replaycli-go/api"
)
type Cli struct {
*api.ApiCli
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
return ret
}
func (c *Cli) Test() (ret []byte, err error) {
ret, err = c.HttpCli().RawPost("/ipc/autoit/test", nil)
return ret, err
}
func (c *Cli) Do(data string) (ret []byte, err error) {
i := []byte(data)
ret, err = c.HttpCli().RawPost("/ipc/autoit/do", i)
return ret, err
}

View File

@ -3,6 +3,7 @@ package chrome
import (
"encoding/json"
"fmt"
"go.digitalcircle.com.br/open/replaycli-go/api"
)
@ -10,11 +11,18 @@ type Cli struct {
*api.ApiCli
}
//func (c *Cli) HttpCli() *httpcli.Cli {
// return c.ApiCli.HttpCli()
//}
type TabMetadata struct {
Description string `json:"description"`
DevtoolsFrontendUrl string `json:"devtoolsFrontendUrl"`
Id string `json:"id"`
Title string `json:"title"`
Type string `json:"type"`
Url string `json:"url"`
WebSocketDebuggerUrl string `json:"webSocketDebuggerUrl"`
}
func (c *Cli) Start(to int) error {
// to -> Time out para a conexão com o Chrome. Dado em segundos.
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/chrome/start?to=%d", to), nil)
return err
}
@ -27,39 +35,76 @@ func (c *Cli) Stop() error {
return err
}
func (c *Cli) New(url string) (string, error) {
// url -> Site no qual se quer iniciar uma nova aba.
ret := ""
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/chrome/new?url=%s", url), &ret)
return ret, err
// ret -> ID do Websocket criado para navegação na "url" informada.
}
func (c *Cli) Close(id string) error {
// id -> ID do websocket ativo. É o primeiro retorno do método "New".
err := c.HttpCli().JsonGet("/ipc/chrome/close/"+id, nil)
return err
}
func (c *Cli) Eval(id string, s string) (map[string]interface{}, error) {
// id -> ID do websocket no qual se quer fazer um comando JavaScript.
// s -> Comando JavaScript a ser executado no terminal web do WebSocket informado.
ret := make(map[string]interface{})
bs, err := c.HttpCli().RawPost("/ipc/chrome/eval/"+id, []byte(s))
json.Unmarshal(bs, &ret)
return ret, err
// ret -> O valor retornado pelo comando JavaScript executado.
}
func (c *Cli) Wait(id string, s string, to int) (string, error) {
// id -> ID do websocket no qual se quer fazer um comando JavaScript.
// s -> Comando JavaScript a ser executado no terminal web do WebSocket informado. Deve ser uma expressão que retorne um valor booleano para, por exemplo, verificar se um elemento já foi carregado.
// to -> TimeOut de espera para retorno "true" da expressão JavaScript informada. Informado em segundos.
ret := ""
bs, err := c.HttpCli().RawPost(fmt.Sprintf("/ipc/chrome/wait/%s?to=%d", id, to), []byte(s))
json.Unmarshal(bs, &ret)
return ret, err
}
func (c *Cli) Send(id string, m string, ps map[string]interface{}) (string, error) {
ret := ""
func (c *Cli) Send(id string, m string, ps map[string]interface{}) (interface{}, error) {
// id -> ID do Websocket no qual se deseja realizar a alteração.
var ret interface{}
in := map[string]interface{}{
"method": m,
"params": ps,
}
err := c.HttpCli().JsonPost("/ipc/chrome/eval/"+id, in, &ret)
err := c.HttpCli().JsonPost("/ipc/chrome/send/"+id, in, &ret)
return ret, err
// ret -> Retorno do comando (Referência em: https://chromedevtools.github.io/devtools-protocol/)
}
func (c *Cli) OpenTabs() (ret []map[string]string, err error) {
err = c.HttpCli().JsonGet("/ipc/chrome/opentabs", &ret)
return ret, err
// ret -> Array contendo as abas abertas e metadados sobre as mesmas.
}
func (c *Cli) FindTabByUrl(url string) (ret string, err error) {
// url -> URL ativa em uma das abas abertas.
err = c.HttpCli().JsonGet("/ipc/chrome/findtabbyurl/"+url, &ret)
return ret, err
// ret -> ID do WebSocket contendo a aba encontrada.
}
func (c *Cli) FindUrlById(id string) (ret string, err error) {
// url -> URL ativa em uma das abas abertas.
err = c.HttpCli().JsonGet("/ipc/chrome/findurlbyid/"+id, &ret)
return ret, err
// ret -> Url da aba encontrada.
}
func (c *Cli) FindTabByTitle(title string) (ret string, err error) {
// title -> Título de uma das abas abertas.
err = c.HttpCli().JsonGet("/ipc/chrome/findtabbytitle/"+title, &ret)
return ret, err
// ret -> ID do WebSocket contendo a aba encontrada.
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
return ret
// ret -> Nova instância do Chrome para utilização.
}

View File

@ -1,6 +1,9 @@
package dataapi
import (
"strconv"
"time"
"go.digitalcircle.com.br/open/httpcli"
)
@ -43,3 +46,86 @@ func NewCli(apikey string) *Cli {
ret.Httpcli.SetBasePath("https://dataapi.digitalcircle.com.br")
return ret
}
func RegistrarExec(table, apikey string, check bool, checkC bool) {
//Para robôs, age como contador e registra cada repetição no mês
c := NewCli(apikey)
var registros int
var erro int
captReg := 0
current := time.Now().Format("2006-01")
res, err := c.Do(&DataAPIRequest{
Col: table,
Op: RETRIEVE,
Q: "@[?date=='" + current + "']",
})
if err != nil {
panic(err)
}
if len(res.Data) > 0 {
if check {
result := res.Data[0].(map[string]interface{})
registros = int(result["exec"].(float64))
registros = registros + 1
captReg = int(result["capt"].(float64))
if checkC {
captReg = captReg + 1
}
ident := strconv.Itoa(int(result["ID"].(float64)))
_, err = c.Do(&DataAPIRequest{
Col: table,
Op: UPDATE,
Id: ident,
Data: map[string]interface{}{
"exec": registros,
"capt": captReg,
},
})
if err != nil {
panic(err)
}
} else {
result := res.Data[0].(map[string]interface{})
registros = int(result["err"].(float64))
registros = registros + 1
ident := strconv.Itoa(int(result["ID"].(float64)))
_, err = c.Do(&DataAPIRequest{
Col: table,
Op: UPDATE,
Id: ident,
Data: map[string]interface{}{
"err": registros,
},
})
if err != nil {
panic(err)
}
}
} else {
if check {
registros = 1
erro = 0
if checkC {
captReg = 1
}
} else {
registros = 0
erro = 1
}
_, err = c.Do(&DataAPIRequest{
Col: table,
Op: CREATE,
Data: map[string]interface{}{
"date": current,
"exec": registros,
"err": erro,
"capt": captReg,
},
})
if err != nil {
panic(err)
}
}
}

View File

@ -1,15 +1,18 @@
package dataapi_test
import (
"go.digitalcircle.com.br/open/replaycli-go/api/dataapi"
"log"
"strconv"
"testing"
"time"
"go.digitalcircle.com.br/open/replaycli-go/api/dataapi"
)
func TestAPIRetrieve(t *testing.T) {
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
c := dataapi.NewCli()
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Col: "teste3",
Op: dataapi.RETRIEVE,
})
if err != nil {
@ -20,7 +23,7 @@ func TestAPIRetrieve(t *testing.T) {
}
func TestAPIRetrieveWQuery(t *testing.T) {
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
c := dataapi.NewCli()
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.RETRIEVE,
@ -34,7 +37,7 @@ func TestAPIRetrieveWQuery(t *testing.T) {
}
func TestAPIUpdate(t *testing.T) {
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
c := dataapi.NewCli()
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.UPDATE,
@ -51,7 +54,7 @@ func TestAPIUpdate(t *testing.T) {
}
func TestAPIDelete(t *testing.T) {
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
c := dataapi.NewCli()
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.DELETE,
@ -65,18 +68,78 @@ func TestAPIDelete(t *testing.T) {
}
func TestAPICreate(t *testing.T) {
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
if true {
print("a")
print("b")
}
c := dataapi.NewCli()
var registros int
var erro int
current := time.Now().Format("2006-01")
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.CREATE,
Data: map[string]interface{}{
"MSG": "OI LEO",
},
Col: "teste3",
Op: dataapi.RETRIEVE,
Q: "@[?date=='" + current + "']",
})
if err != nil {
t.Fatal(err.Error())
panic(err)
}
check := false
if len(res.Data) > 0 {
if check {
result := res.Data[0].(map[string]interface{})
registros = int(result["exec"].(float64))
registros = registros + 1
ident := strconv.Itoa(int(result["ID"].(float64)))
log.Printf("%#v", res)
_, err = c.Do(&dataapi.DataAPIRequest{
Col: "teste3",
Op: dataapi.UPDATE,
Id: ident,
Data: map[string]interface{}{
"exec": registros,
},
})
if err != nil {
panic(err)
}
} else {
result := res.Data[0].(map[string]interface{})
registros = int(result["err"].(float64))
registros = registros + 1
ident := strconv.Itoa(int(result["ID"].(float64)))
_, err = c.Do(&dataapi.DataAPIRequest{
Col: "teste3",
Op: dataapi.UPDATE,
Id: ident,
Data: map[string]interface{}{
"err": registros,
},
})
if err != nil {
panic(err)
}
}
} else {
if check {
registros = 1
erro = 0
} else {
registros = 0
erro = 1
}
_, err = c.Do(&dataapi.DataAPIRequest{
Col: "teste3",
Op: dataapi.CREATE,
Data: map[string]interface{}{
"date": current,
"exec": registros,
"err": erro,
},
})
if err != nil {
panic(err)
}
}
}

View File

@ -43,7 +43,6 @@ func (c *Cli) Write(fname string, sheet string, cell string, val string, celtype
err := c.HttpCli().JsonPost("/ipc/excel/write", req, &res)
return err
}
func (c *Cli) New(fname string, sheet string) (string, error) {
req := &Req{
File: fname,

View File

@ -16,11 +16,15 @@ type Cli struct {
*api.ApiCli
}
//Log saves log to database after populated
func (c *Cli) Log(l *types.Log) error {
l.Alias = c.ReplayEnvAlias()
l.Dtlogend = time.Now()
return c.HttpCli().JsonPost("/api/v1/log/add", l, nil)
}
//NewLog creates a new log instance in the client, capable of collecting data in memory for later saving it to the
//database by calling Log
func (c *Cli) NewLog() *types.Log {
ret := &types.Log{}
ret.Alias = c.ReplayEnvAlias()
@ -46,6 +50,11 @@ func (c *Cli) ReplayEnvAddr() string {
func (c *Cli) ReplayEnvHomeDir() string {
return os.Getenv("REPLAY_HOMEDIR")
}
func (c *Cli) ReplayPort() string {
return os.Getenv("REPLAY_PORT")
}
func (c *Cli) ReplayEnvRepo() string {
return os.Getenv("REPLAY_REPO")
}
@ -118,15 +127,20 @@ func (c *Cli) QueueGetData(id string) (ret []byte, err error) {
ret, err = c.HttpCli().RawGet("/api/v1/queue/getrequest/" + id)
return
}
func (c *Cli) QueueGetDataBody(id string) (ret []byte, err error) {
ret, err = c.HttpCli().RawGet("/api/v1/queue/getrequestbody/" + id)
return
}
func (c *Cli) QueueGetMyData() ([]byte, error) {
return c.QueueGetData(os.Getenv("REPLAY_QUEUEID"))
}
func (c *Cli) QueueGetMyJson(i interface{}) error {
func (c *Cli) QueueGetMyJson(i *interface{}) error {
bs, err := c.QueueGetData(os.Getenv("REPLAY_QUEUEID"))
if err != nil {
return err
}
err = json.Unmarshal(bs, i)
err = json.Unmarshal(bs, &i)
return err
}
func (c *Cli) QueueAbort() error {
@ -136,6 +150,14 @@ func (c *Cli) QueueEnqueue(id uint) error {
return c.HttpCli().JsonGet(fmt.Sprintf("/api/v1/robots/op/enqueue/%d", id), nil)
}
func (c *Cli) QueueEnqueueWData(id string, bs []byte) ([]byte, error) {
return c.HttpCli().RawPost(fmt.Sprintf("api/v1/queue/add/%s", id), bs)
}
func (c *Cli) QueueEnqueueWDataWait(id string, bs []byte) ([]byte, error) {
return c.HttpCli().RawPost(fmt.Sprintf("api/v1/queue/addwait?job=%s", id), bs)
}
func (c *Cli) ServiceStopAll() error {
return c.HttpCli().JsonGet("/api/v1/service/op/stopall", nil)
}

View File

@ -10,14 +10,59 @@ type Cli struct {
*api.ApiCli
}
//func (c *Cli) HttpCli() *api.Cli {
// return c.cli
//}
const (
CCHDEVICENAME = 32
CCHFORMNAME = 32
ENUM_CURRENT_SETTINGS uint32 = 0xFFFFFFFF
ENUM_REGISTRY_SETTINGS uint32 = 0xFFFFFFFE
DISP_CHANGE_SUCCESSFUL uint32 = 0
DISP_CHANGE_RESTART uint32 = 1
DISP_CHANGE_FAILED uint32 = 0xFFFFFFFF
DISP_CHANGE_BADMODE uint32 = 0xFFFFFFFE
)
type DEVMODE struct {
DmDeviceName [CCHDEVICENAME]uint16
DmSpecVersion uint16
DmDriverVersion uint16
DmSize uint16
DmDriverExtra uint16
DmFields uint32
DmOrientation int16
DmPaperSize int16
DmPaperLength int16
DmPaperWidth int16
DmScale int16
DmCopies int16
DmDefaultSource int16
DmPrintQuality int16
DmColor int16
DmDuplex int16
DmYResolution int16
DmTTOption int16
DmCollate int16
DmFormName [CCHFORMNAME]uint16
DmLogPixels uint16
DmBitsPerPel uint32
DmPelsWidth uint32
DmPelsHeight uint32
DmDisplayFlags uint32
DmDisplayFrequency uint32
DmICMMethod uint32
DmICMIntent uint32
DmMediaType uint32
DmDitherType uint32
DmReserved1 uint32
DmReserved2 uint32
DmPanningWidth uint32
DmPanningHeight uint32
}
/***************** Clip Functions *****************/
func (c *Cli) ClipRead() (string, error) {
ret := ""
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/clip/read"), &ret)
return ret, err
bs, err := c.HttpCli().RawGet("/ipc/wingui/clip/read")
return string(bs), err
}
func (c *Cli) ClipWrite(site string) error {
@ -25,39 +70,39 @@ func (c *Cli) ClipWrite(site string) error {
return err
}
/***************** Mouse Functions *****************/
func (c *Cli) MouseClick() error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/mouse/click"), nil)
err := c.HttpCli().JsonGet("/ipc/wingui/mouse/click", nil)
return err
}
func (c *Cli) MouseMove(x, y int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/mouse/move?x=%d&y=%d", x, y), nil)
return err
}
func (c *Cli) MouseMoveRelative(x, y int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/mouse/moverelative?x=%d&y=%d", x, y), nil)
return err
}
func (c *Cli) MouseClickRelative(x, y int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/mouse/clickatrelative?x=%d&y=%d", x, y), nil)
return err
}
func (c *Cli) MouseClickAt(x, y int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/mouse/clickat?x=%d&y=%d", x, y), nil)
return err
}
func (c *Cli) ScreenClick(f string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/click?f=%s", f), nil)
func (c *Cli) MouseDrag(x, y int, btn string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/mouse/drag?x=%d&y=%d&btn=%s", x, y, btn), nil)
return err
}
func (c *Cli) ScreenClickCenter(f string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/clickcenter?f=%s", f), nil)
return err
}
func (c *Cli) ScreenFind(f string) (ret map[string]interface{}, err error) {
ret = make(map[string]interface{})
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/find?f=%s", f), &ret)
return
}
/***************** KB Functions *****************/
func (c *Cli) KBTap(t string) (map[string]interface{}, error) {
/*Envia uma tecla ou teclas para serem clicadas no componente com foco onde o robo é executado
@ -168,6 +213,147 @@ func (c *Cli) KBType(t string) (map[string]interface{}, error) {
return ret, err
}
func (c *Cli) KBToggle(str string) error {
err := c.HttpCli().JsonGet("/ipc/wingui/kb/toggle?str="+str, nil)
return err
}
/***************** Display Functions *****************/
func (c *Cli) DisplayRes() (*DEVMODE, error) {
ret := &DEVMODE{}
err := c.HttpCli().JsonGet("/ipc/wingui/display/res", ret)
return ret, err
}
func (c *Cli) DisplaySetRes(d *DEVMODE) error {
err := c.HttpCli().JsonPost("/ipc/wingui/display/setres", d, nil)
return err
}
/***************** Draw Functions *****************/
func (c *Cli) DrawCLear() error {
err := c.HttpCli().JsonGet("/ipc/draw/clear", nil)
return err
}
func (c *Cli) DrawBox(x, y, w, h, t int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/draw/addbox?x=%d&y=%d&w=%d&h=%d&t=%d", x, y, w, h, t), nil)
return err
}
func (c *Cli) DrawRect(x, y, w, h int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/draw/addrect?x=%d&y=%d&w=%d&h=%d", x, y, w, h), nil)
return err
}
func (c *Cli) DrawAddText(t string, x, y int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/draw/addtext?t=%s&x=%d&y=%d", t, x, y), nil)
return err
}
/***************** Notify Functions *****************/
func (c *Cli) NotifyAlert(msg, title string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/notify/alert?msg=%s&title=%s", msg, title), nil)
return err
}
func (c *Cli) NotifyBeep(msg, title string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/notify/notify?msg=%s&title=%s", msg, title), nil)
return err
}
/***************** Window Functions *****************/
func (c *Cli) WindowList(s string) (ret []map[string]interface{}, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/window/list?s="+s, &ret)
return ret, err
}
func (c *Cli) WindowHwnd(s string) (ret []int, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/window/hwnd?s="+s, &ret)
return ret, err
}
func (c *Cli) WindowActivate(Hwnd string) error {
err := c.HttpCli().JsonGet("/ipc/wingui/window/activate?Hwnd="+Hwnd, nil)
return err
}
func (c *Cli) WindowClose(Hwnd string) error {
err := c.HttpCli().JsonGet("/ipc/wingui/window/close?Hwnd="+Hwnd, nil)
return err
}
func (c *Cli) WindowMax(Hwnd string) error {
err := c.HttpCli().JsonGet("/ipc/wingui/window/max?Hwnd="+Hwnd, nil)
return err
}
func (c *Cli) WindowMin(Hwnd string) error {
err := c.HttpCli().JsonGet("/ipc/wingui/window/min?Hwnd="+Hwnd, nil)
return err
}
func (c *Cli) WindowActiveHwnd() (ret int, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/window/activehwnd", &ret)
return ret, err
}
func (c *Cli) WindowWaitActiveTitle(t string, m int) (ret map[string]interface{}, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/window/waitactivetitle?t=%s&m=%d", t, m), &ret)
return ret, err
}
func (c *Cli) WindowActiveTitle() (ret string, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/window/activetitle", &ret)
return ret, err
}
/*func (c *Cli) WindowWinfo(w int) (ret interface{}, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/window/winfo?w=%d", w), &ret)
return ret, err
}
func (c *Cli) WindowSendMsg(w, m string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/window/sendmsg?w=%s&m=%s", w, m), nil)
return err
}
func (c *Cli) WindowPostMsg(w, m string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/window/postmsg?w=%s&m=%s", w, m), nil)
return err
}*/
/***************** Screen Functions *****************/
func (c *Cli) ScreenCapture(x, y, w, h int, f string) (ret interface{}, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/capture?x=%d&y=%d&w=%d&h=%d&f=%s", x, y, w, h, f), &ret)
return ret, err
}
func (c *Cli) ScreenFindAll(f string) (ret map[string]int, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/screen/findall?f="+f, &ret)
return ret, err
}
func (c *Cli) ScreenClick(f string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/click?f=%s", f), nil)
return err
}
func (c *Cli) ScreenClickCenter(f string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/clickcenter?f=%s", f), nil)
return err
}
func (c *Cli) ScreenFind(f string) (ret []interface{}, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/find?f=%s", f), &ret)
return
}
func (c *Cli) ScreenWait(f string, m int) ([]byte, error) {
url := fmt.Sprintf("/ipc/wingui/screen/wait?f=%s&m=%d", f, m)
@ -178,6 +364,7 @@ func (c *Cli) ScreenWait(f string, m int) ([]byte, error) {
fmt.Println(ret)
return ret, err
}
func (c *Cli) ScreenWaitClick(f string, m int) ([]byte, error) {
url := fmt.Sprintf("/ipc/wingui/screen/waitclick?f=%s&m=%d", f, m)
@ -188,6 +375,7 @@ func (c *Cli) ScreenWaitClick(f string, m int) ([]byte, error) {
fmt.Println(ret)
return ret, err
}
func (c *Cli) ScreenWaitClickCenter(f string, m int) ([]byte, error) {
url := fmt.Sprintf("/ipc/wingui/screen/waitclickcenter?f=%s&m=%d", f, m)
@ -200,7 +388,7 @@ func (c *Cli) ScreenWaitClickCenter(f string, m int) ([]byte, error) {
}
func (c *Cli) ScreenRes() ([]byte, error) {
url := fmt.Sprintf("/ipc/wingui/screen/res")
url := "/ipc/wingui/screen/res"
ret, err := c.HttpCli().RawGet(url)
if err != nil {
@ -208,11 +396,146 @@ func (c *Cli) ScreenRes() ([]byte, error) {
}
return ret, err
}
func (c *Cli) ScreenSetRes(x, y, cor int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/screen/setres?x=%d&y=%d&c=%d", x, y, cor), nil)
return err
}
func (c *Cli) ScreenScale() (ret []int, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/screen/scale", &ret)
return ret, err
}
func (c *Cli) ScreenSize() (ret []int, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/screen/size", &ret)
return ret, err
}
func (c *Cli) ScreenShot(frmt string) (ret []byte, err error) {
url := fmt.Sprintf("/ipc/wingui/screen/shot?fmt=%s", frmt)
ret, err = c.HttpCli().RawGet(url)
if err != nil {
fmt.Print(err.Error())
}
return ret, err
}
func (c *Cli) ScreenDsInternal() error {
err := c.HttpCli().JsonGet("/ipc/wingui/screen/dsinternal", nil)
return err
}
func (c *Cli) ScreenDsExternal() error {
err := c.HttpCli().JsonGet("/ipc/wingui/screen/dsexternal", nil)
return err
}
func (c *Cli) ScreenDsClone() error {
err := c.HttpCli().JsonGet("/ipc/wingui/screen/dsclone", nil)
return err
}
func (c *Cli) ScreenDsExtend() error {
err := c.HttpCli().JsonGet("/ipc/wingui/screen/dsextend", nil)
return err
}
/***************** Dialog Functions *****************/
func (c *Cli) DialogColor(t, d string) (ret map[string]int, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/color?t=%s&d=%s", t, d), &ret)
return ret, err
}
func (c *Cli) DialogDate(t, m, d, f string) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/date?t=%s&m=%s&d=%s&f=%s", t, m, d, f), &ret)
return ret, err
}
func (c *Cli) DialogEntry(t, m, d string) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/entry?t=%s&m=%s&d=%s", t, m, d), &ret)
return ret, err
}
func (c *Cli) DialogError(t, m string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/error?t=%s&m=%s", t, m), nil)
return err
}
func (c *Cli) DialogFile(t, f, d string) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/file?t=%s&f=%s&d=%s", t, f, d), &ret)
return ret, err
}
func (c *Cli) DialogFileMulti(t, f string) (ret []string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/filemulti?t=%s&f=%s", t, f), &ret)
return ret, err
}
func (c *Cli) DialogInfo(t, m string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/info?t=%s&m=%s", t, m), nil)
return err
}
func (c *Cli) DialogList(t, m, f string) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/list?t=%s&m=%s&f=%s", t, m, f), &ret)
return ret, err
}
func (c *Cli) DialogListMulti(t, m, f string) (ret []string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/listmulti?t=%s&m=%s&f=%s", t, m, f), &ret)
return ret, err
}
func (c *Cli) DialogPassword(t, m string) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/password?t=%s&m=%s", t, m), &ret)
return ret, err
}
func (c *Cli) DialogQuestion(t, m string) (ret bool, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/question?t=%s&m=%s", t, m), &ret)
return ret, err
}
func (c *Cli) DialogWarn(t, m string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/dialog/warn?t=%s&m=%s", t, m), nil)
return err
}
/***************** Process Functions *****************/
func (c *Cli) ProcAll() (ret []map[string]interface{}, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/proc/all", &ret)
return ret, err
}
func (c *Cli) ProcPids() (ret []int, err error) {
err = c.HttpCli().JsonGet("/ipc/wingui/proc/pids", &ret)
return ret, err
}
func (c *Cli) ProcKill(cmd int) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/proc/kill?cmd=%d", cmd), &ret)
return ret, err
}
func (c *Cli) ProcExec(cmd string) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/proc/exec?cmd=%s", cmd), nil)
return err
}
func (c *Cli) ProcName(pid int) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/proc/name?pid=%d", pid), &ret)
return ret, err
}
func (c *Cli) ProcPath(pid int) (ret string, err error) {
err = c.HttpCli().JsonGet(fmt.Sprintf("/ipc/wingui/proc/path?pid=%d", pid), &ret)
return ret, err
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
return ret

4
go.mod
View File

@ -6,9 +6,9 @@ go 1.17
// go.digitalcircle.com.br/open/httpcli => ../httpcli
//)
require (
github.com/Microsoft/go-winio v0.5.1
github.com/Microsoft/go-winio v0.5.2
github.com/gorilla/websocket v1.4.2
github.com/mitchellh/go-ps v1.0.0
go.digitalcircle.com.br/open/httpcli v0.0.0-20211031093505-ecf33aed8afb
golang.org/x/sys v0.0.0-20211031064116-611d5d643895 // indirect
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect
)

6
go.sum
View File

@ -2,6 +2,8 @@ github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXG
github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY=
github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
@ -21,3 +23,7 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyX
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211031064116-611d5d643895 h1:iaNpwpnrgL5jzWS0vCNnfa8HqzxveCFpFx3uC/X4Tps=
golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211106132015-ebca88c72f68 h1:Ywe/f3fNleF8I6F6qv3MeFoSZ6CTf2zBMMa/7qVML8M=
golang.org/x/sys v0.0.0-20211106132015-ebca88c72f68/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 h1:nhht2DYV/Sn3qOayu8lM+cU1ii9sTLUeBQwQQfUHtrs=
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

View File

@ -214,7 +214,11 @@ type Log struct {
}
func (l *Log) Write(p []byte) (n int, err error) {
os.Stdout.Write([]byte(fmt.Sprintf("- %s\n", string(p))))
_, err = os.Stdout.Write([]byte(fmt.Sprintf("- %s\n", string(p))))
if err != nil {
println(fmt.Sprintf("Log.Write:: Error writing log: %s", err.Error()))
return 0, err
}
l.AddHistory(string(p))
return len(p), nil
}
@ -228,6 +232,11 @@ func (l *Log) AddHistory(s string) {
}
}
func (l *Log) Printf(s string, i ...interface{}) {
l.AddHistory(fmt.Sprintf(s, i...))
s = fmt.Sprintf("* %s: %s", time.Now().Format("02/01/06 - 15:04:05"), s)
}
type LogQuery struct {
From time.Time `json:"from"`
Until time.Time `json:"until"`
@ -303,9 +312,11 @@ type Cron struct {
Model
Cron string `json:"cron"`
JobCode uint `json:"job"`
JobAlias string `json:"jobalias" gorm:"-"`
Enabled *bool `json:"enabled"`
Data string `json:"data"`
Comments string `json:"comments"`
Once bool `json:"once"`
}
//type Resource struct {