Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
briar
Python Briar Wrapper
Commits
f637cd33
Commit
f637cd33
authored
Jun 07, 2020
by
Nico
Browse files
Revise PrivatChat class
parent
eab66ddd
Changes
1
Hide whitespace changes
Inline
Side-by-side
briar_wrapper/models/private_chat.py
View file @
f637cd33
...
...
@@ -4,8 +4,7 @@
from
urllib.parse
import
urljoin
from
requests
import
get
as
_get
from
requests
import
post
as
_post
import
requests
from
briar_wrapper.constants
import
BASE_HTTP_URL
from
briar_wrapper.model
import
Model
...
...
@@ -15,20 +14,17 @@ class PrivateChat(Model):
API_ENDPOINT
=
"messages/"
_contact_id
=
0
_on_message_received_callback
=
None
def
__init__
(
self
,
api
,
contact_id
):
super
().
__init__
(
api
)
self
.
_contact_id
=
contact_id
def
get
(
self
):
url
=
urljoin
(
BASE_HTTP_URL
,
self
.
API_ENDPOINT
+
"/%d"
%
self
.
_contact_id
)
request
=
_
get
(
url
,
headers
=
self
.
_headers
)
self
.
API_ENDPOINT
+
str
(
self
.
_contact_id
)
)
request
=
requests
.
get
(
url
,
headers
=
self
.
_headers
)
return
request
.
json
()
def
send
(
self
,
message
):
url
=
urljoin
(
BASE_HTTP_URL
,
self
.
API_ENDPOINT
+
"/%i"
%
self
.
_contact_id
)
_
post
(
url
,
headers
=
self
.
_headers
,
json
=
{
"text"
:
message
})
self
.
API_ENDPOINT
+
str
(
self
.
_contact_id
)
)
requests
.
post
(
url
,
headers
=
self
.
_headers
,
json
=
{
"text"
:
message
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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