Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2db7e51327 | ||
|
|
e698b66819 | ||
|
|
7fdafb477a | ||
|
|
13632156a1 | ||
|
|
08b69673e3 | ||
|
|
36b8bdac2f | ||
|
|
43c5795cc7 | ||
|
|
2063aeec91 | ||
|
|
310e9fa2ab | ||
|
|
c860542052 | ||
|
|
172fad115b | ||
|
|
cfd41b2de6 | ||
|
|
6eb872ef8a | ||
|
|
3f5ec9ff8c | ||
|
|
48fca0e6ad | ||
|
|
28d06730c7 | ||
|
|
fff039e776 |
75
README.md
75
README.md
@@ -1,66 +1,61 @@
|
||||
# whatscli
|
||||
|
||||
A command line interface for whatsapp, based on go-whatsapp and tview
|
||||
A command line interface for whatsapp, based on [go-whatsapp](https://github.com/Rhymen/go-whatsapp) and [tview](https://github.com/rivo/tview)
|
||||
|
||||
```
|
||||
┌────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ WhatsCLI v0.1.0 Help: /name = name contact | /quit = exit app | /load = reload contacts | <Tab> =│
|
||||
├──────────────────────────────┬─────────────────────────────────────────────────────────────────────┤
|
||||
│Contacts │ │
|
||||
│├──Normen │(03-22-13 21:18:24) Daniel: Sachste bescheid wenn der kram vorbei ist│
|
||||
│├──Lilou │? :) │
|
||||
│├──Boris │(03-22-13 21:37:29) Ich: Jo │
|
||||
│├──Malte │(03-22-13 22:02:13) Daniel: Mensch das geht ja lang.. │
|
||||
│├──Daniel │(03-22-13 22:02:53) Ich: Nu is schulz │
|
||||
│├──Seb │(03-22-13 22:03:08) Daniel: Jo bis gleich ! │
|
||||
│├──Bettina │(04-07-14 18:06:15) Daniel: Hey wie schauts :) │
|
||||
│├──Elternbeirat │(04-07-14 18:07:56) Ich: Ich komme laut Navigationssystem um 19:40 │
|
||||
│├──4911758758720-1565273421@g.│Uhr an │
|
||||
│├──491111250015@s.whatsapp.net│(04-07-14 18:08:33) Daniel: Sauber, ruf ma so ca 10 min vorher durch │
|
||||
│├──4911758758714-1537904683@g.│dann bin ich da :) │
|
||||
│├──491114171906-1448397341@g.u│(04-07-14 19:24:21) Ich: Bin jetzt in Bremen. Circa 10 Minuten │
|
||||
│├──491192855547-1561396191@g.u│(04-07-14 19:24:45) Daniel: Ok mach mich los │
|
||||
│├──491152456088@s.whatsapp.net│(07-27-14 19:14:19) Ich: Moin do. Sag' mal bist Du morgen um fünf in │
|
||||
│├──491107382606-1364411990@g.u│Bremen? Ich bräuchte jemanden um das Mischpult etc. wieder in einen │
|
||||
│├──491111250017-1603197565@g.u│LKW zu laden.. │
|
||||
│├──491131942996@s.whatsapp.net│(07-27-14 19:15:22) Daniel: Ich bin unterwegs, sorry │
|
||||
│├──491122978981@s.whatsapp.net│(07-27-14 19:15:52) Ich: Kein Ding, danke! │
|
||||
│├──491192855528@s.whatsapp.net│(07-27-14 19:24:50) Daniel: Jou bin quasi noch im breminale stress :)│
|
||||
│├──491154447429@s.whatsapp.net│(07-27-14 19:25:12) Ich: Na dann noch viel Spass :) │
|
||||
│├──491132457405-1526385826@g.u│(07-27-14 19:25:34) Daniel: Ja danke, bin froh wenns vorbei is ;) │
|
||||
│├──491103663035@s.whatsapp.net│(07-27-14 19:26:12) Ich: Augen zu und durch, Lock'n'Loll │
|
||||
│├──491113075747@s.whatsapp.net│(11-15-20 15:27:06) Ich: testjj │
|
||||
│├──491147048885@s.whatsapp.net├─────────────────────────────────────────────────────────────────────┤
|
||||
│├──491124146101@s.whatsapp.net│ │
|
||||
└──────────────────────────────┴─────────────────────────────────────────────────────────────────────┘
|
||||
┌─────────────────────────────────────────────────────────────────────────┐
|
||||
│ WhatsCLI v0.4.2 Help: /name NewName | /addname 123456 NewName | /quit |│
|
||||
├──────────────────────────────┬──────────────────────────────────────────┤
|
||||
│Contacts │(03-14-12 22:59:00) Me: Hey, whatscli here│
|
||||
│├──Peter │(03-14-12 23:00:00) Peter: Cool 😀 │
|
||||
│├──Paul │ │
|
||||
│└──Mary │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ │ │
|
||||
│ ├──────────────────────────────────────────┤
|
||||
│ │Yeah, love the shell! │
|
||||
└──────────────────────────────┴──────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
Things that work.
|
||||
|
||||
- Allows sending and receiving WhatsApp messages in a CLI interface
|
||||
- Connects through Web App API without browser
|
||||
- Allows sending and receiving WhatsApp messages in a command line app
|
||||
- Connects through the Web App API without browser
|
||||
- Uses QR code for simple setup
|
||||
- Binaries for Windows, Mac, Linux and RaspBerry Pi
|
||||
|
||||
### Caveats
|
||||
|
||||
This is a WIP. Heres some things you might expect to work that don't. Plus some other things I should mention.
|
||||
|
||||
- Only lists contacts and groups that have been messaged on phone
|
||||
- Only fetches a few messages for last contacted
|
||||
- To display names they have to be entered through the `/name` or `/addname` commands for each contact
|
||||
- No support for images, videos, documents etc
|
||||
- Only shows existing chats
|
||||
- Only fetches a few old messages
|
||||
- No support for images, videos, documents etc.
|
||||
- No incoming message notification / count
|
||||
- No proper connection drop handling
|
||||
- Not configurable at all
|
||||
- Leaves its config files in your home folder
|
||||
- FaceBook obviously doesn't endorse or like these kinds of apps and they're likely to break when they change stuff in their web app
|
||||
- FaceBook obviously doesn't endorse or like these kinds of apps and they're likely to break when FaceBook changes stuff in their web app
|
||||
|
||||
## Installation / Usage
|
||||
|
||||
How to get it running and use it
|
||||
How to get it running and how to use it
|
||||
|
||||
- Download a release
|
||||
- Put the binary in your PATH (optional)
|
||||
- Run with `whatscli` (or double-click)
|
||||
- Scan QR code with WhatsApp on phone (maybe resize shell)
|
||||
- Scan the QR code with WhatsApp on your phone (maybe resize shell)
|
||||
|
||||
|
||||
17
go.mod
17
go.mod
@@ -3,11 +3,16 @@ module github.com/normen/whatscli
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f
|
||||
github.com/Rhymen/go-whatsapp v0.1.1-0.20201007125822-005103751b7a
|
||||
github.com/gdamore/tcell v1.4.0
|
||||
github.com/Rhymen/go-whatsapp v0.1.1-0.20201117204225-79ad714fa46a
|
||||
github.com/gdamore/tcell/v2 v2.0.1-0.20201017141208-acf90d56d591
|
||||
github.com/mattn/go-colorable v0.1.1
|
||||
github.com/rivo/tview v0.0.0-20201018122409-d551c850a743
|
||||
github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9
|
||||
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-20201117185959-f9f2182520da
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
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
|
||||
)
|
||||
|
||||
98
go.sum
98
go.sum
@@ -1,57 +1,155 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f h1:2dk3eOnYllh+wUOuDhOoC2vUVoJF/5z478ryJ+wzEII=
|
||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/go.mod h1:4a58ifQTEe2uwwsaqbh3i2un5/CBPg+At/qHpt18Tmk=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Rhymen/go-whatsapp v0.0.0/go.mod h1:rdQr95g2C1xcOfM7QGOhza58HeI3I+tZ/bbluv7VazA=
|
||||
github.com/Rhymen/go-whatsapp v0.1.0 h1:XTXhFIQ/fx9jKObUnUX2Q+nh58EyeHNhX7DniE8xeuA=
|
||||
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=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||
github.com/gdamore/tcell v1.4.0 h1:vUnHwJRvcPQa3tzi+0QI4U9JINXYJlOz9yiaiPQ2wMU=
|
||||
github.com/gdamore/tcell v1.4.0/go.mod h1:vxEiSDZdW3L+Uhjii9c3375IlDmR05bzxY404ZVSMo0=
|
||||
github.com/gdamore/tcell/v2 v2.0.0 h1:GRWG8aLfWAlekj9Q6W29bVvkHENc6hp79XOqG4AWDOs=
|
||||
github.com/gdamore/tcell/v2 v2.0.0/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
||||
github.com/gdamore/tcell/v2 v2.0.1-0.20201017141208-acf90d56d591 h1:0WWUDZ1oxq7NxVyGo8M3KI5jbkiwNAdZFFzAdC68up4=
|
||||
github.com/gdamore/tcell/v2 v2.0.1-0.20201017141208-acf90d56d591/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.0 h1:kbxbvI4Un1LUWKxufD+BiE6AEExYYgkQLQmLFqA1LFk=
|
||||
github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
|
||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
|
||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
||||
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
|
||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
|
||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-isatty v0.0.5 h1:tHXDdz1cpzGaovsTB+TVB8q90WEokoVmfMqoVcrLUgw=
|
||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
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=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
||||
golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
|
||||
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=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201017003518-b09fb700fbb7 h1:XtNJkfEjb4zR3q20BBBcYUykVOEMgZeIUOpBPfNYgxg=
|
||||
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=
|
||||
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
|
||||
94
main.go
94
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()
|
||||
@@ -49,31 +47,9 @@ func main() {
|
||||
gridLayout.SetBorders(true)
|
||||
gridLayout.SetBackgroundColor(tcell.ColorBlack)
|
||||
|
||||
//list := tview.NewList()
|
||||
////list.SetTitle("Contacts")
|
||||
////list.AddItem("List Contacts", "get the contacts", 'a', func() {
|
||||
//// list.Clear()
|
||||
//// var ids = msgStore.GetContactIds()
|
||||
//// for _, element := range ids {
|
||||
//// //fmt.Fprint(textView, "\n"+element)
|
||||
//// var elem = element
|
||||
//// list.AddItem(messages.GetIdName(element), "", '-', func() {
|
||||
//// currentReceiver = elem
|
||||
//// textView.Clear()
|
||||
//// textView.SetText(msgStore.GetMessagesString(elem))
|
||||
//// fmt.Fprint(textView, "\nNeuer Empfänger: ", elem)
|
||||
//// })
|
||||
//// }
|
||||
////})
|
||||
//list.ShowSecondaryText(false)
|
||||
//list.AddItem("Load", "Load Contacts", 'l', LoadContacts)
|
||||
//list.AddItem("Quit", "Press to exit", 'q', func() {
|
||||
// app.Stop()
|
||||
//})
|
||||
|
||||
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)
|
||||
@@ -87,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)
|
||||
|
||||
@@ -97,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
|
||||
@@ -139,22 +119,47 @@ func main() {
|
||||
app.SetFocus(textInput)
|
||||
go func() {
|
||||
if err := StartTextReceiver(); err != nil {
|
||||
fmt.Fprint(textView, 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()
|
||||
@@ -164,7 +169,7 @@ func EnterCommand(key tcell.Key) {
|
||||
//command
|
||||
parts := strings.Split(sndTxt, " ")
|
||||
if len(parts) < 3 {
|
||||
fmt.Fprint(textView, "\nUse /addname 1234567 NewName")
|
||||
fmt.Fprintln(textView, "Use /addname 1234567 NewName")
|
||||
return
|
||||
}
|
||||
messages.SetIdName(parts[1]+messages.CONTACTSUFFIX, strings.TrimPrefix(sndTxt, "/addname "+parts[1]+" "))
|
||||
@@ -174,7 +179,7 @@ func EnterCommand(key tcell.Key) {
|
||||
return
|
||||
}
|
||||
if currentReceiver == "" {
|
||||
fmt.Fprint(textView, "\nNo recipient set")
|
||||
fmt.Fprintln(textView, "[red]no contact selected[-]")
|
||||
return
|
||||
}
|
||||
if strings.Index(sndTxt, "/name ") == 0 {
|
||||
@@ -194,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).
|
||||
@@ -223,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()
|
||||
@@ -247,6 +258,7 @@ func LoadContacts() {
|
||||
}
|
||||
}
|
||||
|
||||
// sets the current contact, loads text from storage to TextView
|
||||
func SetDisplayedContact(wid string) {
|
||||
currentReceiver = wid
|
||||
textView.Clear()
|
||||
@@ -254,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)
|
||||
@@ -278,11 +290,12 @@ func StartTextReceiver() error {
|
||||
messages.SetIdName(contact.Jid, contact.Name)
|
||||
}
|
||||
}
|
||||
fmt.Fprint(textView, "\n"+"closing the receiver")
|
||||
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{
|
||||
@@ -294,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, "\nerror sending message: %v", err)
|
||||
fmt.Fprintln(textView, "[red]error sending message: ", err, "[-]")
|
||||
} else {
|
||||
//fmt.Fprint(textView, "\nSent msg with ID: %v", msgID)
|
||||
//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, "\nerror in textHandler : %v", err)
|
||||
fmt.Fprintln(textView, "[red]error in textHandler : ", err, "[-]")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -325,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{
|
||||
@@ -381,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 += "\n[-::d](" + tim.Format("01-02-06 15:04:05") + ") [blue::b]Me: [-::-]" + text
|
||||
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 += "\n[-::d](" + tim.Format("01-02-06 15:04:05") + ") [green::b]" + GetIdName(userId) + ": [-::-]" + text
|
||||
out += "[-::d](" + tim.Format("02-01-06 15:04:05") + ") [green::b]" + GetIdName(userId) + ": [-::-]" + text
|
||||
} else { // message from others
|
||||
out += "\n[-::d](" + tim.Format("01-02-06 15:04:05") + ") [green::b]" + GetIdName((*msg).Info.RemoteJid) + ": [-::-]" + text
|
||||
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 {
|
||||
|
||||
31
release.sh
Executable file
31
release.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: ./release.sh v1.0.0"
|
||||
exit 0
|
||||
fi
|
||||
WINF=whatscli-$1-windows.zip
|
||||
LINUXF=whatscli-$1-linux.zip
|
||||
MACF=whatscli-$1-macos.zip
|
||||
RASPIF=whatscli-$1-raspberrypi.zip
|
||||
|
||||
GOOS=darwin go build -o whatscli
|
||||
zip $MACF whatscli
|
||||
rm whatscli
|
||||
GOOS=windows go build -o whatscli.exe
|
||||
zip $WINF whatscli.exe
|
||||
rm whatscli.exe
|
||||
GOOS=linux go build -o whatscli
|
||||
zip $LINUXF whatscli
|
||||
rm whatscli
|
||||
GOOS=linux GOARCH=arm GOARM=5 go build -o whatscli
|
||||
zip $RASPIF whatscli
|
||||
rm whatscli
|
||||
|
||||
git pull
|
||||
LASTTAG=$(git describe --tags --abbrev=0)
|
||||
git log $LASTTAG..HEAD --no-decorate --pretty=format:"- %s" --abbrev-commit > changes.txt
|
||||
vim changes.txt
|
||||
gh release create $1 $LINUXF $MACF $WINF $RASPIF -F changes.txt -t $1
|
||||
rm changes.txt
|
||||
rm *.zip
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -68,7 +70,6 @@ func LoginWithConnection(wac *whatsapp.Conn) error {
|
||||
return fmt.Errorf("error saving session: %v\n", err)
|
||||
}
|
||||
//<-time.After(3 * time.Second)
|
||||
//fmt.Fprint(textView, "\nlogin successful")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user