Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2db7e51327 | ||
|
|
e698b66819 | ||
|
|
7fdafb477a | ||
|
|
13632156a1 | ||
|
|
08b69673e3 | ||
|
|
36b8bdac2f | ||
|
|
43c5795cc7 | ||
|
|
2063aeec91 | ||
|
|
310e9fa2ab | ||
|
|
c860542052 | ||
|
|
172fad115b |
@@ -43,7 +43,6 @@ This is a WIP. Heres some things you might expect to work that don't. Plus some
|
||||
|
||||
- Only shows existing chats
|
||||
- Only fetches a few old messages
|
||||
- Names have to be entered with the `/name` or `/addname` commands
|
||||
- No support for images, videos, documents etc.
|
||||
- No incoming message notification / count
|
||||
- No proper connection drop handling
|
||||
|
||||
8
go.mod
8
go.mod
@@ -3,16 +3,16 @@ module github.com/normen/whatscli
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/Rhymen/go-whatsapp v0.1.1-0.20201007125822-005103751b7a
|
||||
github.com/Rhymen/go-whatsapp v0.1.1-0.20201117204225-79ad714fa46a
|
||||
github.com/gdamore/tcell/v2 v2.0.1-0.20201017141208-acf90d56d591
|
||||
github.com/golang/protobuf v1.4.3 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/mattn/go-colorable v0.1.8
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/rivo/tview v0.0.0-20201018122409-d551c850a743
|
||||
github.com/rivo/tview v0.0.0-20201117185959-f9f2182520da
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
golang.org/x/crypto v0.0.0-20201116153603-4be66e5b6582 // indirect
|
||||
golang.org/x/sys v0.0.0-20201116194326-cc9327a14d48 // indirect
|
||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 // indirect
|
||||
golang.org/x/sys v0.0.0-20201117170446-d9b008d0a637 // indirect
|
||||
golang.org/x/text v0.3.4 // indirect
|
||||
google.golang.org/protobuf v1.25.0 // indirect
|
||||
)
|
||||
|
||||
13
go.sum
13
go.sum
@@ -7,10 +7,14 @@ github.com/Rhymen/go-whatsapp v0.1.0 h1:XTXhFIQ/fx9jKObUnUX2Q+nh58EyeHNhX7DniE8x
|
||||
github.com/Rhymen/go-whatsapp v0.1.0/go.mod h1:xJSy+okeRjKkQEH/lEYrnekXB3PG33fqL0I6ncAkV50=
|
||||
github.com/Rhymen/go-whatsapp v0.1.1-0.20201007125822-005103751b7a h1:LW+rX0NY6LzMPa2hJcgmQlfiFJUihzOMAaIoCq+P3xc=
|
||||
github.com/Rhymen/go-whatsapp v0.1.1-0.20201007125822-005103751b7a/go.mod h1:o7jjkvKnigfu432dMbQ/w4PH0Yp5u4Y6ysCNjUlcYCk=
|
||||
github.com/Rhymen/go-whatsapp v0.1.1-0.20201117204225-79ad714fa46a h1:IhYU0cQ0cvMO9MOuOO08X8zUtMQ+AVIV0D+7eZVtHe8=
|
||||
github.com/Rhymen/go-whatsapp v0.1.1-0.20201117204225-79ad714fa46a/go.mod h1:o7jjkvKnigfu432dMbQ/w4PH0Yp5u4Y6ysCNjUlcYCk=
|
||||
github.com/Rhymen/go-whatsapp/examples/echo v0.0.0-20190325075644-cc2581bbf24d/go.mod h1:zgCiQtBtZ4P4gFWvwl9aashsdwOcbb/EHOGRmSzM8ME=
|
||||
github.com/Rhymen/go-whatsapp/examples/restoreSession v0.0.0-20190325075644-cc2581bbf24d/go.mod h1:5sCUSpG616ZoSJhlt9iBNI/KXBqrVLcNUJqg7J9+8pU=
|
||||
github.com/Rhymen/go-whatsapp/examples/sendImage v0.0.0-20190325075644-cc2581bbf24d/go.mod h1:RdiyhanVEGXTam+mZ3k6Y3VDCCvXYCwReOoxGozqhHw=
|
||||
github.com/Rhymen/go-whatsapp/examples/sendTextMessages v0.0.0-20190325075644-cc2581bbf24d/go.mod h1:suwzklatySS3Q0+NCxCDh5hYfgXdQUWU1DNcxwAxStM=
|
||||
github.com/SchulteMK/go-whatsapp v0.0.0-20201117193111-50e7347bfbb6 h1:Rsit49rPlurIGzQn9VGOPph0pNjUX+bo+9Lg51D8rn0=
|
||||
github.com/SchulteMK/go-whatsapp v0.0.0-20201117193111-50e7347bfbb6/go.mod h1:o7jjkvKnigfu432dMbQ/w4PH0Yp5u4Y6ysCNjUlcYCk=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
@@ -68,8 +72,12 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/rivo/tview v0.0.0-20201018122409-d551c850a743 h1:9BBjVJTRxuYBeCAv9DFH2hSzY0ujLx5sxMg5D3K/Xeg=
|
||||
github.com/rivo/tview v0.0.0-20201018122409-d551c850a743/go.mod h1:t7mcA3nlK9dxD1DMoz/DQRMWFMkGBUj6rJBM5VNfLFA=
|
||||
github.com/rivo/tview v0.0.0-20201117185959-f9f2182520da h1:XUh+g7tjO81Ph5+7GSco4VLrBbQPnakm8M6sQU+fT5Y=
|
||||
github.com/rivo/tview v0.0.0-20201117185959-f9f2182520da/go.mod h1:0ha5CGekam8ZV1kxkBxSlh7gfQ7YolUj2P/VruwH0QY=
|
||||
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9 h1:lpEzuenPuO1XNTeikEmvqYFcU37GVLl8SRNblzyvGBE=
|
||||
github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9/go.mod h1:PLPIyL7ikehBD1OAjmKKiOEhbvWyHGaNDjquXMcYABo=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||
@@ -79,6 +87,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90Pveol
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20201116153603-4be66e5b6582 h1:0WDrJ1E7UolDk1KhTXxxw3Fc8qtk5x7dHP431KHEJls=
|
||||
golang.org/x/crypto v0.0.0-20201116153603-4be66e5b6582/go.mod h1:tCqSYrHVcf3i63Co2FzBkTCo2gdF6Zak62921dSfraU=
|
||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 h1:phUcVbl53swtrUN8kQEXFhUxPlIlWyBfKmidCu7P95o=
|
||||
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
@@ -106,7 +116,10 @@ golang.org/x/sys v0.0.0-20201017003518-b09fb700fbb7 h1:XtNJkfEjb4zR3q20BBBcYUykV
|
||||
golang.org/x/sys v0.0.0-20201017003518-b09fb700fbb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201116194326-cc9327a14d48 h1:AYCWBZhgIw6XobZ5CibNJr0Rc4ZofGGKvWa1vcx2IGk=
|
||||
golang.org/x/sys v0.0.0-20201116194326-cc9327a14d48/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201117170446-d9b008d0a637 h1:O5hKNaGxIT4A8OTMnuh6UpmBdI3SAPxlZ3g0olDrJVM=
|
||||
golang.org/x/sys v0.0.0-20201117170446-d9b008d0a637/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201113234701-d7a72108b828/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
|
||||
70
main.go
70
main.go
@@ -15,7 +15,7 @@ type waMsg struct {
|
||||
Text string
|
||||
}
|
||||
|
||||
var VERSION string = "v0.4.2"
|
||||
var VERSION string = "v0.5.1"
|
||||
|
||||
var sendChannel chan waMsg
|
||||
var textChannel chan whatsapp.TextMessage
|
||||
@@ -36,8 +36,6 @@ var contactRoot *tview.TreeNode
|
||||
var handler textHandler
|
||||
var app *tview.Application
|
||||
|
||||
//var messages map[string]string
|
||||
|
||||
func main() {
|
||||
msgStore = messages.MessageDatabase{}
|
||||
msgStore.Init()
|
||||
@@ -51,7 +49,7 @@ func main() {
|
||||
|
||||
topBar = tview.NewTextView()
|
||||
topBar.SetDynamicColors(true)
|
||||
topBar.SetText("[::b] WhatsCLI " + VERSION + " [-::d]Help: /name NewName | /addname 123456 NewName | /quit | <Tab> = contacts/message | <Up/Dn> = scroll")
|
||||
topBar.SetText("[::b] WhatsCLI " + VERSION + " [-::d]Type /help for help")
|
||||
|
||||
//infoBar = tview.NewTextView()
|
||||
//infoBar.SetDynamicColors(true)
|
||||
@@ -65,7 +63,7 @@ func main() {
|
||||
app.Draw()
|
||||
})
|
||||
|
||||
fmt.Fprint(textView, "[::b]WhatsCLI "+VERSION+"\n\n[-][-::u]Commands:[-::-]\n/name NewName = name current contact\n/addname number NewName = name by number\n/load = reload contacts\n/quit = exit app\n\n[-::u]Keys:[-::-]\n<Tab> = switch input/contacts\n<Up/Dn> = scroll history")
|
||||
PrintHelp()
|
||||
|
||||
//textView.SetBorder(true)
|
||||
|
||||
@@ -75,6 +73,10 @@ func main() {
|
||||
})
|
||||
textInput.SetDoneFunc(EnterCommand)
|
||||
textInput.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
|
||||
if event.Key() == tcell.KeyCtrlE {
|
||||
app.SetFocus(treeView)
|
||||
return nil
|
||||
}
|
||||
if event.Key() == tcell.KeyTab {
|
||||
app.SetFocus(treeView)
|
||||
return nil
|
||||
@@ -117,22 +119,47 @@ func main() {
|
||||
app.SetFocus(textInput)
|
||||
go func() {
|
||||
if err := StartTextReceiver(); err != nil {
|
||||
fmt.Fprint(textView, "[red]", err, "[-]")
|
||||
fmt.Fprintln(textView, "[red]", err, "[-]")
|
||||
}
|
||||
}()
|
||||
app.Run()
|
||||
}
|
||||
|
||||
// prints help to chat view
|
||||
func PrintHelp() {
|
||||
fmt.Fprintln(textView, "[::b]WhatsCLI "+VERSION+"\n\n[-]")
|
||||
fmt.Fprintln(textView, "[-::u]Commands:[-::-]")
|
||||
fmt.Fprintln(textView, "/name NewName = name selected contact")
|
||||
fmt.Fprintln(textView, "/addname 1234567 NewName = add name for number")
|
||||
fmt.Fprintln(textView, "/load = reload contacts")
|
||||
fmt.Fprintln(textView, "/quit = exit app")
|
||||
fmt.Fprintln(textView, "/help = show this help\n")
|
||||
fmt.Fprintln(textView, "[-::u]Keys:[-::-]")
|
||||
fmt.Fprintln(textView, "<Tab> = switch input/contacts")
|
||||
fmt.Fprintln(textView, "<Up/Dn> = scroll history\n")
|
||||
}
|
||||
|
||||
// called when text is entered by the user
|
||||
func EnterCommand(key tcell.Key) {
|
||||
if sndTxt == "" {
|
||||
return
|
||||
}
|
||||
if key == tcell.KeyEsc {
|
||||
textInput.SetText("")
|
||||
return
|
||||
}
|
||||
if sndTxt == "/load" {
|
||||
//command
|
||||
LoadContacts()
|
||||
textInput.SetText("")
|
||||
return
|
||||
}
|
||||
if sndTxt == "/help" {
|
||||
//command
|
||||
PrintHelp()
|
||||
textInput.SetText("")
|
||||
return
|
||||
}
|
||||
if sndTxt == "/quit" {
|
||||
//command
|
||||
app.Stop()
|
||||
@@ -142,7 +169,7 @@ func EnterCommand(key tcell.Key) {
|
||||
//command
|
||||
parts := strings.Split(sndTxt, " ")
|
||||
if len(parts) < 3 {
|
||||
fmt.Fprint(textView, "Use /addname 1234567 NewName\n")
|
||||
fmt.Fprintln(textView, "Use /addname 1234567 NewName")
|
||||
return
|
||||
}
|
||||
messages.SetIdName(parts[1]+messages.CONTACTSUFFIX, strings.TrimPrefix(sndTxt, "/addname "+parts[1]+" "))
|
||||
@@ -152,7 +179,7 @@ func EnterCommand(key tcell.Key) {
|
||||
return
|
||||
}
|
||||
if currentReceiver == "" {
|
||||
fmt.Fprint(textView, "[red]No recipient set[-]\n")
|
||||
fmt.Fprintln(textView, "[red]no contact selected[-]")
|
||||
return
|
||||
}
|
||||
if strings.Index(sndTxt, "/name ") == 0 {
|
||||
@@ -172,6 +199,7 @@ func EnterCommand(key tcell.Key) {
|
||||
textInput.SetText("")
|
||||
}
|
||||
|
||||
// creates the TreeView for contacts
|
||||
func MakeTree() *tview.TreeView {
|
||||
rootDir := "Contacts"
|
||||
contactRoot = tview.NewTreeNode(rootDir).
|
||||
@@ -201,11 +229,16 @@ func MakeTree() *tview.TreeView {
|
||||
app.SetFocus(textInput)
|
||||
return nil
|
||||
}
|
||||
if event.Key() == tcell.KeyCtrlSpace {
|
||||
app.SetFocus(textInput)
|
||||
return nil
|
||||
}
|
||||
return event
|
||||
})
|
||||
return treeView
|
||||
}
|
||||
|
||||
// loads the contact data from storage to the TreeView
|
||||
func LoadContacts() {
|
||||
var ids = msgStore.GetContactIds()
|
||||
contactRoot.ClearChildren()
|
||||
@@ -225,6 +258,7 @@ func LoadContacts() {
|
||||
}
|
||||
}
|
||||
|
||||
// sets the current contact, loads text from storage to TextView
|
||||
func SetDisplayedContact(wid string) {
|
||||
currentReceiver = wid
|
||||
textView.Clear()
|
||||
@@ -232,7 +266,7 @@ func SetDisplayedContact(wid string) {
|
||||
textView.SetText(msgStore.GetMessagesString(wid))
|
||||
}
|
||||
|
||||
// StartTextReceiver starts the handler for the text messages received
|
||||
// starts the receiver and message handling thread
|
||||
func StartTextReceiver() error {
|
||||
var wac = GetConnection()
|
||||
err := LoginWithConnection(wac)
|
||||
@@ -256,11 +290,12 @@ func StartTextReceiver() error {
|
||||
messages.SetIdName(contact.Jid, contact.Name)
|
||||
}
|
||||
}
|
||||
fmt.Fprint(textView, "closing the receiver\n")
|
||||
fmt.Fprintln(textView, "closing the receiver")
|
||||
wac.Disconnect()
|
||||
return nil
|
||||
}
|
||||
|
||||
// sends text to whatsapp id
|
||||
func SendText(wid string, text string) {
|
||||
msg := whatsapp.TextMessage{
|
||||
Info: whatsapp.MessageInfo{
|
||||
@@ -272,24 +307,22 @@ func SendText(wid string, text string) {
|
||||
}
|
||||
|
||||
PrintTextMessage(msg)
|
||||
//TODO: workaround for error when receiving&sending
|
||||
connection.RemoveHandlers()
|
||||
_, err := connection.Send(msg)
|
||||
msgStore.AddTextMessage(msg)
|
||||
connection.AddHandler(handler)
|
||||
if err != nil {
|
||||
fmt.Fprint(textView, "[red]error sending message: ", err, "\n[-]")
|
||||
fmt.Fprintln(textView, "[red]error sending message: ", err, "[-]")
|
||||
} else {
|
||||
//fmt.Fprint(textView, "Sent msg with ID: ", msgID, "\n")
|
||||
}
|
||||
}
|
||||
|
||||
// handler struct for whatsapp callbacks
|
||||
type textHandler struct{}
|
||||
|
||||
// HandleError implements the handler interface for go-whatsapp
|
||||
// HandleError implements the error handler interface for go-whatsapp
|
||||
func (t textHandler) HandleError(err error) {
|
||||
// TODO : handle go routine here
|
||||
fmt.Fprint(textView, "[red]error in textHandler : ", err, "\n[-]")
|
||||
fmt.Fprintln(textView, "[red]error in textHandler : ", err, "[-]")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -303,10 +336,12 @@ func (t textHandler) HandleTextMessage(msg whatsapp.TextMessage) {
|
||||
PrintTextMessage(msg)
|
||||
}
|
||||
|
||||
// prints a text message to the TextView
|
||||
func PrintTextMessage(msg whatsapp.TextMessage) {
|
||||
fmt.Fprint(textView, messages.GetTextMessageString(&msg))
|
||||
fmt.Fprintln(textView, messages.GetTextMessageString(&msg))
|
||||
}
|
||||
|
||||
// methods to convert messages to TextMessage
|
||||
func (t textHandler) HandleImageMessage(message whatsapp.ImageMessage) {
|
||||
msg := whatsapp.TextMessage{
|
||||
Info: whatsapp.MessageInfo{
|
||||
@@ -359,6 +394,7 @@ func (t textHandler) HandleAudioMessage(message whatsapp.AudioMessage) {
|
||||
t.HandleTextMessage(msg)
|
||||
}
|
||||
|
||||
// add contact info to database TODO: when are these sent??
|
||||
func (t textHandler) HandleNewContact(contact whatsapp.Contact) {
|
||||
contactChannel <- contact
|
||||
}
|
||||
|
||||
@@ -2,12 +2,18 @@ package messages
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"github.com/Rhymen/go-whatsapp"
|
||||
"os"
|
||||
"os/user"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var contacts map[string]string
|
||||
var connection *whatsapp.Conn
|
||||
|
||||
func SetConnection(conn *whatsapp.Conn) {
|
||||
connection = conn
|
||||
}
|
||||
|
||||
func LoadContacts() {
|
||||
contacts = make(map[string]string)
|
||||
@@ -46,6 +52,15 @@ func GetIdName(id string) string {
|
||||
if _, ok := contacts[id]; ok {
|
||||
return contacts[id]
|
||||
}
|
||||
if val, ok := connection.Store.Contacts[id]; ok {
|
||||
if val.Name != "" {
|
||||
return val.Name
|
||||
} else if val.Short != "" {
|
||||
return val.Short
|
||||
} else if val.Notify != "" {
|
||||
return val.Notify
|
||||
}
|
||||
}
|
||||
return strings.TrimSuffix(id, CONTACTSUFFIX)
|
||||
}
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ func (db *MessageDatabase) GetMessagesString(wid string) string {
|
||||
var out = ""
|
||||
for _, element := range (*db).textMessages[wid] {
|
||||
out += GetTextMessageString(&element)
|
||||
out += "\n"
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -71,14 +72,14 @@ func GetTextMessageString(msg *whatsapp.TextMessage) string {
|
||||
text := tview.Escape((*msg).Text)
|
||||
tim := time.Unix(int64((*msg).Info.Timestamp), 0)
|
||||
if (*msg).Info.FromMe { //msg from me
|
||||
out += "[-::d](" + tim.Format("02-01-06 15:04:05") + ") [blue::b]Me: [-::-]" + text + "\n"
|
||||
out += "[-::d](" + tim.Format("02-01-06 15:04:05") + ") [blue::b]Me: [-::-]" + text
|
||||
} else if strings.Contains((*msg).Info.RemoteJid, GROUPSUFFIX) { // group msg
|
||||
//(*msg).Info.SenderJid
|
||||
userId := (*msg).Info.SenderJid
|
||||
//userId := strings.Split(string((*msg).Info.RemoteJid), "-")[0] + CONTACTSUFFIX
|
||||
out += "[-::d](" + tim.Format("02-01-06 15:04:05") + ") [green::b]" + GetIdName(userId) + ": [-::-]" + text + "\n"
|
||||
out += "[-::d](" + tim.Format("02-01-06 15:04:05") + ") [green::b]" + GetIdName(userId) + ": [-::-]" + text
|
||||
} else { // message from others
|
||||
out += "[-::d](" + tim.Format("02-01-06 15:04:05") + ") [green::b]" + GetIdName((*msg).Info.RemoteJid) + ": [-::-]" + text + "\n"
|
||||
out += "[-::d](" + tim.Format("02-01-06 15:04:05") + ") [green::b]" + GetIdName((*msg).Info.RemoteJid) + ": [-::-]" + text
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ var (
|
||||
type QRCodeString string
|
||||
|
||||
func (v *QRCodeString) Print() {
|
||||
fmt.Fprint(outer, *v)
|
||||
fmt.Fprintln(outer, *v)
|
||||
}
|
||||
|
||||
type qrcodeTerminal struct {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/Rhymen/go-whatsapp"
|
||||
"github.com/normen/whatscli/messages"
|
||||
"github.com/normen/whatscli/qrcode"
|
||||
)
|
||||
|
||||
@@ -25,6 +26,7 @@ func GetConnection() *whatsapp.Conn {
|
||||
} else {
|
||||
wac = connection
|
||||
}
|
||||
messages.SetConnection(wac)
|
||||
return wac
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user