Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Koen van der Veen
whatsapp
Commits
4c3c9e31
Commit
4c3c9e31
authored
3 years ago
by
Eelco van der Wel
Browse files
Options
Download
Plain Diff
Merge branch 'dev' into 'refactor'
# Conflicts: # whatsapp/plugin.py
parents
8041ae0a
2233934b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitignore
+1
-0
.gitignore
README.md
+6
-0
README.md
setup.py
+1
-0
setup.py
whatsapp/cli.py
+39
-0
whatsapp/cli.py
whatsapp/web_client/binary_reader.py
+3
-0
whatsapp/web_client/binary_reader.py
with
50 additions
and
0 deletions
+50
-0
.gitignore
+
1
-
0
View file @
4c3c9e31
src/qr_code
example_message_config.json
whatsapp/data/
test/data/*
...
...
This diff is collapsed.
Click to expand it.
README.md
+
6
-
0
View file @
4c3c9e31
...
...
@@ -27,4 +27,10 @@ simulate_run_plugin_from_frontend --config_file="example_config.json"
Go to
`localhost:8000/qr`
, and scan the QR code (with a time limit of 20 seconds)
## Sending messages
To send a whatsapp message (with a running and authenticated plugin), do:
```
send_message_action --config="example_message_config.json"
```
This diff is collapsed.
Click to expand it.
setup.py
+
1
-
0
View file @
4c3c9e31
...
...
@@ -17,4 +17,5 @@ setup(name='whatsapp',
"pytest"
],
packages
=
setuptools
.
find_packages
(),
entry_points
=
{
'console_scripts'
:
[
"send_message_action=whatsapp.cli:send_message_action"
]}
)
This diff is collapsed.
Click to expand it.
whatsapp/cli.py
0 → 100644
+
39
-
0
View file @
4c3c9e31
from
fastscript
import
call_parse
,
Param
from
pymemri.data.central_schema
import
Message
,
Account
from
pymemri.pod.client
import
PodClient
from
pymemri.data.itembase
import
Edge
from
pymemri.data.basic
import
read_json
@
call_parse
def
send_message_action
(
database_key
:
Param
(
"database key"
,
str
)
=
None
,
owner_key
:
Param
(
"owner key"
,
str
)
=
None
,
config
:
Param
(
"config"
,
str
)
=
None
,
service
:
Param
(
"service"
,
str
)
=
None
,
content
:
Param
(
"service"
,
str
)
=
None
,
phone_number
:
Param
(
"phone_number"
,
str
)
=
None
):
print
(
"CREATING SEND MESSAGE ITEM"
)
if
database_key
and
owner_key
:
print
(
"pod credentials from from args"
)
client
=
PodClient
(
database_key
=
database_key
,
owner_key
=
owner_key
)
else
:
client
=
PodClient
.
from_local_keys
()
if
config
:
dict
=
read_json
(
config
)
print
(
dict
)
service
=
dict
.
get
(
"service"
,
service
)
phone_number
=
dict
.
get
(
"phone_number"
,
phone_number
)
content
=
dict
.
get
(
"content"
,
content
)
assert
phone_number
,
"provide a valid phone number either via cli or example_message_config.json"
message
=
Message
(
sendStatus
=
"toSend"
,
service
=
service
,
content
=
content
)
account
=
Account
(
phoneNumber
=
phone_number
)
edge
=
Edge
(
message
,
account
,
"receiver"
)
client
.
bulk_action
(
create_items
=
[
message
,
account
],
create_edges
=
[
edge
])
This diff is collapsed.
Click to expand it.
whatsapp/web_client/binary_reader.py
+
3
-
0
View file @
4c3c9e31
...
...
@@ -123,6 +123,9 @@ class WABinaryReader:
# TODO: Fix this hack for this edge case properly
if
i
==
b
'Server'
:
i
=
'Server'
if
isinstance
(
i
,
bytes
):
# Hacky fix for unknown phone numbers (bytes to string) . e.g. b'+14151111' -> "+14151111"
i
=
str
(
i
)[
2
:
-
1
]
return
i
+
'@'
+
j
elif
tag
==
WATags
.
NIBBLE_8
or
tag
==
WATags
.
HEX_8
:
return
self
.
readPacked8
(
tag
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets