slidge-whatsapp 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/PKG-INFO +5 -5
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/README.md +3 -3
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/pyproject.toml +7 -4
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/__init__.py +1 -1
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/contact.py +1 -1
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/event.go +5 -0
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/group.py +7 -2
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/media/media.go +8 -3
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/session.go +4 -4
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/session.py +29 -27
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/LICENSE +0 -0
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/build.py +0 -0
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/__main__.py +0 -0
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/command.py +0 -0
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/config.py +0 -0
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/gateway.go +0 -0
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/gateway.py +0 -0
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/go.mod +0 -0
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/go.sum +0 -0
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/media/ffmpeg.go +0 -0
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/media/mupdf.go +0 -0
- {slidge_whatsapp-0.2.2 → slidge_whatsapp-0.2.3}/slidge_whatsapp/media/stub.go +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: slidge-whatsapp
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: A Whatsapp/XMPP gateway.
|
|
5
5
|
License: GNU AFFERO GENERAL PUBLIC LICENSE
|
|
6
6
|
Version 3, 19 November 2007
|
|
@@ -672,7 +672,7 @@ Requires-Dist: linkpreview (>=0.11.0)
|
|
|
672
672
|
Requires-Dist: pybindgen (>=0.22.1)
|
|
673
673
|
Requires-Dist: slidge (>=0.2.4)
|
|
674
674
|
Project-URL: Chat room, https://conference.nicoco.fr:5281/muc_log/slidge/
|
|
675
|
-
Project-URL: Documentation, https://slidge.
|
|
675
|
+
Project-URL: Documentation, https://slidge.im/docs/slidge-whatsapp/main
|
|
676
676
|
Project-URL: Homepage, https://codeberg.org/slidge/slidge-whatsapp
|
|
677
677
|
Project-URL: Issues, https://codeberg.org/slidge/slidge-whatsapp/issues
|
|
678
678
|
Project-URL: Repository, https://codeberg.org/slidge/slidge-whatsapp
|
|
@@ -694,7 +694,7 @@ A
|
|
|
694
694
|
|
|
695
695
|
## Installation
|
|
696
696
|
|
|
697
|
-
Refer to the [slidge admin documentation](https://slidge.im/
|
|
697
|
+
Refer to the [slidge admin documentation](https://slidge.im/docs/slidge/main/admin/)
|
|
698
698
|
for general info on how to set up an XMPP server component.
|
|
699
699
|
|
|
700
700
|
### Containers
|
|
@@ -702,8 +702,8 @@ for general info on how to set up an XMPP server component.
|
|
|
702
702
|
From [the codeberg package registry](https://codeberg.org/slidge/-/packages?q=&type=container)
|
|
703
703
|
|
|
704
704
|
```sh
|
|
705
|
-
# use ravermeister/slidge-whatsapp for arm64 (thanks raver! <3)
|
|
706
|
-
docker run
|
|
705
|
+
# use docker.io/ravermeister/slidge-whatsapp for arm64 (thanks raver! <3)
|
|
706
|
+
docker run codeberg.org/slidge/slidge-whatsapp
|
|
707
707
|
```
|
|
708
708
|
|
|
709
709
|
### Python package
|
|
@@ -14,7 +14,7 @@ A
|
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
|
-
Refer to the [slidge admin documentation](https://slidge.im/
|
|
17
|
+
Refer to the [slidge admin documentation](https://slidge.im/docs/slidge/main/admin/)
|
|
18
18
|
for general info on how to set up an XMPP server component.
|
|
19
19
|
|
|
20
20
|
### Containers
|
|
@@ -22,8 +22,8 @@ for general info on how to set up an XMPP server component.
|
|
|
22
22
|
From [the codeberg package registry](https://codeberg.org/slidge/-/packages?q=&type=container)
|
|
23
23
|
|
|
24
24
|
```sh
|
|
25
|
-
# use ravermeister/slidge-whatsapp for arm64 (thanks raver! <3)
|
|
26
|
-
docker run
|
|
25
|
+
# use docker.io/ravermeister/slidge-whatsapp for arm64 (thanks raver! <3)
|
|
26
|
+
docker run codeberg.org/slidge/slidge-whatsapp
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
### Python package
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "slidge-whatsapp"
|
|
3
|
-
version = "v0.2.
|
|
3
|
+
version = "v0.2.3"
|
|
4
4
|
description = "A Whatsapp/XMPP gateway."
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "nicoco", email = "nicoco@nicoco.fr"},
|
|
@@ -24,7 +24,7 @@ Homepage = "https://codeberg.org/slidge/slidge-whatsapp"
|
|
|
24
24
|
Issues = "https://codeberg.org/slidge/slidge-whatsapp/issues"
|
|
25
25
|
Repository = "https://codeberg.org/slidge/slidge-whatsapp"
|
|
26
26
|
"Chat room" = "https://conference.nicoco.fr:5281/muc_log/slidge/"
|
|
27
|
-
Documentation = "https://slidge.
|
|
27
|
+
Documentation = "https://slidge.im/docs/slidge-whatsapp/main"
|
|
28
28
|
|
|
29
29
|
[project.scripts]
|
|
30
30
|
slidge-whatsapp = "slidge_whatsapp:main"
|
|
@@ -108,8 +108,9 @@ body = """
|
|
|
108
108
|
{% for commit in commits %}
|
|
109
109
|
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
|
|
110
110
|
{% if commit.breaking %}[**breaking**] {% endif %}\
|
|
111
|
-
{{ commit.message | upper_first }}\
|
|
112
|
-
{% if commit.remote.username %} by @{{ commit.remote.username }}{%- endif %}\
|
|
111
|
+
{{ commit.message | split(pat="\n") | first | upper_first | trim }}\
|
|
112
|
+
{% if commit.remote.username %} by @{{ commit.remote.username }}{%- endif %} \
|
|
113
|
+
[`{{ commit.id | truncate(length=7, end="") }}`](./commit/{{ commit.id }})\
|
|
113
114
|
{% endfor %}
|
|
114
115
|
{% endfor %}\n
|
|
115
116
|
"""
|
|
@@ -118,6 +119,8 @@ footer = """
|
|
|
118
119
|
"""
|
|
119
120
|
|
|
120
121
|
[tool.git-cliff.git]
|
|
122
|
+
conventional_commits = true
|
|
123
|
+
filter_unconventional = false
|
|
121
124
|
commit_parsers = [
|
|
122
125
|
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
|
|
123
126
|
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
|
|
@@ -57,7 +57,7 @@ class Roster(LegacyRoster[str, Contact]):
|
|
|
57
57
|
avatar = self.session.whatsapp.GetAvatar(data.JID, contact.avatar or "")
|
|
58
58
|
if avatar.URL and contact.avatar != avatar.ID:
|
|
59
59
|
await contact.set_avatar(avatar.URL, avatar.ID)
|
|
60
|
-
elif avatar.URL == "":
|
|
60
|
+
elif avatar.URL == "" and avatar.ID == "":
|
|
61
61
|
await contact.set_avatar(None)
|
|
62
62
|
except RuntimeError as err:
|
|
63
63
|
self.session.log.error(
|
|
@@ -578,6 +578,7 @@ func convertAttachment(attach *Attachment) error {
|
|
|
578
578
|
// these are some times misdetected as such.
|
|
579
579
|
if s.VideoWidth == 0 && s.VideoHeight == 0 && s.AudioSampleRate > 0 && s.Duration > 0 {
|
|
580
580
|
spec = voiceMessageSpec
|
|
581
|
+
spec.SourceMIME = media.TypeM4A
|
|
581
582
|
}
|
|
582
583
|
}
|
|
583
584
|
default:
|
|
@@ -586,6 +587,10 @@ func convertAttachment(attach *Attachment) error {
|
|
|
586
587
|
}
|
|
587
588
|
|
|
588
589
|
// Convert attachment between file-types, if source MIME matches the known list of convertable types.
|
|
590
|
+
if spec.SourceMIME == "" {
|
|
591
|
+
spec.SourceMIME = detectedMIME
|
|
592
|
+
}
|
|
593
|
+
|
|
589
594
|
data, err := media.Convert(ctx, attach.Data, &spec)
|
|
590
595
|
if err != nil {
|
|
591
596
|
return fmt.Errorf("failed converting attachment: %w", err)
|
|
@@ -25,14 +25,13 @@ class MUC(LegacyMUC[str, str, Participant, str]):
|
|
|
25
25
|
|
|
26
26
|
HAS_DESCRIPTION = False
|
|
27
27
|
REACTIONS_SINGLE_EMOJI = True
|
|
28
|
-
_ALL_INFO_FILLED_ON_STARTUP = True
|
|
29
28
|
|
|
30
29
|
async def update_info(self):
|
|
31
30
|
try:
|
|
32
31
|
avatar = self.session.whatsapp.GetAvatar(self.legacy_id, self.avatar or "")
|
|
33
32
|
if avatar.URL and self.avatar != avatar.ID:
|
|
34
33
|
await self.set_avatar(avatar.URL, avatar.ID)
|
|
35
|
-
elif avatar.URL == "":
|
|
34
|
+
elif avatar.URL == "" and avatar.ID == "":
|
|
36
35
|
await self.set_avatar(None)
|
|
37
36
|
except RuntimeError as err:
|
|
38
37
|
self.session.log.error(
|
|
@@ -95,6 +94,12 @@ class MUC(LegacyMUC[str, str, Participant, str]):
|
|
|
95
94
|
if name := participant.nickname:
|
|
96
95
|
self.subject_setter = name
|
|
97
96
|
self.session.whatsapp_participants[self.legacy_id] = info.Participants
|
|
97
|
+
self.n_participants = len(info.Participants)
|
|
98
|
+
# Since whatsmeow does always emit a whatsapp.Group event even for participant changes,
|
|
99
|
+
# we need to do that to actually update the participant list.
|
|
100
|
+
if self._participants_filled:
|
|
101
|
+
async for _ in self.fill_participants():
|
|
102
|
+
pass
|
|
98
103
|
|
|
99
104
|
async def fill_participants(self) -> AsyncIterator[Participant]:
|
|
100
105
|
await self.session.bookmarks.ready
|
|
@@ -107,6 +107,8 @@ type Spec struct {
|
|
|
107
107
|
VideoHeight int // The height of the video stream, in pixels.
|
|
108
108
|
VideoFilter string // A complex filter to apply to the video stream.
|
|
109
109
|
|
|
110
|
+
Duration time.Duration // The duration of the audio or video stream.
|
|
111
|
+
|
|
110
112
|
ImageWidth int // The width of the image, in pixels.
|
|
111
113
|
ImageHeight int // The height of the image, in pixels.
|
|
112
114
|
ImageQuality int // Image quality for lossy image formats, typically a value from 1 to 100.
|
|
@@ -114,8 +116,8 @@ type Spec struct {
|
|
|
114
116
|
|
|
115
117
|
DocumentPage int // The number of pages for the document.
|
|
116
118
|
|
|
117
|
-
|
|
118
|
-
StripMetadata bool
|
|
119
|
+
SourceMIME MIMEType // The MIME type for the source data. If not set, this is derived from the source data.
|
|
120
|
+
StripMetadata bool // Whether or not to remove any container-level metadata present in the stream.
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
// CommandLineArgs returns the current [Spec] as a list of command-line arguments meant for FFMPEG
|
|
@@ -216,7 +218,10 @@ func (s Spec) commandLineArgs() ([]string, error) {
|
|
|
216
218
|
// specification given. For information on how these definitions affect media conversions, see the
|
|
217
219
|
// documentation for the [Spec] type.
|
|
218
220
|
func Convert(ctx context.Context, data []byte, spec *Spec) ([]byte, error) {
|
|
219
|
-
var from, to =
|
|
221
|
+
var from, to = spec.SourceMIME, spec.MIME.BaseMediaType()
|
|
222
|
+
if from == "" {
|
|
223
|
+
from = DetectMIMEType(data)
|
|
224
|
+
}
|
|
220
225
|
switch from {
|
|
221
226
|
case TypeOgg, TypeM4A:
|
|
222
227
|
switch to {
|
|
@@ -535,15 +535,15 @@ func (s *Session) GetAvatar(resourceID, avatarID string) (Avatar, error) {
|
|
|
535
535
|
}
|
|
536
536
|
|
|
537
537
|
p, err := s.client.GetProfilePictureInfo(jid, &whatsmeow.GetProfilePictureParams{ExistingID: avatarID})
|
|
538
|
-
if err
|
|
539
|
-
|
|
540
|
-
|
|
538
|
+
if errors.Is(err, whatsmeow.ErrProfilePictureNotSet) || errors.Is(err, whatsmeow.ErrProfilePictureUnauthorized) {
|
|
539
|
+
return Avatar{}, nil
|
|
540
|
+
} else if err != nil {
|
|
541
541
|
return Avatar{}, fmt.Errorf("Could not get avatar: %s", err)
|
|
542
542
|
} else if p != nil {
|
|
543
543
|
return Avatar{ID: p.ID, URL: p.URL}, nil
|
|
544
544
|
}
|
|
545
545
|
|
|
546
|
-
return Avatar{}, nil
|
|
546
|
+
return Avatar{ID: avatarID}, nil
|
|
547
547
|
}
|
|
548
548
|
|
|
549
549
|
// SetAvatar updates the profile picture for the Contact or Group JID given; it can also update the
|
|
@@ -590,30 +590,32 @@ class Session(BaseSession[str, Recipient]):
|
|
|
590
590
|
if not match:
|
|
591
591
|
return None
|
|
592
592
|
url = match.group("url")
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
593
|
+
try:
|
|
594
|
+
async with self.http.get(url) as resp:
|
|
595
|
+
if resp.status != 200:
|
|
596
|
+
self.log.debug(
|
|
597
|
+
"Could not generate a preview for %s because response status was %s",
|
|
598
|
+
url,
|
|
599
|
+
resp.status,
|
|
600
|
+
)
|
|
601
|
+
return None
|
|
602
|
+
if resp.content_type != "text/html":
|
|
603
|
+
self.log.debug(
|
|
604
|
+
"Could not generate a preview for %s because content type is %s",
|
|
605
|
+
url,
|
|
606
|
+
resp.content_type,
|
|
607
|
+
)
|
|
608
|
+
return None
|
|
609
|
+
try:
|
|
610
|
+
html = await resp.text()
|
|
611
|
+
except Exception as e:
|
|
612
|
+
self.log.debug(
|
|
613
|
+
"Could not generate a preview for %s", url, exc_info=e
|
|
614
|
+
)
|
|
615
|
+
return None
|
|
616
|
+
preview = LinkPreview(Link(url, html))
|
|
617
|
+
if not preview.title:
|
|
618
|
+
return None
|
|
617
619
|
thumbnail = (
|
|
618
620
|
await get_url_bytes(self.http, preview.image)
|
|
619
621
|
if preview.image
|
|
@@ -635,9 +637,9 @@ class Session(BaseSession[str, Recipient]):
|
|
|
635
637
|
else go.Slice_byte()
|
|
636
638
|
),
|
|
637
639
|
)
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
640
|
+
except Exception as e:
|
|
641
|
+
self.log.debug("Could not generate a preview for %s", url, exc_info=e)
|
|
642
|
+
return None
|
|
641
643
|
|
|
642
644
|
async def __get_location(self, text: str) -> Optional[whatsapp.Location]:
|
|
643
645
|
match = search(GEO_URI_SEARCH_REGEX, text)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|