├── LICENSE ├── README.md ├── go.mod ├── go.sum └── main.go /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2018 Jorick Caberio 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## ucp-cli 2 | 3 | command-line interface for sending and receiving SMS via UCP protocol 4 | 5 | #### setup 6 | 7 | - go 1.11 8 | - git 9 | 10 | #### demo 11 | 12 | ![demo]( 13 | https://thumbs.gfycat.com/HorribleWelcomeAcouchi-size_restricted.gif) 14 | 15 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-gsm/ucp-cli 2 | 3 | require ( 4 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e 5 | github.com/go-gsm/ucp v0.0.1 6 | ) 7 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= 2 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= 3 | github.com/go-gsm/charset v1.0.0 h1:6k6LOKHtxgCPXE15X0unRewjOksyhmHBIp6x7qLQ6Ls= 4 | github.com/go-gsm/charset v1.0.0/go.mod h1:sC8+2VpAM2sZDlxv11MxWIZiuf8MipOgM/hCYsRQRps= 5 | github.com/go-gsm/ucp v0.0.1 h1:vM5ly5iRNGMGGiVx4K3+puF9AhpwkC76BkiV9LFv0bw= 6 | github.com/go-gsm/ucp v0.0.1/go.mod h1:58/PrXWFcmaQyZ5p/Dp2YiCnhlVx0HdKXFGmqiVO/mI= 7 | golang.org/x/net v0.0.0-20181102091132-c10e9556a7bc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 8 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM= 9 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 10 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "strings" 7 | 8 | "github.com/chzyer/readline" 9 | "github.com/go-gsm/ucp" 10 | ) 11 | 12 | func main() { 13 | opt := &ucp.Options{ 14 | Addr: fmt.Sprintf("%s:%s", os.Getenv("SMSC_HOST"), os.Getenv("SMSC_PORT")), 15 | User: os.Getenv("SMSC_USER"), 16 | Password: os.Getenv("SMSC_PASSWORD"), 17 | AccessCode: os.Getenv("SMSC_ACCESSCODE"), 18 | } 19 | 20 | client := ucp.New(opt) 21 | if err := client.Connect(); err != nil { 22 | fmt.Println("Cant connect") 23 | os.Exit(1) 24 | } 25 | defer client.Close() 26 | 27 | reader, _ := readline.New(">>> ") 28 | defer reader.Close() 29 | 30 | for { 31 | fmt.Print(">>> ") 32 | lines, _ := reader.Readline() 33 | fields := strings.Fields(lines) 34 | 35 | if len(fields) == 1 { 36 | // exit CLI 37 | if fields[0] == "exit" { 38 | return 39 | } 40 | // display help message 41 | if fields[0] == "help" { 42 | fmt.Println("\n\tSend a 'message' to 'receiver' with a 'sender' mask\n\t>>> sender receiver message\n\n\tExit the cli\n\t>>> exit\n") 43 | } 44 | } 45 | 46 | // sender receiver message... 47 | if len(fields) >= 3 { 48 | sender := fields[0] 49 | receiver := fields[1] 50 | message := strings.Join(fields[2:], " ") 51 | ids, err := client.Send(sender, receiver, message) 52 | if err != nil { 53 | fmt.Println(err) 54 | } else { 55 | fmt.Printf("%v\n", ids) 56 | } 57 | } 58 | } 59 | } 60 | --------------------------------------------------------------------------------