Compare commits

...

110 Commits

Author SHA1 Message Date
Wim 3719dd93ab Use tulir/go-whatsapp fork 2021-01-23 19:56:27 +01:00
Wim 5dd15ef8e7 Add an even more debug option (discord) (#1368)
Enable discordgo debugging with debuglevel=1 under the [discord.xxx] section, for even more debugging fun.
2021-01-23 00:09:56 +01:00
Alexander 4ac6366706 Allow the XMPP bridge to use slack compatible webhooks (xmpp) (#1364)
* Add mod_slack_webhook support to the XMPP bridge

* Replace b.webhookURL with b.GetString

* Do not return a message ID on webhook POST

* Add the XMPP webhook to the sample configuration
2021-01-21 22:50:04 +01:00
Wim adc0912efa Update README (#1362) 2021-01-15 23:21:48 +01:00
Wim 536823ce55 Optimize Dockerfile (#1361) 2021-01-15 22:44:01 +01:00
Peter Dave Hello 207cd24edb Unify/sync apk index cache control in Dockerfile (#1352)
The second stage is using a single `apk` command with `--no-cache` which is better.
2021-01-14 23:48:02 +01:00
Paul b039da1eba Add jpe as valid image filename extension (telegram) (#1360) 2021-01-14 23:42:13 +01:00
Qais Patankar 8fcd0f3b6f Improve Markdown in transmitter docs (discord) (#1351) 2021-01-03 18:57:06 +00:00
Wim 16fde6935c Rename .oga audio files to .ogg (telegram) (#1349) 2021-01-02 00:55:20 +01:00
Wim 9592cff9fa Update README about unsupported steam chat 2021-01-02 00:12:10 +01:00
Wim 109148988c Bump version 2020-12-31 23:42:41 +01:00
Wim cf13fff7d2 Release v1.21.0 (#1348) 2020-12-31 22:32:13 +01:00
Qais Patankar a9d8ac8bc0 Refactor "msg-parent-not-found" to config.ParentIDNotFound (#1347) 2020-12-31 18:01:57 +00:00
Qais Patankar 1a4717b366 Reject cross-channel message references (discord) (#1345)
Discord message references have been designed in a way for this to
support cross-channel or even cross-guild references in the future.

This will ensure the ParentID is *not* set when the message refers to a
message that was sent in a different channel.
2020-12-31 16:21:37 +00:00
Qais Patankar 6cadf12260 Add a prefix handler for unthreaded messages (discord) (#1346) 2020-12-31 16:15:42 +00:00
Wim 19d47784bd Add threading support with token (discord) (#1342)
Webhooks don't support the threading yet, so this is token only.
In discord you can reply on each message of a thread, but this is not possible in mattermost (so some changes added there to make sure we always answer on the rootID of the thread).

Also needs some more testing with slack.

update : It now also uses the token when replying to a thread (even if webhooks are enabled), until webhooks have support for threads.
2020-12-31 16:59:47 +01:00
Qais Patankar b89102c5fc Fix 'webook' typo in discord/webhook.go (#1344) 2020-12-31 16:51:49 +01:00
Wim 4f20ebead3 Update vendor for next release (#1343) 2020-12-31 14:48:12 +01:00
James Lu a9f89dbc64 Add support for stateless bridging via draft/relaymsg (irc) (#1339)
* irc: add support for stateless bridging via draft/relaymsg

As discussed at https://github.com/42wim/matterbridge/issues/667#issuecomment-634214165

* irc: handle the draft/relaymsg tag in spoofed messages too

* Apply suggestions from code review

Co-authored-by: Wim <wim@42.be>

* Run gofmt on irc.go

* Document relaymsg in matterbridge.toml.sample

Co-authored-by: Wim <wim@42.be>
2020-12-30 18:21:32 +01:00
wschwab 58ea1e07d2 Update README.md (#1340)
added using `chmod a+x` to make the binary executable in the installation section
2020-12-29 20:42:00 +01:00
Qais Patankar 6de4c7e971 Update webhook documentation (discord) (#1335) 2020-12-17 20:27:52 +01:00
Qais Patankar 03dc51ffa2 Split Bdiscord.Send into handleEventWebhook and handleEventBotUser (discord) 2020-12-13 23:19:48 +01:00
Qais Patankar aef2dcdfdd Move webhook specific logic to its own file (discord) 2020-12-13 23:19:48 +01:00
Qais Patankar 0494119bf4 Extract maybeGetLocalAvatar into its own function (discord) 2020-12-13 23:19:48 +01:00
Qais Patankar 0a17e21119 Remove WebhookURL support (discord) 2020-12-13 23:19:48 +01:00
Qais Patankar 52e2f926f4 Add initial transmitter implementation (discord)
This has been tested with one webhook in one channel.

Sends, edits and deletions work fine
2020-12-13 23:19:48 +01:00
Qais Patankar 611fb279bc Revert "Disable webhook editing (#1296)" (discord)
This reverts commit c23252ab53.
2020-12-13 23:19:48 +01:00
Gary Kim 41b4e64be9 Update go-nc-talk (nctalk) (#1333)
Signed-off-by: Gary Kim <gary@garykim.dev>
2020-12-10 00:06:27 +01:00
Wim 0d7315249d Update vendor (#1330) 2020-12-06 23:16:02 +01:00
Wim 4913766d58 Parse fencedcode in ParseMarkdown. Fixes #1127 (#1329) 2020-12-06 19:38:32 +01:00
Wim 92da8c7044 Mark messages as read (matrix). Fixes #1317 (#1328) 2020-12-06 17:49:35 +01:00
Wim 9dba3d5385 Update rocketchat vendor (#1327)
Contains fixes for #992 and adds more random ID
2020-12-06 17:23:37 +01:00
Wim 2d3c26a4b2 Implement ratelimiting (matrix). Fixes #1238 (#1326) 2020-12-06 17:18:25 +01:00
Wim 8eba2d3e50 Make handlers run async (irc) (#1325)
This makes the handlers run in a seperate go-routine in girc, and makes
sure that girc isn't blocked on executing PONG requests when
matterbridge takes a long time handling the incoming message.

This can happen when another bridge is in a backoff state where the
backoff time exceeds the IRC ping timeout.
2020-12-05 21:41:45 +01:00
Qais Patankar a8d4a27de1 Remove locale from golangci misspell (#1324) 2020-12-05 15:22:23 +01:00
Qais Patankar c42167c6f4 Refactor guild finding code (discord) (#1319) 2020-12-03 22:36:08 +01:00
Sebastian P 44d182e2f9 Add nil checks to text message handling (mumble) (#1321) 2020-12-03 22:25:33 +01:00
Wim ad95e35687 Rename jfif to jpg (whatsapp). Fixes #1292 2020-11-29 15:37:20 +01:00
Wim 640a9995f4 Refactor handleTextMessage (whatsapp) 2020-11-29 15:37:20 +01:00
Wim 95625f6871 Refactor image downloads (whatsapp) 2020-11-29 15:37:20 +01:00
Wim 2c20f72a9c Handle audio downloads (whatsapp) 2020-11-29 15:37:20 +01:00
Wim 5ad788e768 Handle video downloads (whatsapp) 2020-11-29 15:37:20 +01:00
Wim ed98c586c6 Add support for deleting messages (whatsapp) 2020-11-29 15:37:20 +01:00
Wim 3e865708d6 Refactor/cleanup code (whatsapp) 2020-11-29 15:37:20 +01:00
JeremyRand c3bcbd63c0 Add UserID to RemoteNickFormat and Tengo (#1308)
* Add UserID to RemoteNickFormat and Tengo

* Use strings.ReplaceAll in gateway.modifyUsername

Fixes a warning from gocritic linter.

* Use Unicode escape sequence instead of raw ZWSP in gateway.modifyUsername

Fixes a warning from stylecheck linter.
2020-11-25 23:54:27 +01:00
Simon THOBY 29e29439ee Show mxids in case of clashing usernames (matrix) (#1309)
Fixes #1302.
2020-11-25 23:51:23 +01:00
Wim 0c19716f44 Join on invite (irc). Fixes #1231 (#1306) 2020-11-22 22:44:15 +01:00
Wim b24e1bafa1 Add support for irc to irc notice (irc). Fixes #754 (#1305) 2020-11-22 22:21:02 +01:00
Wim 64b899ac89 Retry until we have contacts (whatsapp). Fixes #1122 (#1304) 2020-11-22 21:42:54 +01:00
Wim aa274e5ab7 Update discordgo fork (#1303) 2020-11-22 19:21:34 +01:00
Wim 7b3eaf3ccf Bump version 2020-11-22 18:55:21 +01:00
Wim 1a5353d768 Release v1.20.0 (#1298) 2020-11-22 17:27:33 +01:00
Wim eff41759bc Add extra debug to log time spent sending a message per bridge (#1299) 2020-11-22 17:20:20 +01:00
Wim c23252ab53 Disable webhook editing (discord) (#1296)
See https://github.com/42wim/matterbridge/issues/1255 and
https://github.com/qaisjp/go-discord-irc/issues/57

Webhook edits gets ratelimited which cause other problems with
matterbridge. Disabling for now.
2020-11-22 17:18:48 +01:00
Simon THOBY 1a3c57a031 Send the display name instead of the user name (matrix) (#1282)
* matrix: send the display name (the nickname in matrix parlance) instead of the user name

There is also the option UseUserName (already in use by the discord bridge) to turn back to the old behavior.

* matrix: update displayNames on join events

* matrix: introduce a helper.go file to keep matrix.go size reasonable
2020-11-22 15:57:41 +01:00
Wim 4cc2c914e6 Update vendor (#1297) 2020-11-22 15:55:57 +01:00
Simon THOBY cbb46293ab Update webhook messages via new endpoint (discord)
When using the webhook, the previous method to edit a message was to
delete the old one via the classical API, and to create a new message
via the webhook. While this works, this means that editing "old" messages
lead to a mess where the chronological order is no longer respected.

This uses an hidden API explained in https://support.discord.com/hc/en-us/community/posts/360034557771
to achieve a proper edition using the webhook API.

The obvious downside of this approach is that since it is an
undocumented API for now, so there is no stability guarantee :/
2020-11-14 04:08:09 +00:00
George 765e00c949 Add NoTLS option to allow plaintext XMPP connections (#1288)
Co-authored-by: George <zhoreeq@users.noreply.github.com>
2020-11-13 23:59:05 +01:00
Simon THOBY 662359908b Allow message edits on matrix (#1286)
based on https://github.com/Half-Shot/matrix-doc/blob/hs/1695-message-edits-proposal/proposals/1695-message-edits.md
2020-11-13 23:42:14 +01:00
Wim 0d99766686 Update slack invite 2020-10-24 21:04:24 +02:00
Wim ae3bc3358b Allow tengo to drop messages using msgDrop (#1272) 2020-10-21 21:57:14 +02:00
Wim 1e0b4532bd Show deprecate warnings about old tengo settings (#1271) 2020-10-21 20:35:22 +02:00
Wim 4f8b19c686 Add PingDelay option (irc) (#1269) 2020-10-21 01:14:13 +02:00
Wim 84ab223b81 Bump version 2020-10-21 00:59:11 +02:00
Wim 2bb21262d4 Release v1.19.0 (#1268) 2020-10-20 23:34:41 +02:00
Dellle 3188a9ffe6 Add username formatting for all events (matrix) (#1233) 2020-10-20 21:22:31 +02:00
Wim 61569a8610 Add even more debug for irc (#1266) 2020-10-20 00:33:15 +02:00
Wim 075a84427f Update vendor (#1265) 2020-10-19 23:40:00 +02:00
Gary Kim 950f2759bd Add support for downloading files (nctalk) (#1249)
Signed-off-by: Gary Kim <gary@garykim.dev>
2020-10-19 23:16:34 +02:00
Wim 25c82ddf02 Use vendored whatsapp version (#1258) 2020-10-12 00:05:17 +02:00
Wim 2d98df6122 Update vendor (#1257) 2020-10-11 23:07:00 +02:00
Gary Kim 219a5453f9 Append a suffix if user is a guest user (nctalk) (#1250)
Signed-off-by: Gary Kim <gary@garykim.dev>
2020-10-01 22:59:35 +02:00
Sebastian P 214a6a1386 Add Mumble support (#1245) 2020-10-01 22:50:56 +02:00
Wim e7781dc79c Bump version 2020-10-01 22:46:18 +02:00
Wim 10c4bd1ac8 Create codeql-analysis.yml 2020-10-01 22:02:05 +02:00
Dellle a42e488e58 Add username for images from WhatsApp (#1232) 2020-09-26 21:32:57 +02:00
Ben Wiederhake 06eb89b05b Matrix: Permit uploading files of other mimetypes (#1237)
This includes at least c-source-files, cpp-source-files,
markdown-files, Rust-files, and plaintext files.
We already allow uploading arbitrary executables. (And javascript-files,
coincidentally.) Not permitting these other text files would be highly unexpected.
2020-09-26 21:28:24 +02:00
Wim 91c58ec027 Bump version 2020-09-05 00:10:30 +02:00
Wim 8b26e42a3a Release v1.18.3 (#1229) 2020-09-05 00:02:37 +02:00
Wim acca011f15 Use alpine stable for docker 2020-09-04 23:47:03 +02:00
Wim 2f59abdda7 Update vendor (#1228) 2020-09-04 23:29:13 +02:00
Wim 17747a5c88 Remove outdated link. Closes #1224 2020-09-04 22:52:55 +02:00
Wim cec63546ff Check location of avatarURL (zulip). Fixes #1214 (#1227) 2020-09-04 22:50:57 +02:00
Gary Kim 75f67d2de4 Update nc-talk dependency (#1226) 2020-09-04 22:14:36 +02:00
Tilo Spannagel 712385ffd5 Format rich object strings (nctalk) (#1222)
Signed-off-by: Tilo Spannagel <development@tilosp.de>
2020-08-31 01:49:43 +02:00
Tilo Spannagel ad90cf09fe Update nc-talk to version 0.1.2 (#1220)
Signed-off-by: Tilo Spannagel <development@tilosp.de>
2020-08-30 15:19:51 +02:00
Tilo Spannagel f9928c9e25 Switch to upstream gomatrix (#1219)
Signed-off-by: Tilo Spannagel <development@tilosp.de>
2020-08-30 14:01:52 +02:00
Gary Kim a0741d99b8 Add TLSConfig to nctalk (#1195)
Signed-off-by: Gary Kim <gary@garykim.dev>
2020-08-30 13:49:26 +02:00
NikkyAI c63f08c811 Sent loopback messages to other websockets as well (api) (#1216) 2020-08-27 22:28:03 +02:00
escoand 58b6c4d277 Handle broadcasts as groups in Whatsapp (#1213)
The current way to get the correct JID of a WhatsApp group is to dump all JIDs to the log and grab the right one. This is working for for groups fine but not for broadcast, as they are not print out.

According to https://www.npmjs.com/package/@noamalffasy/js-whatsapp we have these possibilities:
* Chats: `[country code][phone number]@s.whatsapp.net`
* Groups: `[country code][phone number of creator]-[timestamp of group creation]@g.us`
* Broadcast Channels: `[timestamp of group creation]@broadcast`

But the bridge does currently interprets (and prints) the only second option.
2020-08-26 22:27:50 +02:00
NikkyAI 27c02549c8 Replace gorilla with melody for websocket API (#1205) 2020-08-26 22:27:00 +02:00
Wim 88d371c71c Release v1.18.2 (#1212) 2020-08-25 13:21:53 +02:00
Sandro b339524613 Add Dockerimage for tgs conversion (#1211)
* Add Dockerfile with tgs to png conversion support

* Add .dockerignore to keep cache busts while testing low
2020-08-25 13:15:24 +02:00
Wim d5feda5c8a Fix error loop (zulip) (#1210)
Fixes #1047
2020-08-25 00:12:13 +02:00
Wim 2f506425c2 Update whatsapp vendor and fix a panic (#1209)
* Fix another whatsapp panic

* Update whatsapp vendor
2020-08-24 23:35:08 +02:00
Wim e8167ee3d7 Add link to nctalk in README 2020-08-24 00:50:32 +02:00
Wim 2f5e211065 Bump version 2020-08-24 00:40:26 +02:00
Wim 39f4fb3446 Release v1.18.1 (#1207) 2020-08-24 00:25:30 +02:00
Wim 56159b9bce Sleep when ratelimited on joins (matrix). Fixes #1201 (#1206) 2020-08-24 00:12:30 +02:00
Ben Wiederhake b2af76e7dc Support Telegram animated stickers (tgs) format (#1173)
This is half a fix for #874

This patch introduces a new config flag:
- MediaConvertTgs

These need to be treated independently from the existing
MediaConvertWebPToPNG flag because Tgs→WebP results in an
*animated* WebP, and the WebP→PNG converter can't handle
animated WebP files yet.

Furthermore, some platforms (like discord) don't even support
animated WebP files, so the user may want to fall back to
static PNGs (not APNGs).

The final reason why this is only half a fix is that this
introduces an external dependency, namely lottie, to be
installed like this:

$ pip3 install lottie cairosvg

This patch works by writing the tgs to a temporary file in /tmp,
calling lottie to convert it (this conversion may take several seconds!),
and then deleting the temporary file.
The temporary file is absolutely necessary, as lottie refuses to
work on non-seekable files.
If anyone comes up with a reasonable use case where /tmp is
unavailable, I can add yet another config option for that, if desired.

Telegram will bail out if the option is configured but lottie isn't found.
2020-08-23 22:34:28 +02:00
Wim 491fe35397 Update workflow builds to go 1.15 2020-08-21 00:29:59 +02:00
Wim b451285af7 Sync with upstream gozulipbot fixes (#1202) 2020-08-21 00:14:33 +02:00
Dellle 63a1847cdc Remove HTML formatting for push messages (#1188) (#1189)
When there is a valid HTML formatting then remove this in the cleartext
field of the matrix client. This leads to nicer push messages on
smartphone apps.

Fix #1188
2020-08-20 22:41:53 +02:00
Wim 4e50fd8649 Use mattermost v5 module (#1192) 2020-08-10 00:29:54 +02:00
Wim dfdffa0027 Add EnableAllEvents
Add option to have all events send to the messagechan
2020-08-09 21:46:45 +02:00
Wim ebd2073144 Handle panic in whatsapp. Fixes #1180 (#1184) 2020-07-30 23:55:31 +02:00
Wim 1e94b716fb Fix typo in documentation (#1183) 2020-07-30 23:46:03 +02:00
Wim 2a41abb3d1 Update linter config 2020-07-26 15:05:52 +02:00
Gary Kim 2d2bebe976 Fix Nextcloud Talk connection failure (#1179)
Fix #1177

Signed-off-by: Gary Kim <gary@garykim.dev>
2020-07-26 14:51:07 +02:00
Wim e1629994bd Bump version 2020-07-24 21:31:28 +02:00
2616 changed files with 204906 additions and 52229 deletions
+2
View File
@@ -0,0 +1,2 @@
Dockerfile
tgs.Dockerfile
+71
View File
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"
on:
push:
branches: [master]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 16 * * 1'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['go']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
+7 -7
View File
@@ -9,14 +9,14 @@ jobs:
with: with:
fetch-depth: 20 fetch-depth: 20
- name: Run golangci-lint - name: Run golangci-lint
uses: golangci/golangci-lint-action@v1 uses: golangci/golangci-lint-action@v2
with: with:
version: v1.27 version: v1.29
args: "-v --new-from-rev HEAD~1" args: "-v --new-from-rev HEAD~5"
test-build-upload: test-build-upload:
strategy: strategy:
matrix: matrix:
go-version: [1.13.x, 1.14.x] go-version: [1.14.x, 1.15.x]
platform: [ubuntu-latest] platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }} runs-on: ${{ matrix.platform }}
steps: steps:
@@ -38,19 +38,19 @@ jobs:
GOOS=windows GOARCH=amd64 go build -mod=vendor -ldflags "-s -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o output/win/matterbridge-$VERSION-windows-amd64.exe GOOS=windows GOARCH=amd64 go build -mod=vendor -ldflags "-s -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o output/win/matterbridge-$VERSION-windows-amd64.exe
GOOS=darwin GOARCH=amd64 go build -mod=vendor -ldflags "-s -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o output/mac/matterbridge-$VERSION-darwin-amd64 GOOS=darwin GOARCH=amd64 go build -mod=vendor -ldflags "-s -X main.githash=$(git log --pretty=format:'%h' -n 1)" -o output/mac/matterbridge-$VERSION-darwin-amd64
- name: Upload linux 64-bit - name: Upload linux 64-bit
if: startsWith(matrix.go-version,'1.14') if: startsWith(matrix.go-version,'1.15')
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: matterbridge-linux-64bit name: matterbridge-linux-64bit
path: output/lin path: output/lin
- name: Upload windows 64-bit - name: Upload windows 64-bit
if: startsWith(matrix.go-version,'1.14') if: startsWith(matrix.go-version,'1.15')
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: matterbridge-windows-64bit name: matterbridge-windows-64bit
path: output/win path: output/win
- name: Upload darwin 64-bit - name: Upload darwin 64-bit
if: startsWith(matrix.go-version,'1.14') if: startsWith(matrix.go-version,'1.15')
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: matterbridge-darwin-64bit name: matterbridge-darwin-64bit
+3 -2
View File
@@ -91,7 +91,6 @@ linters-settings:
# Correct spellings using locale preferences for US or UK. # Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English. # Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'. # Setting locale to US will correct the British spelling of 'colour' to 'color'.
locale: US
lll: lll:
# max line length, lines longer will be reported. Default is 120. # max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option # '\t' is counted as 1 character by default, and can be changed with the tab-width option
@@ -180,7 +179,9 @@ linters:
- goerr113 - goerr113
- testpackage - testpackage
- godot - godot
- interfacer
- goheader
- noctx
# rules to deal with reported isues # rules to deal with reported isues
issues: issues:
+6 -8
View File
@@ -1,13 +1,11 @@
FROM alpine:edge AS builder FROM alpine AS builder
COPY . /go/src/github.com/42wim/matterbridge COPY . /go/src/matterbridge
RUN apk update && apk add go git gcc musl-dev \ RUN apk --no-cache add go git \
&& cd /go/src/github.com/42wim/matterbridge \ && cd /go/src/matterbridge \
&& export GOPATH=/go \ && go build -mod vendor -ldflags "-X main.githash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge
&& go get \
&& go build -x -ldflags "-X main.githash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge
FROM alpine:edge FROM alpine
RUN apk --no-cache add ca-certificates mailcap RUN apk --no-cache add ca-certificates mailcap
COPY --from=builder /bin/matterbridge /bin/matterbridge COPY --from=builder /bin/matterbridge /bin/matterbridge
RUN mkdir /etc/matterbridge \ RUN mkdir /etc/matterbridge \
+52 -40
View File
@@ -70,7 +70,7 @@ And more...
- [Changelog](#changelog) - [Changelog](#changelog)
- [FAQ](#faq) - [FAQ](#faq)
- [Related projects](#related-projects) - [Related projects](#related-projects)
- [Articles](#articles) - [Articles / Tutorials](#articles--tutorials)
- [Thanks](#thanks) - [Thanks](#thanks)
## Features ## Features
@@ -91,13 +91,15 @@ And more...
- [IRC](http://www.mirc.com/servers.html) - [IRC](http://www.mirc.com/servers.html)
- [Keybase](https://keybase.io) - [Keybase](https://keybase.io)
- [Matrix](https://matrix.org) - [Matrix](https://matrix.org)
- [Mattermost](https://github.com/mattermost/mattermost-server/) 4.x, 5.x - [Mattermost](https://github.com/mattermost/mattermost-server/)
- [Microsoft Teams](https://teams.microsoft.com) - [Microsoft Teams](https://teams.microsoft.com)
- [Mumble](https://www.mumble.info/)
- [Nextcloud Talk](https://nextcloud.com/talk/) - [Nextcloud Talk](https://nextcloud.com/talk/)
- [Rocket.chat](https://rocket.chat) - [Rocket.chat](https://rocket.chat)
- [Slack](https://slack.com) - [Slack](https://slack.com)
- [Ssh-chat](https://github.com/shazow/ssh-chat) - [Ssh-chat](https://github.com/shazow/ssh-chat)
- [Steam](https://store.steampowered.com/) - ~~[Steam](https://store.steampowered.com/)~~
- Not supported anymore, see [here](https://github.com/Philipp15b/go-steam/issues/94) for more info.
- [Telegram](https://telegram.org) - [Telegram](https://telegram.org)
- [Twitch](https://twitch.tv) - [Twitch](https://twitch.tv)
- [WhatsApp](https://www.whatsapp.com/) - [WhatsApp](https://www.whatsapp.com/)
@@ -109,9 +111,11 @@ And more...
- [Discourse](https://github.com/DeclanHoare/matterbabble) - [Discourse](https://github.com/DeclanHoare/matterbabble)
- [Facebook messenger](https://github.com/VictorNine/fbridge) - [Facebook messenger](https://github.com/VictorNine/fbridge)
- [Minecraft](https://github.com/elytra/MatterLink) - [Minecraft](https://github.com/elytra/MatterLink)
- [Minecraft](https://github.com/raws/mattercraft)
- [Reddit](https://github.com/bonehurtingjuice/mattereddit) - [Reddit](https://github.com/bonehurtingjuice/mattereddit)
- [Counter-Strike, half-life and more](https://forums.alliedmods.net/showthread.php?t=319430) - [Counter-Strike, half-life and more](https://forums.alliedmods.net/showthread.php?t=319430)
- [MatterAMXX](https://github.com/GabeIggy/MatterAMXX) - [MatterAMXX](https://github.com/GabeIggy/MatterAMXX)
- [Vintage Story](https://github.com/NikkyAI/vs-matterbridge)
### API ### API
@@ -121,11 +125,13 @@ More info and examples on the [wiki](https://github.com/42wim/matterbridge/wiki/
Used by the projects below. Feel free to make a PR to add your project to this list. Used by the projects below. Feel free to make a PR to add your project to this list.
- [MatterLink](https://github.com/elytra/MatterLink) (Matterbridge link for Minecraft Server chat) - [MatterLink](https://github.com/elytra/MatterLink) (Matterbridge link for Minecraft Server chat)
- [Minecraft](https://github.com/raws/mattercraft) (Matterbridge link for Minecraft Server chat)
- [pyCord](https://github.com/NikkyAI/pyCord) (crossplatform chatbot) - [pyCord](https://github.com/NikkyAI/pyCord) (crossplatform chatbot)
- [Mattereddit](https://github.com/bonehurtingjuice/mattereddit) (Reddit chat support) - [Mattereddit](https://github.com/bonehurtingjuice/mattereddit) (Reddit chat support)
- [fbridge](https://github.com/VictorNine/fbridge) (Facebook messenger support) - [fbridge](https://github.com/VictorNine/fbridge) (Facebook messenger support)
- [matterbabble](https://github.com/DeclanHoare/matterbabble) (Discourse support) - [matterbabble](https://github.com/DeclanHoare/matterbabble) (Discourse support)
- [MatterAMXX](https://forums.alliedmods.net/showthread.php?t=319430) (Counter-Strike, half-life and more via AMXX mod) - [MatterAMXX](https://forums.alliedmods.net/showthread.php?t=319430) (Counter-Strike, half-life and more via AMXX mod)
- [Vintage Story](https://github.com/NikkyAI/vs-matterbridge)
## Chat with us ## Chat with us
@@ -146,16 +152,16 @@ Questions or want to test on your favorite platform? Join below:
## Screenshots ## Screenshots
See https://github.com/42wim/matterbridge/wiki See <https://github.com/42wim/matterbridge/wiki>
## Installing / upgrading ## Installing / upgrading
### Binaries ### Binaries
- Latest stable release [v1.18.0](https://github.com/42wim/matterbridge/releases/latest) - Latest stable release [v1.21.0](https://github.com/42wim/matterbridge/releases/latest)
- Development releases (follows master) can be downloaded [here](https://github.com/42wim/matterbridge/actions) selecting the latest green build and then artifacts. - Development releases (follows master) can be downloaded [here](https://github.com/42wim/matterbridge/actions) selecting the latest green build and then artifacts.
To install or upgrade just download the latest [binary](https://github.com/42wim/matterbridge/releases/latest) and follow the instructions on the [howto](https://github.com/42wim/matterbridge/wiki/How-to-create-your-config) for a step by step walkthrough for creating your configuration. To install or upgrade just download the latest [binary](https://github.com/42wim/matterbridge/releases/latest). On \*nix platforms you may need to make the binary executable - you can do this by running `chmod a+x` on the binary (example: `chmod a+x matterbridge-1.20.0-linux-64bit`). After downloading (and making the binary executable, if necessary), follow the instructions on the [howto](https://github.com/42wim/matterbridge/wiki/How-to-create-your-config) for a step by step walkthrough for creating your configuration.
### Packages ### Packages
@@ -167,16 +173,15 @@ To install or upgrade just download the latest [binary](https://github.com/42wim
Most people just want to use binaries, you can find those [here](https://github.com/42wim/matterbridge/releases/latest) Most people just want to use binaries, you can find those [here](https://github.com/42wim/matterbridge/releases/latest)
If you really want to build from source, follow these instructions: If you really want to build from source, follow these instructions:
Go 1.12+ is required. Make sure you have [Go](https://golang.org/doc/install) properly installed. Go 1.13+ is required. Make sure you have [Go](https://golang.org/doc/install) properly installed.
```bash
```
go get github.com/42wim/matterbridge go get github.com/42wim/matterbridge
``` ```
You should now have matterbridge binary in the ~/go/bin directory: You should now have matterbridge binary in the ~/go/bin directory:
``` ```bash
$ ls ~/go/bin/ $ ls ~/go/bin/
matterbridge matterbridge
``` ```
@@ -259,7 +264,7 @@ RemoteNickFormat="[{PROTOCOL}/{BRIDGE}] <{NICK}> "
See [howto](https://github.com/42wim/matterbridge/wiki/How-to-create-your-config) for a step by step walkthrough for creating your configuration. See [howto](https://github.com/42wim/matterbridge/wiki/How-to-create-your-config) for a step by step walkthrough for creating your configuration.
``` ```bash
Usage of ./matterbridge: Usage of ./matterbridge:
-conf string -conf string
config file (default "matterbridge.toml") config file (default "matterbridge.toml")
@@ -296,19 +301,23 @@ See [FAQ](https://github.com/42wim/matterbridge/wiki/FAQ)
- [fbridge](https://github.com/VictorNine/fbridge) (Facebook messenger support) - [fbridge](https://github.com/VictorNine/fbridge) (Facebook messenger support)
- [isla](https://github.com/alphachung/isla) (Bot for Discord-Telegram groups used alongside matterbridge) - [isla](https://github.com/alphachung/isla) (Bot for Discord-Telegram groups used alongside matterbridge)
- [matterbabble](https://github.com/DeclanHoare/matterbabble) (Connect Discourse threads to Matterbridge) - [matterbabble](https://github.com/DeclanHoare/matterbabble) (Connect Discourse threads to Matterbridge)
- [nextcloud talk](https://github.com/nextcloud/talk_matterbridge) (Integrates matterbridge in Nextcloud Talk)
- [mattercraft](https://github.com/raws/mattercraft) (Minecraft bridge)
- [vs-matterbridge](https://github.com/NikkyAI/vs-matterbridge) (Vintage Story bridge)
## Articles ## Articles / Tutorials
- [matterbridge on kubernetes](https://medium.freecodecamp.org/using-kubernetes-to-deploy-a-chat-gateway-or-when-technology-works-like-its-supposed-to-a169a8cd69a3) - [matterbridge on kubernetes](https://medium.freecodecamp.org/using-kubernetes-to-deploy-a-chat-gateway-or-when-technology-works-like-its-supposed-to-a169a8cd69a3)
- https://mattermost.com/blog/connect-irc-to-mattermost/ - <https://mattermost.com/blog/connect-irc-to-mattermost/>
- https://blog.valvin.fr/2016/09/17/mattermost-et-un-channel-irc-cest-possible/ - <https://blog.valvin.fr/2016/09/17/mattermost-et-un-channel-irc-cest-possible/>
- https://blog.brightscout.com/top-10-mattermost-integrations/ - <https://blog.brightscout.com/top-10-mattermost-integrations/>
- http://bencey.co.nz/2018/09/17/bridge/ - <https://www.algoo.fr/blog/2018/01/19/recouvrez-votre-liberte-en-quittant-slack-pour-un-mattermost-auto-heberge/>
- https://www.algoo.fr/blog/2018/01/19/recouvrez-votre-liberte-en-quittant-slack-pour-un-mattermost-auto-heberge/ - <https://kopano.com/blog/matterbridge-bridging-mattermost-chat/>
- https://kopano.com/blog/matterbridge-bridging-mattermost-chat/ - <https://www.stitcher.com/s/?eid=52382713>
- https://www.stitcher.com/s/?eid=52382713 - <https://daniele.tech/2019/02/how-to-use-matterbridge-to-connect-2-different-slack-workspaces/>
- https://daniele.tech/2019/02/how-to-use-matterbridge-to-connect-2-different-slack-workspaces/ - <https://userlinux.net/mattermost-and-matterbridge.html>
- https://userlinux.net/mattermost-and-matterbridge.html - <https://nextcloud.com/blog/bridging-chat-services-in-talk/>
- Youtube: [whatsapp - telegram bridging](https://www.youtube.com/watch?v=W-VXISoKtNc)
## Thanks ## Thanks
@@ -321,24 +330,27 @@ See [FAQ](https://github.com/42wim/matterbridge/wiki/FAQ)
Matterbridge wouldn't exist without these libraries: Matterbridge wouldn't exist without these libraries:
- discord - https://github.com/bwmarrin/discordgo - discord - <https://github.com/bwmarrin/discordgo>
- echo - https://github.com/labstack/echo - echo - <https://github.com/labstack/echo>
- gitter - https://github.com/sromku/go-gitter - gitter - <https://github.com/sromku/go-gitter>
- gops - https://github.com/google/gops - gops - <https://github.com/google/gops>
- gozulipbot - https://github.com/ifo/gozulipbot - gozulipbot - <https://github.com/ifo/gozulipbot>
- irc - https://github.com/lrstanley/girc - gumble - <https://github.com/layeh/gumble>
- keybase - https://github.com/keybase/go-keybase-chat-bot - irc - <https://github.com/lrstanley/girc>
- matrix - https://github.com/matrix-org/gomatrix - keybase - <https://github.com/keybase/go-keybase-chat-bot>
- mattermost - https://github.com/mattermost/mattermost-server - matrix - <https://github.com/matrix-org/gomatrix>
- msgraph.go - https://github.com/yaegashi/msgraph.go - mattermost - <https://github.com/mattermost/mattermost-server>
- slack - https://github.com/nlopes/slack - msgraph.go - <https://github.com/yaegashi/msgraph.go>
- sshchat - https://github.com/shazow/ssh-chat - mumble - <https://github.com/layeh/gumble>
- steam - https://github.com/Philipp15b/go-steam - nctalk - <https://github.com/gary-kim/go-nc-talk>
- telegram - https://github.com/go-telegram-bot-api/telegram-bot-api - slack - <https://github.com/nlopes/slack>
- tengo - https://github.com/d5/tengo - sshchat - <https://github.com/shazow/ssh-chat>
- whatsapp - https://github.com/Rhymen/go-whatsapp/ - steam - <https://github.com/Philipp15b/go-steam>
- xmpp - https://github.com/mattn/go-xmpp - telegram - <https://github.com/go-telegram-bot-api/telegram-bot-api>
- zulip - https://github.com/ifo/gozulipbot - tengo - <https://github.com/d5/tengo>
- whatsapp - <https://github.com/Rhymen/go-whatsapp>
- xmpp - <https://github.com/mattn/go-xmpp>
- zulip - <https://github.com/ifo/gozulipbot>
<!-- Links --> <!-- Links -->
@@ -350,7 +362,7 @@ Matterbridge wouldn't exist without these libraries:
[mb-mattermost]: https://framateam.org/signup_user_complete/?id=tfqm33ggop8x3qgu4boeieta6e [mb-mattermost]: https://framateam.org/signup_user_complete/?id=tfqm33ggop8x3qgu4boeieta6e
[mb-msteams]: https://teams.microsoft.com/join/hj92x75gd3y7 [mb-msteams]: https://teams.microsoft.com/join/hj92x75gd3y7
[mb-rocketchat]: https://open.rocket.chat/channel/matterbridge [mb-rocketchat]: https://open.rocket.chat/channel/matterbridge
[mb-slack]: https://join.slack.com/matterbridgechat/shared_invite/MjEwODMxNjU1NDMwLTE0OTk2MTU3NTMtMzZkZmRiNDZhOA [mb-slack]: https://join.slack.com/t/matterbridgechat/shared_invite/zt-2ourq2h2-7YvyYBq2WFGC~~zEzA68_Q
[mb-telegram]: https://t.me/Matterbridge [mb-telegram]: https://t.me/Matterbridge
[mb-twitch]: https://www.twitch.tv/matterbridge [mb-twitch]: https://www.twitch.tv/matterbridge
[mb-whatsapp]: https://www.whatsapp.com/ [mb-whatsapp]: https://www.whatsapp.com/
+50 -35
View File
@@ -6,9 +6,10 @@ import (
"sync" "sync"
"time" "time"
"gopkg.in/olahol/melody.v1"
"github.com/42wim/matterbridge/bridge" "github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/bridge/config"
"github.com/gorilla/websocket"
"github.com/labstack/echo/v4" "github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware" "github.com/labstack/echo/v4/middleware"
ring "github.com/zfjagann/golang-ring" ring "github.com/zfjagann/golang-ring"
@@ -18,6 +19,7 @@ type API struct {
Messages ring.Ring Messages ring.Ring
sync.RWMutex sync.RWMutex
*bridge.Config *bridge.Config
mrouter *melody.Melody
} }
type Message struct { type Message struct {
@@ -33,6 +35,32 @@ func New(cfg *bridge.Config) bridge.Bridger {
e := echo.New() e := echo.New()
e.HideBanner = true e.HideBanner = true
e.HidePort = true e.HidePort = true
b.mrouter = melody.New()
b.mrouter.HandleMessage(func(s *melody.Session, msg []byte) {
message := config.Message{}
err := json.Unmarshal(msg, &message)
if err != nil {
b.Log.Errorf("failed to decode message from byte[] '%s'", string(msg))
return
}
b.handleWebsocketMessage(message, s)
})
b.mrouter.HandleConnect(func(session *melody.Session) {
greet := b.getGreeting()
data, err := json.Marshal(greet)
if err != nil {
b.Log.Errorf("failed to encode message '%v'", greet)
return
}
err = session.Write(data)
if err != nil {
b.Log.Errorf("failed to write message '%s'", string(data))
return
}
// TODO: send message history buffer from `b.Messages` here
})
b.Messages = ring.Ring{} b.Messages = ring.Ring{}
if b.GetInt("Buffer") != 0 { if b.GetInt("Buffer") != 0 {
b.Messages.SetCapacity(b.GetInt("Buffer")) b.Messages.SetCapacity(b.GetInt("Buffer"))
@@ -67,13 +95,13 @@ func New(cfg *bridge.Config) bridge.Bridger {
func (b *API) Connect() error { func (b *API) Connect() error {
return nil return nil
} }
func (b *API) Disconnect() error { func (b *API) Disconnect() error {
return nil return nil
} }
func (b *API) JoinChannel(channel config.ChannelInfo) error { func (b *API) JoinChannel(channel config.ChannelInfo) error {
return nil return nil
} }
func (b *API) Send(msg config.Message) (string, error) { func (b *API) Send(msg config.Message) (string, error) {
@@ -83,7 +111,14 @@ func (b *API) Send(msg config.Message) (string, error) {
if msg.Event == config.EventMsgDelete { if msg.Event == config.EventMsgDelete {
return "", nil return "", nil
} }
b.Messages.Enqueue(&msg) b.Log.Debugf("enqueueing message from %s on ring buffer", msg.Username)
b.Messages.Enqueue(msg)
data, err := json.Marshal(msg)
if err != nil {
b.Log.Errorf("failed to encode message '%s'", msg)
}
_ = b.mrouter.Broadcast(data)
return "", nil return "", nil
} }
@@ -131,6 +166,7 @@ func (b *API) handleStream(c echo.Context) error {
} }
c.Response().Flush() c.Response().Flush()
for { for {
// TODO: this causes issues, messages should be broadcasted to all connected clients
msg := b.Messages.Dequeue() msg := b.Messages.Dequeue()
if msg != nil { if msg != nil {
if err := json.NewEncoder(c.Response()).Encode(msg); err != nil { if err := json.NewEncoder(c.Response()).Encode(msg); err != nil {
@@ -142,51 +178,30 @@ func (b *API) handleStream(c echo.Context) error {
} }
} }
func (b *API) handleWebsocketMessage(message config.Message) { func (b *API) handleWebsocketMessage(message config.Message, s *melody.Session) {
message.Channel = "api" message.Channel = "api"
message.Protocol = "api" message.Protocol = "api"
message.Account = b.Account message.Account = b.Account
message.ID = "" message.ID = ""
message.Timestamp = time.Now() message.Timestamp = time.Now()
data, err := json.Marshal(message)
if err != nil {
b.Log.Errorf("failed to encode message for loopback '%v'", message)
return
}
_ = b.mrouter.BroadcastOthers(data, s)
b.Log.Debugf("Sending websocket message from %s on %s to gateway", message.Username, "api") b.Log.Debugf("Sending websocket message from %s on %s to gateway", message.Username, "api")
b.Remote <- message b.Remote <- message
} }
func (b *API) writePump(conn *websocket.Conn) {
for {
msg := b.Messages.Dequeue()
if msg != nil {
err := conn.WriteJSON(msg)
if err != nil {
break
}
}
}
}
func (b *API) readPump(conn *websocket.Conn) {
for {
message := config.Message{}
err := conn.ReadJSON(&message)
if err != nil {
break
}
b.handleWebsocketMessage(message)
}
}
func (b *API) handleWebsocket(c echo.Context) error { func (b *API) handleWebsocket(c echo.Context) error {
conn, err := websocket.Upgrade(c.Response().Writer, c.Request(), nil, 1024, 1024) err := b.mrouter.HandleRequest(c.Response(), c.Request())
if err != nil { if err != nil {
b.Log.Errorf("error in websocket handling '%v'", err)
return err return err
} }
greet := b.getGreeting()
_ = conn.WriteJSON(greet)
go b.writePump(conn)
go b.readPump(conn)
return nil return nil
} }
+15 -2
View File
@@ -26,8 +26,11 @@ const (
EventAPIConnected = "api_connected" EventAPIConnected = "api_connected"
EventUserTyping = "user_typing" EventUserTyping = "user_typing"
EventGetChannelMembers = "get_channel_members" EventGetChannelMembers = "get_channel_members"
EventNoticeIRC = "notice_irc"
) )
const ParentIDNotFound = "msg-parent-not-found"
type Message struct { type Message struct {
Text string `json:"text"` Text string `json:"text"`
Channel string `json:"channel"` Channel string `json:"channel"`
@@ -44,6 +47,14 @@ type Message struct {
Extra map[string][]interface{} Extra map[string][]interface{}
} }
func (m Message) ParentNotFound() bool {
return m.ParentID == ParentIDNotFound
}
func (m Message) ParentValid() bool {
return m.ParentID != "" && !m.ParentNotFound()
}
type FileInfo struct { type FileInfo struct {
Name string Name string
Data *[]byte Data *[]byte
@@ -100,6 +111,7 @@ type Protocol struct {
MediaDownloadSize int // all protocols MediaDownloadSize int // all protocols
MediaServerDownload string MediaServerDownload string
MediaServerUpload string MediaServerUpload string
MediaConvertTgs string // telegram
MediaConvertWebPToPNG bool // telegram MediaConvertWebPToPNG bool // telegram
MessageDelay int // IRC, time in millisecond to wait between messages MessageDelay int // IRC, time in millisecond to wait between messages
MessageFormat string // telegram MessageFormat string // telegram
@@ -116,7 +128,7 @@ type Protocol struct {
NicksPerRow int // mattermost, slack NicksPerRow int // mattermost, slack
NoHomeServerSuffix bool // matrix NoHomeServerSuffix bool // matrix
NoSendJoinPart bool // all protocols NoSendJoinPart bool // all protocols
NoTLS bool // mattermost NoTLS bool // mattermost, xmpp
Password string // IRC,mattermost,XMPP,matrix Password string // IRC,mattermost,XMPP,matrix
PrefixMessagesWithNick bool // mattemost, slack PrefixMessagesWithNick bool // mattemost, slack
PreserveThreading bool // slack PreserveThreading bool // slack
@@ -153,7 +165,7 @@ type Protocol struct {
UseTLS bool // IRC UseTLS bool // IRC
UseDiscriminator bool // discord UseDiscriminator bool // discord
UseFirstName bool // telegram UseFirstName bool // telegram
UseUserName bool // discord UseUserName bool // discord, matrix
UseInsecureURL bool // telegram UseInsecureURL bool // telegram
VerboseJoinPart bool // IRC VerboseJoinPart bool // IRC
WebhookBindAddress string // mattermost, slack WebhookBindAddress string // mattermost, slack
@@ -212,6 +224,7 @@ type BridgeValues struct {
WhatsApp map[string]Protocol // TODO is this struct used? Search for "SlackLegacy" for example didn't return any results WhatsApp map[string]Protocol // TODO is this struct used? Search for "SlackLegacy" for example didn't return any results
Zulip map[string]Protocol Zulip map[string]Protocol
Keybase map[string]Protocol Keybase map[string]Protocol
Mumble map[string]Protocol
General Protocol General Protocol
Tengo Tengo Tengo Tengo
Gateway []Gateway Gateway []Gateway
+114 -242
View File
@@ -2,13 +2,13 @@ package bdiscord
import ( import (
"bytes" "bytes"
"errors"
"fmt" "fmt"
"strings" "strings"
"sync" "sync"
"github.com/42wim/matterbridge/bridge" "github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/discord/transmitter"
"github.com/42wim/matterbridge/bridge/helper" "github.com/42wim/matterbridge/bridge/helper"
"github.com/matterbridge/discordgo" "github.com/matterbridge/discordgo"
) )
@@ -23,9 +23,6 @@ type Bdiscord struct {
nick string nick string
userID string userID string
guildID string guildID string
webhookID string
webhookToken string
canEditWebhooks bool
channelsMutex sync.RWMutex channelsMutex sync.RWMutex
channels []*discordgo.Channel channels []*discordgo.Channel
@@ -34,8 +31,10 @@ type Bdiscord struct {
membersMutex sync.RWMutex membersMutex sync.RWMutex
userMemberMap map[string]*discordgo.Member userMemberMap map[string]*discordgo.Member
nickMemberMap map[string]*discordgo.Member nickMemberMap map[string]*discordgo.Member
webhookCache map[string]string
webhookMutex sync.RWMutex // Webhook specific logic
useAutoWebhooks bool
transmitter *transmitter.Transmitter
} }
func New(cfg *bridge.Config) bridge.Bridger { func New(cfg *bridge.Config) bridge.Bridger {
@@ -43,24 +42,18 @@ func New(cfg *bridge.Config) bridge.Bridger {
b.userMemberMap = make(map[string]*discordgo.Member) b.userMemberMap = make(map[string]*discordgo.Member)
b.nickMemberMap = make(map[string]*discordgo.Member) b.nickMemberMap = make(map[string]*discordgo.Member)
b.channelInfoMap = make(map[string]*config.ChannelInfo) b.channelInfoMap = make(map[string]*config.ChannelInfo)
b.webhookCache = make(map[string]string)
if b.GetString("WebhookURL") != "" { b.useAutoWebhooks = b.GetBool("AutoWebhooks")
b.Log.Debug("Configuring Discord Incoming Webhook") if b.useAutoWebhooks {
b.webhookID, b.webhookToken = b.splitURL(b.GetString("WebhookURL")) b.Log.Debug("Using automatic webhooks")
} }
return b return b
} }
func (b *Bdiscord) Connect() error { func (b *Bdiscord) Connect() error {
var err error var err error
var guildFound bool
token := b.GetString("Token") token := b.GetString("Token")
b.Log.Info("Connecting") b.Log.Info("Connecting")
if b.GetString("WebhookURL") == "" {
b.Log.Info("Connecting using token")
} else {
b.Log.Info("Connecting using webhookurl (for posting) and token")
}
if !strings.HasPrefix(b.GetString("Token"), "Bot ") { if !strings.HasPrefix(b.GetString("Token"), "Bot ") {
token = "Bot " + b.GetString("Token") token = "Bot " + b.GetString("Token")
} }
@@ -97,62 +90,107 @@ func (b *Bdiscord) Connect() error {
serverName := strings.Replace(b.GetString("Server"), "ID:", "", -1) serverName := strings.Replace(b.GetString("Server"), "ID:", "", -1)
b.nick = userinfo.Username b.nick = userinfo.Username
b.userID = userinfo.ID b.userID = userinfo.ID
// Try and find this account's guild, and populate channels
b.channelsMutex.Lock() b.channelsMutex.Lock()
for _, guild := range guilds { for _, guild := range guilds {
if guild.Name == serverName || guild.ID == serverName { // Skip, if the server name does not match the visible name or the ID
if guild.Name != serverName && guild.ID != serverName {
continue
}
// Complain about an ambiguous Server setting. Two Discord servers could have the same title!
// For IDs, practically this will never happen. It would only trigger if some server's name is also an ID.
if b.guildID != "" {
return fmt.Errorf("found multiple Discord servers with the same name %#v, expected to see only one", serverName)
}
// Getting this guild's channel could result in a permission error
b.channels, err = b.c.GuildChannels(guild.ID) b.channels, err = b.c.GuildChannels(guild.ID)
if err != nil { if err != nil {
break return fmt.Errorf("could not get %#v's channels: %w", b.GetString("Server"), err)
} }
b.guildID = guild.ID b.guildID = guild.ID
guildFound = true
}
} }
b.channelsMutex.Unlock() b.channelsMutex.Unlock()
if !guildFound {
msg := fmt.Sprintf("Server \"%s\" not found", b.GetString("Server")) // If we couldn't find a guild, we print extra debug information and return a nice error
err = errors.New(msg) if b.guildID == "" {
b.Log.Error(msg) err = fmt.Errorf("could not find Discord server %#v", b.GetString("Server"))
b.Log.Info("Possible values:") b.Log.Error(err.Error())
// Print all of the possible server values
b.Log.Info("Possible server values:")
for _, guild := range guilds { for _, guild := range guilds {
b.Log.Infof("Server=\"%s\" # Server name", guild.Name) b.Log.Infof("\t- Server=%#v # by name", guild.Name)
b.Log.Infof("Server=\"%s\" # Server ID", guild.ID) b.Log.Infof("\t- Server=%#v # by ID", guild.ID)
} }
// If there are no results, we should say that
if len(guilds) == 0 {
b.Log.Info("\t- (none found)")
} }
if err != nil {
return err return err
} }
b.channelsMutex.RLock() // Legacy note: WebhookURL used to have an actual webhook URL that we would edit,
if b.GetString("WebhookURL") == "" { // but we stopped doing that due to Discord making rate limits more aggressive.
for _, channel := range b.channels { //
b.Log.Debugf("found channel %#v", channel) // Even older: the same WebhookURL used to be used by every channel, which is usually unexpected.
// This is no longer possible.
if b.GetString("WebhookURL") != "" {
message := "The global WebhookURL setting has been removed. "
message += "You can get similar \"webhook editing\" behaviour by replacing this line with `AutoWebhooks=true`. "
message += "If you rely on the old-OLD (non-editing) behaviour, can move the WebhookURL to specific channel sections."
b.Log.Errorln(message)
return fmt.Errorf("use of removed WebhookURL setting")
} }
} else {
manageWebhooks := discordgo.PermissionManageWebhooks
var channelsDenied []string
for _, info := range b.Channels {
id := b.getChannelID(info.Name) // note(qaisjp): this readlocks channelsMutex
b.Log.Debugf("Verifying PermissionManageWebhooks for %s with ID %s", info.ID, id)
perms, permsErr := b.c.UserChannelPermissions(userinfo.ID, id) if b.GetInt("debuglevel") > 0 {
if permsErr != nil { b.Log.Debug("enabling even more discord debug")
b.Log.Warnf("Failed to check PermissionManageWebhooks in channel \"%s\": %s", info.Name, permsErr.Error()) b.c.Debug = true
} else if perms&manageWebhooks == manageWebhooks { }
// Initialise webhook management
b.transmitter = transmitter.New(b.c, b.guildID, "matterbridge", b.useAutoWebhooks)
b.transmitter.Log = b.Log
var webhookChannelIDs []string
for _, channel := range b.Channels {
channelID := b.getChannelID(channel.Name) // note(qaisjp): this readlocks channelsMutex
// If a WebhookURL was not explicitly provided for this channel,
// there are two options: just a regular bot message (ugly) or this is should be webhook sent
if channel.Options.WebhookURL == "" {
// If it should be webhook sent, we should enforce this via the transmitter
if b.useAutoWebhooks {
webhookChannelIDs = append(webhookChannelIDs, channelID)
}
continue continue
} }
channelsDenied = append(channelsDenied, fmt.Sprintf("%#v", info.Name))
whID, whToken, ok := b.splitURL(channel.Options.WebhookURL)
if !ok {
return fmt.Errorf("failed to parse WebhookURL %#v for channel %#v", channel.Options.WebhookURL, channel.ID)
} }
b.canEditWebhooks = len(channelsDenied) == 0 b.transmitter.AddWebhook(channelID, &discordgo.Webhook{
if b.canEditWebhooks { ID: whID,
b.Log.Info("Can manage webhooks; will edit channel for global webhook on send") Token: whToken,
} else { GuildID: b.guildID,
b.Log.Warn("Can't manage webhooks; won't edit channel for global webhook on send") ChannelID: channelID,
b.Log.Warn("Can't manage webhooks in channels: ", strings.Join(channelsDenied, ", ")) })
}
if b.useAutoWebhooks {
err = b.transmitter.RefreshGuildWebhooks(webhookChannelIDs)
if err != nil {
b.Log.WithError(err).Println("transmitter could not refresh guild webhooks")
return err
} }
} }
b.channelsMutex.RUnlock()
// Obtaining guild members and initializing nickname mapping. // Obtaining guild members and initializing nickname mapping.
b.membersMutex.Lock() b.membersMutex.Lock()
@@ -191,8 +229,6 @@ func (b *Bdiscord) JoinChannel(channel config.ChannelInfo) error {
func (b *Bdiscord) Send(msg config.Message) (string, error) { func (b *Bdiscord) Send(msg config.Message) (string, error) {
b.Log.Debugf("=> Receiving %#v", msg) b.Log.Debugf("=> Receiving %#v", msg)
origMsgID := msg.ID
channelID := b.getChannelID(msg.Channel) channelID := b.getChannelID(msg.Channel)
if channelID == "" { if channelID == "" {
return "", fmt.Errorf("Could not find channelID for %v", msg.Channel) return "", fmt.Errorf("Could not find channelID for %v", msg.Channel)
@@ -211,79 +247,23 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
msg.Text = "_" + msg.Text + "_" msg.Text = "_" + msg.Text + "_"
} }
// use initial webhook configured for the entire Discord account // Handle prefix hint for unthreaded messages.
isGlobalWebhook := true if msg.ParentNotFound() {
wID := b.webhookID msg.ParentID = ""
wToken := b.webhookToken msg.Text = fmt.Sprintf("[thread]: %s", msg.Text)
// check if have a channel specific webhook
b.channelsMutex.RLock()
if ci, ok := b.channelInfoMap[msg.Channel+b.Account]; ok {
if ci.Options.WebhookURL != "" {
wID, wToken = b.splitURL(ci.Options.WebhookURL)
isGlobalWebhook = false
} }
}
b.channelsMutex.RUnlock()
// Use webhook to send the message // Use webhook to send the message
if wID != "" && msg.Event != config.EventMsgDelete { useWebhooks := b.shouldMessageUseWebhooks(&msg)
// skip events if useWebhooks && msg.Event != config.EventMsgDelete && msg.ParentID == "" {
if msg.Event != "" && msg.Event != config.EventUserAction && msg.Event != config.EventJoinLeave && msg.Event != config.EventTopicChange { return b.handleEventWebhook(&msg, channelID)
return "", nil
} }
// If we are editing a message, delete the old message return b.handleEventBotUser(&msg, channelID)
if msg.ID != "" {
msg.ID = b.getCacheID(msg.ID)
b.Log.Debugf("Deleting edited webhook message")
err := b.c.ChannelMessageDelete(channelID, msg.ID)
if err != nil {
b.Log.Errorf("Could not delete edited webhook message: %s", err)
}
}
b.Log.Debugf("Broadcasting using Webhook")
// skip empty messages
if msg.Text == "" && (msg.Extra == nil || len(msg.Extra["file"]) == 0) {
b.Log.Debugf("Skipping empty message %#v", msg)
return "", nil
}
msg.Text = helper.ClipMessage(msg.Text, MessageLength)
msg.Text = b.replaceUserMentions(msg.Text)
// discord username must be [0..32] max
if len(msg.Username) > 32 {
msg.Username = msg.Username[0:32]
}
// if we have a global webhook for this Discord account, and permission
// to modify webhooks (previously verified), then set its channel to
// the message channel before using it
// TODO: this isn't necessary if the last message from this webhook was
// sent to the current channel
if isGlobalWebhook && b.canEditWebhooks {
b.Log.Debugf("Setting webhook channel to \"%s\"", msg.Channel)
_, err := b.c.WebhookEdit(wID, "", "", channelID)
if err != nil {
b.Log.Errorf("Could not set webhook channel: %s", err)
return "", err
}
}
b.Log.Debugf("Processing webhook sending for message %#v", msg)
msg, err := b.webhookSend(&msg, wID, wToken)
if err != nil {
b.Log.Errorf("Could not broadcast via webook for message %#v: %s", msg, err)
return "", err
}
if msg == nil {
return "", nil
}
b.updateCacheID(origMsgID, msg.ID)
return msg.ID, nil
} }
// handleEventDirect handles events via the bot user
func (b *Bdiscord) handleEventBotUser(msg *config.Message, channelID string) (string, error) {
b.Log.Debugf("Broadcasting using token (API)") b.Log.Debugf("Broadcasting using token (API)")
// Delete message // Delete message
@@ -291,14 +271,13 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
if msg.ID == "" { if msg.ID == "" {
return "", nil return "", nil
} }
msg.ID = b.getCacheID(msg.ID)
err := b.c.ChannelMessageDelete(channelID, msg.ID) err := b.c.ChannelMessageDelete(channelID, msg.ID)
return "", err return "", err
} }
// Upload a file if it exists // Upload a file if it exists
if msg.Extra != nil { if msg.Extra != nil {
for _, rmsg := range helper.HandleExtra(&msg, b.General) { for _, rmsg := range helper.HandleExtra(msg, b.General) {
rmsg.Text = helper.ClipMessage(rmsg.Text, MessageLength) rmsg.Text = helper.ClipMessage(rmsg.Text, MessageLength)
if _, err := b.c.ChannelMessageSend(channelID, rmsg.Username+rmsg.Text); err != nil { if _, err := b.c.ChannelMessageSend(channelID, rmsg.Username+rmsg.Text); err != nil {
b.Log.Errorf("Could not send message %#v: %s", rmsg, err) b.Log.Errorf("Could not send message %#v: %s", rmsg, err)
@@ -306,7 +285,7 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
} }
// check if we have files to upload (from slack, telegram or mattermost) // check if we have files to upload (from slack, telegram or mattermost)
if len(msg.Extra["file"]) > 0 { if len(msg.Extra["file"]) > 0 {
return b.handleUploadFile(&msg, channelID) return b.handleUploadFile(msg, channelID)
} }
} }
@@ -319,54 +298,27 @@ func (b *Bdiscord) Send(msg config.Message) (string, error) {
return msg.ID, err return msg.ID, err
} }
m := discordgo.MessageSend{
Content: msg.Username + msg.Text,
}
if msg.ParentValid() {
m.Reference = &discordgo.MessageReference{
MessageID: msg.ParentID,
ChannelID: channelID,
GuildID: b.guildID,
}
}
// Post normal message // Post normal message
res, err := b.c.ChannelMessageSend(channelID, msg.Username+msg.Text) res, err := b.c.ChannelMessageSendComplex(channelID, &m)
if err != nil { if err != nil {
return "", err return "", err
} }
return res.ID, nil return res.ID, nil
} }
// useWebhook returns true if we have a webhook defined somewhere
func (b *Bdiscord) useWebhook() bool {
if b.GetString("WebhookURL") != "" {
return true
}
b.channelsMutex.RLock()
defer b.channelsMutex.RUnlock()
for _, channel := range b.channelInfoMap {
if channel.Options.WebhookURL != "" {
return true
}
}
return false
}
// isWebhookID returns true if the specified id is used in a defined webhook
func (b *Bdiscord) isWebhookID(id string) bool {
if b.GetString("WebhookURL") != "" {
wID, _ := b.splitURL(b.GetString("WebhookURL"))
if wID == id {
return true
}
}
b.channelsMutex.RLock()
defer b.channelsMutex.RUnlock()
for _, channel := range b.channelInfoMap {
if channel.Options.WebhookURL != "" {
wID, _ := b.splitURL(channel.Options.WebhookURL)
if wID == id {
return true
}
}
}
return false
}
// handleUploadFile handles native upload of files // handleUploadFile handles native upload of files
func (b *Bdiscord) handleUploadFile(msg *config.Message, channelID string) (string, error) { func (b *Bdiscord) handleUploadFile(msg *config.Message, channelID string) (string, error) {
var err error var err error
@@ -388,83 +340,3 @@ func (b *Bdiscord) handleUploadFile(msg *config.Message, channelID string) (stri
} }
return "", nil return "", nil
} }
// webhookSend send one or more message via webhook, taking care of file
// uploads (from slack, telegram or mattermost).
// Returns messageID and error.
func (b *Bdiscord) webhookSend(msg *config.Message, webhookID, token string) (*discordgo.Message, error) {
var (
res *discordgo.Message
err error
)
// If avatar is unset, check if UseLocalAvatar contains the message's
// account or protocol, and if so, try to find a local avatar
if msg.Avatar == "" {
for _, val := range b.GetStringSlice("UseLocalAvatar") {
if msg.Protocol == val || msg.Account == val {
if avatar := b.findAvatar(msg); avatar != "" {
msg.Avatar = avatar
}
break
}
}
}
// WebhookParams can have either `Content` or `File`.
// We can't send empty messages.
if msg.Text != "" {
res, err = b.c.WebhookExecute(
webhookID,
token,
true,
&discordgo.WebhookParams{
Content: msg.Text,
Username: msg.Username,
AvatarURL: msg.Avatar,
},
)
if err != nil {
b.Log.Errorf("Could not send text (%s) for message %#v: %s", msg.Text, msg, err)
}
}
if msg.Extra != nil {
for _, f := range msg.Extra["file"] {
fi := f.(config.FileInfo)
file := discordgo.File{
Name: fi.Name,
ContentType: "",
Reader: bytes.NewReader(*fi.Data),
}
content := ""
if msg.Text == "" {
content = fi.Comment
}
_, e2 := b.c.WebhookExecute(
webhookID,
token,
false,
&discordgo.WebhookParams{
Username: msg.Username,
AvatarURL: msg.Avatar,
File: &file,
Content: content,
},
)
if e2 != nil {
b.Log.Errorf("Could not send file %#v for message %#v: %s", file, msg, e2)
}
}
}
return res, err
}
func (b *Bdiscord) findAvatar(m *config.Message) string {
member, err := b.getGuildMemberByNick(m.Username)
if err != nil {
return ""
}
return member.User.AvatarURL("")
}
+6 -1
View File
@@ -69,7 +69,7 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
return return
} }
// if using webhooks, do not relay if it's ours // if using webhooks, do not relay if it's ours
if b.useWebhook() && m.Author.Bot && b.isWebhookID(m.Author.ID) { if m.Author.Bot && b.transmitter.HasWebhook(m.Author.ID) {
return return
} }
@@ -127,6 +127,11 @@ func (b *Bdiscord) messageCreate(s *discordgo.Session, m *discordgo.MessageCreat
// Replace emotes // Replace emotes
rmsg.Text = replaceEmotes(rmsg.Text) rmsg.Text = replaceEmotes(rmsg.Text)
// Add our parent id if it exists, and if it's not referring to a message in another channel
if ref := m.MessageReference; ref != nil && ref.ChannelID == m.ChannelID {
rmsg.ParentID = ref.MessageID
}
b.Log.Debugf("<= Sending message from %s on %s to gateway", m.Author.Username, b.Account) b.Log.Debugf("<= Sending message from %s on %s to gateway", m.Author.Username, b.Account)
b.Log.Debugf("<= Message is %#v", rmsg) b.Log.Debugf("<= Message is %#v", rmsg)
b.Remote <- rmsg b.Remote <- rmsg
+3 -37
View File
@@ -196,7 +196,7 @@ func (b *Bdiscord) replaceAction(text string) (string, bool) {
} }
// splitURL splits a webhookURL and returns the ID and token. // splitURL splits a webhookURL and returns the ID and token.
func (b *Bdiscord) splitURL(url string) (string, string) { func (b *Bdiscord) splitURL(url string) (string, string, bool) {
const ( const (
expectedWebhookSplitCount = 7 expectedWebhookSplitCount = 7
webhookIdxID = 5 webhookIdxID = 5
@@ -204,43 +204,9 @@ func (b *Bdiscord) splitURL(url string) (string, string) {
) )
webhookURLSplit := strings.Split(url, "/") webhookURLSplit := strings.Split(url, "/")
if len(webhookURLSplit) != expectedWebhookSplitCount { if len(webhookURLSplit) != expectedWebhookSplitCount {
b.Log.Fatalf("%s is no correct discord WebhookURL", url) return "", "", false
} }
return webhookURLSplit[webhookIdxID], webhookURLSplit[webhookIdxToken] return webhookURLSplit[webhookIdxID], webhookURLSplit[webhookIdxToken], true
}
// getcacheID tries to find a corresponding msgID in the webhook cache.
// if not found returns the original request.
func (b *Bdiscord) getCacheID(msgID string) string {
b.webhookMutex.RLock()
defer b.webhookMutex.RUnlock()
for k, v := range b.webhookCache {
if msgID == k {
return v
}
}
return msgID
}
// updateCacheID updates the cache so that the newID takes the place of
// the original ID. This is used for edit/deletes in combination with webhooks
// as editing a message via webhook means deleting the message and creating a
// new message (with a new ID). This ID needs to be set instead of the original ID
func (b *Bdiscord) updateCacheID(origID, newID string) {
b.webhookMutex.Lock()
match := false
for k, v := range b.webhookCache {
if v == origID {
delete(b.webhookCache, k)
b.webhookCache[origID] = newID
match = true
continue
}
}
if !match && origID != "" {
b.webhookCache[origID] = newID
}
b.webhookMutex.Unlock()
} }
func enumerateUsernames(s string) []string { func enumerateUsernames(s string) []string {
+258
View File
@@ -0,0 +1,258 @@
// Package transmitter provides functionality for transmitting
// arbitrary webhook messages to Discord.
//
// The package provides the following functionality:
//
// - Creating new webhooks, whenever necessary
// - Loading webhooks that we have previously created
// - Sending new messages
// - Editing messages, via message ID
// - Deleting messages, via message ID
//
// The package has been designed for matterbridge, but with other
// Go bots in mind. The public API should be matterbridge-agnostic.
package transmitter
import (
"errors"
"fmt"
"strings"
"sync"
"time"
"github.com/matterbridge/discordgo"
log "github.com/sirupsen/logrus"
)
// A Transmitter represents a message manager for a single guild.
type Transmitter struct {
session *discordgo.Session
guild string
title string
autoCreate bool
// channelWebhooks maps from a channel ID to a webhook instance
channelWebhooks map[string]*discordgo.Webhook
mutex sync.RWMutex
Log *log.Entry
}
// ErrWebhookNotFound is returned when a valid webhook for this channel/message combination does not exist
var ErrWebhookNotFound = errors.New("webhook for this channel and message does not exist")
// ErrPermissionDenied is returned if the bot does not have permission to manage webhooks.
//
// Bots can be granted a guild-wide permission and channel-specific permissions to manage webhooks.
// Despite potentially having guild-wide permission, channel specific overrides could deny a bot's permission to manage webhooks.
var ErrPermissionDenied = errors.New("missing 'Manage Webhooks' permission")
// New returns a new Transmitter given a Discord session, guild ID, and title.
func New(session *discordgo.Session, guild string, title string, autoCreate bool) *Transmitter {
return &Transmitter{
session: session,
guild: guild,
title: title,
autoCreate: autoCreate,
channelWebhooks: make(map[string]*discordgo.Webhook),
Log: log.NewEntry(nil),
}
}
// Send transmits a message to the given channel with the provided webhook data, and waits until Discord responds with message data.
func (t *Transmitter) Send(channelID string, params *discordgo.WebhookParams) (*discordgo.Message, error) {
wh, err := t.getOrCreateWebhook(channelID)
if err != nil {
return nil, err
}
msg, err := t.session.WebhookExecute(wh.ID, wh.Token, true, params)
if err != nil {
return nil, fmt.Errorf("execute failed: %w", err)
}
return msg, nil
}
// Edit will edit a message in a channel, if possible.
func (t *Transmitter) Edit(channelID string, messageID string, params *discordgo.WebhookParams) error {
wh := t.getWebhook(channelID)
if wh == nil {
return ErrWebhookNotFound
}
uri := discordgo.EndpointWebhookToken(wh.ID, wh.Token) + "/messages/" + messageID
_, err := t.session.RequestWithBucketID("PATCH", uri, params, discordgo.EndpointWebhookToken("", ""))
if err != nil {
return err
}
return nil
}
// HasWebhook checks whether the transmitter is using a particular webhook.
func (t *Transmitter) HasWebhook(id string) bool {
t.mutex.RLock()
defer t.mutex.RUnlock()
for _, wh := range t.channelWebhooks {
if wh.ID == id {
return true
}
}
return false
}
// AddWebhook allows you to register a channel's webhook with the transmitter.
func (t *Transmitter) AddWebhook(channelID string, webhook *discordgo.Webhook) bool {
t.Log.Debugf("Manually added webhook %#v to channel %#v", webhook.ID, channelID)
t.mutex.Lock()
defer t.mutex.Unlock()
_, replaced := t.channelWebhooks[channelID]
t.channelWebhooks[channelID] = webhook
return replaced
}
// RefreshGuildWebhooks loads "relevant" webhooks into the transmitter, with careful permission handling.
//
// Notes:
//
// - A webhook is "relevant" if it was created by this bot -- the ApplicationID should match the bot's ID.
// - The term "having permission" means having the "Manage Webhooks" permission. See ErrPermissionDenied for more information.
// - This function is additive and will not unload previously loaded webhooks.
// - A nil channelIDs slice is treated the same as an empty one.
//
// If the bot has guild-wide permission:
//
// 1. it will load any "relevant" webhooks from the entire guild
// 2. the given slice is ignored
//
// If the bot does not have guild-wide permission:
//
// 1. it will load any "relevant" webhooks in each channel
// 2. a single error will be returned if any error occurs (incl. if there is no permission for any of these channels)
//
// If any channel has more than one "relevant" webhook, it will randomly pick one.
func (t *Transmitter) RefreshGuildWebhooks(channelIDs []string) error {
t.Log.Debugln("Refreshing guild webhooks")
botID, err := getDiscordUserID(t.session)
if err != nil {
return fmt.Errorf("could not get current user: %w", err)
}
// Get all existing webhooks
hooks, err := t.session.GuildWebhooks(t.guild)
if err != nil {
switch {
case isDiscordPermissionError(err):
// We fallback on manually fetching hooks from individual channels
// if we don't have the "Manage Webhooks" permission globally.
// We can only do this if we were provided channelIDs, though.
if len(channelIDs) == 0 {
return ErrPermissionDenied
}
t.Log.Debugln("Missing global 'Manage Webhooks' permission, falling back on per-channel permission")
return t.fetchChannelsHooks(channelIDs, botID)
default:
return fmt.Errorf("could not get webhooks: %w", err)
}
}
t.Log.Debugln("Refreshing guild webhooks using global permission")
t.assignHooksByAppID(hooks, botID, false)
return nil
}
// createWebhook creates a webhook for a specific channel.
func (t *Transmitter) createWebhook(channel string) (*discordgo.Webhook, error) {
t.mutex.Lock()
defer t.mutex.Unlock()
wh, err := t.session.WebhookCreate(channel, t.title+time.Now().Format(" 3:04:05PM"), "")
if err != nil {
return nil, err
}
t.channelWebhooks[channel] = wh
return wh, nil
}
func (t *Transmitter) getWebhook(channel string) *discordgo.Webhook {
t.mutex.RLock()
defer t.mutex.RUnlock()
return t.channelWebhooks[channel]
}
func (t *Transmitter) getOrCreateWebhook(channelID string) (*discordgo.Webhook, error) {
// If we have a webhook for this channel, immediately return it
wh := t.getWebhook(channelID)
if wh != nil {
return wh, nil
}
// Early exit if we don't want to automatically create one
if !t.autoCreate {
return nil, ErrWebhookNotFound
}
t.Log.Infof("Creating a webhook for %s\n", channelID)
wh, err := t.createWebhook(channelID)
if err != nil {
return nil, fmt.Errorf("could not create webhook: %w", err)
}
return wh, nil
}
// fetchChannelsHooks fetches hooks for the given channelIDs and calls assignHooksByAppID for each channel's hooks
func (t *Transmitter) fetchChannelsHooks(channelIDs []string, botID string) error {
// For each channel, search for relevant hooks
var failedHooks []string
for _, channelID := range channelIDs {
hooks, err := t.session.ChannelWebhooks(channelID)
if err != nil {
failedHooks = append(failedHooks, "\n- "+channelID+": "+err.Error())
continue
}
t.assignHooksByAppID(hooks, botID, true)
}
// Compose an error if any hooks failed
if len(failedHooks) > 0 {
return errors.New("failed to fetch hooks:" + strings.Join(failedHooks, ""))
}
return nil
}
func (t *Transmitter) assignHooksByAppID(hooks []*discordgo.Webhook, appID string, channelTargeted bool) {
logLine := "Picking up webhook"
if channelTargeted {
logLine += " (channel targeted)"
}
t.mutex.Lock()
defer t.mutex.Unlock()
for _, wh := range hooks {
if wh.ApplicationID != appID {
continue
}
t.channelWebhooks[wh.ChannelID] = wh
t.Log.WithFields(log.Fields{
"id": wh.ID,
"name": wh.Name,
"channel": wh.ChannelID,
}).Println(logLine)
break
}
}
+32
View File
@@ -0,0 +1,32 @@
package transmitter
import (
"github.com/matterbridge/discordgo"
)
// isDiscordPermissionError returns false for nil, and true if a Discord RESTError with code discordgo.ErrorCodeMissionPermissions
func isDiscordPermissionError(err error) bool {
if err == nil {
return false
}
restErr, ok := err.(*discordgo.RESTError)
if !ok {
return false
}
return restErr.Message != nil && restErr.Message.Code == discordgo.ErrCodeMissingPermissions
}
// getDiscordUserID gets own user ID from state, and fallback on API request
func getDiscordUserID(session *discordgo.Session) (string, error) {
if user := session.State.User; user != nil {
return user.ID, nil
}
user, err := session.User("@me")
if err != nil {
return "", err
}
return user.ID, nil
}
+147
View File
@@ -0,0 +1,147 @@
package bdiscord
import (
"bytes"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
"github.com/matterbridge/discordgo"
)
// shouldMessageUseWebhooks checks if have a channel specific webhook, if we're not using auto webhooks
func (b *Bdiscord) shouldMessageUseWebhooks(msg *config.Message) bool {
if b.useAutoWebhooks {
return true
}
b.channelsMutex.RLock()
defer b.channelsMutex.RUnlock()
if ci, ok := b.channelInfoMap[msg.Channel+b.Account]; ok {
if ci.Options.WebhookURL != "" {
return true
}
}
return false
}
// maybeGetLocalAvatar checks if UseLocalAvatar contains the message's
// account or protocol, and if so, returns the Discord avatar (if exists)
func (b *Bdiscord) maybeGetLocalAvatar(msg *config.Message) string {
for _, val := range b.GetStringSlice("UseLocalAvatar") {
if msg.Protocol != val && msg.Account != val {
continue
}
member, err := b.getGuildMemberByNick(msg.Username)
if err != nil {
return ""
}
return member.User.AvatarURL("")
}
return ""
}
// webhookSend send one or more message via webhook, taking care of file
// uploads (from slack, telegram or mattermost).
// Returns messageID and error.
func (b *Bdiscord) webhookSend(msg *config.Message, channelID string) (*discordgo.Message, error) {
var (
res *discordgo.Message
err error
)
// If avatar is unset, mutate the message to include the local avatar (but only if settings say we should do this)
if msg.Avatar == "" {
msg.Avatar = b.maybeGetLocalAvatar(msg)
}
// WebhookParams can have either `Content` or `File`.
// We can't send empty messages.
if msg.Text != "" {
res, err = b.transmitter.Send(
channelID,
&discordgo.WebhookParams{
Content: msg.Text,
Username: msg.Username,
AvatarURL: msg.Avatar,
},
)
if err != nil {
b.Log.Errorf("Could not send text (%s) for message %#v: %s", msg.Text, msg, err)
}
}
if msg.Extra != nil {
for _, f := range msg.Extra["file"] {
fi := f.(config.FileInfo)
file := discordgo.File{
Name: fi.Name,
ContentType: "",
Reader: bytes.NewReader(*fi.Data),
}
content := ""
if msg.Text == "" {
content = fi.Comment
}
_, e2 := b.transmitter.Send(
channelID,
&discordgo.WebhookParams{
Username: msg.Username,
AvatarURL: msg.Avatar,
File: &file,
Content: content,
},
)
if e2 != nil {
b.Log.Errorf("Could not send file %#v for message %#v: %s", file, msg, e2)
}
}
}
return res, err
}
func (b *Bdiscord) handleEventWebhook(msg *config.Message, channelID string) (string, error) {
// skip events
if msg.Event != "" && msg.Event != config.EventUserAction && msg.Event != config.EventJoinLeave && msg.Event != config.EventTopicChange {
return "", nil
}
// skip empty messages
if msg.Text == "" && (msg.Extra == nil || len(msg.Extra["file"]) == 0) {
b.Log.Debugf("Skipping empty message %#v", msg)
return "", nil
}
msg.Text = helper.ClipMessage(msg.Text, MessageLength)
msg.Text = b.replaceUserMentions(msg.Text)
// discord username must be [0..32] max
if len(msg.Username) > 32 {
msg.Username = msg.Username[0:32]
}
if msg.ID != "" {
b.Log.Debugf("Editing webhook message")
err := b.transmitter.Edit(channelID, msg.ID, &discordgo.WebhookParams{
Content: msg.Text,
Username: msg.Username,
})
if err == nil {
return msg.ID, nil
}
b.Log.Errorf("Could not edit webhook message: %s", err)
}
b.Log.Debugf("Processing webhook sending for message %#v", msg)
discordMsg, err := b.webhookSend(msg, channelID)
if err != nil {
b.Log.Errorf("Could not broadcast via webhook for message %#v: %s", msg, err)
return "", err
}
if discordMsg == nil {
return "", nil
}
return discordMsg.ID, nil
}
+51 -2
View File
@@ -5,7 +5,10 @@ import (
"fmt" "fmt"
"image/png" "image/png"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os"
"os/exec"
"regexp" "regexp"
"strings" "strings"
"time" "time"
@@ -180,7 +183,7 @@ func ClipMessage(text string, length int) string {
// ParseMarkdown takes in an input string as markdown and parses it to html // ParseMarkdown takes in an input string as markdown and parses it to html
func ParseMarkdown(input string) string { func ParseMarkdown(input string) string {
extensions := parser.HardLineBreak | parser.NoIntraEmphasis extensions := parser.HardLineBreak | parser.NoIntraEmphasis | parser.FencedCode
markdownParser := parser.NewWithExtensions(extensions) markdownParser := parser.NewWithExtensions(extensions)
renderer := html.NewRenderer(html.RendererOptions{ renderer := html.NewRenderer(html.RendererOptions{
Flags: 0, Flags: 0,
@@ -192,7 +195,7 @@ func ParseMarkdown(input string) string {
return res return res
} }
// ConvertWebPToPNG convert input data (which should be WebP format to PNG format) // ConvertWebPToPNG converts input data (which should be WebP format) to PNG format
func ConvertWebPToPNG(data *[]byte) error { func ConvertWebPToPNG(data *[]byte) error {
r := bytes.NewReader(*data) r := bytes.NewReader(*data)
m, err := webp.Decode(r) m, err := webp.Decode(r)
@@ -207,3 +210,49 @@ func ConvertWebPToPNG(data *[]byte) error {
*data = w.Bytes() *data = w.Bytes()
return nil return nil
} }
// CanConvertTgsToX Checks whether the external command necessary for ConvertTgsToX works.
func CanConvertTgsToX() error {
// We depend on the fact that `lottie_convert.py --help` has exit status 0.
// Hyrum's Law predicted this, and Murphy's Law predicts that this will break eventually.
// However, there is no alternative like `lottie_convert.py --is-properly-installed`
cmd := exec.Command("lottie_convert.py", "--help")
return cmd.Run()
}
// ConvertTgsToWebP convert input data (which should be tgs format) to WebP format
// This relies on an external command, which is ugly, but works.
func ConvertTgsToX(data *[]byte, outputFormat string, logger *logrus.Entry) error {
// lottie can't handle input from a pipe, so write to a temporary file:
tmpFile, err := ioutil.TempFile(os.TempDir(), "matterbridge-lottie-*.tgs")
if err != nil {
return err
}
tmpFileName := tmpFile.Name()
defer func() {
if removeErr := os.Remove(tmpFileName); removeErr != nil {
logger.Errorf("Could not delete temporary file %s: %v", tmpFileName, removeErr)
}
}()
if _, writeErr := tmpFile.Write(*data); writeErr != nil {
return writeErr
}
// Must close before calling lottie to avoid data races:
if closeErr := tmpFile.Close(); closeErr != nil {
return closeErr
}
// Call lottie to transform:
cmd := exec.Command("lottie_convert.py", "--input-format", "lottie", "--output-format", outputFormat, tmpFileName, "/dev/stdout")
cmd.Stderr = nil
// NB: lottie writes progress into to stderr in all cases.
stdout, stderr := cmd.Output()
if stderr != nil {
// 'stderr' already contains some parts of Stderr, because it was set to 'nil'.
return stderr
}
*data = stdout
return nil
}
+35 -8
View File
@@ -67,6 +67,20 @@ func (b *Birc) handleFiles(msg *config.Message) bool {
return true return true
} }
func (b *Birc) handleInvite(client *girc.Client, event girc.Event) {
if len(event.Params) != 2 {
return
}
channel := event.Params[1]
b.Log.Debugf("got invite for %s", channel)
if _, ok := b.channels[channel]; ok {
b.i.Cmd.Join(channel)
}
}
func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) { func (b *Birc) handleJoinPart(client *girc.Client, event girc.Event) {
if len(event.Params) == 0 { if len(event.Params) == 0 {
b.Log.Debugf("handleJoinPart: empty Params? %#v", event) b.Log.Debugf("handleJoinPart: empty Params? %#v", event)
@@ -109,14 +123,15 @@ func (b *Birc) handleNewConnection(client *girc.Client, event girc.Event) {
i := b.i i := b.i
b.Nick = event.Params[0] b.Nick = event.Params[0]
i.Handlers.Add("PRIVMSG", b.handlePrivMsg) i.Handlers.AddBg("PRIVMSG", b.handlePrivMsg)
i.Handlers.Add("CTCP_ACTION", b.handlePrivMsg) i.Handlers.AddBg("CTCP_ACTION", b.handlePrivMsg)
i.Handlers.Add(girc.RPL_TOPICWHOTIME, b.handleTopicWhoTime) i.Handlers.Add(girc.RPL_TOPICWHOTIME, b.handleTopicWhoTime)
i.Handlers.Add(girc.NOTICE, b.handleNotice) i.Handlers.AddBg(girc.NOTICE, b.handleNotice)
i.Handlers.Add("JOIN", b.handleJoinPart) i.Handlers.AddBg("JOIN", b.handleJoinPart)
i.Handlers.Add("PART", b.handleJoinPart) i.Handlers.AddBg("PART", b.handleJoinPart)
i.Handlers.Add("QUIT", b.handleJoinPart) i.Handlers.AddBg("QUIT", b.handleJoinPart)
i.Handlers.Add("KICK", b.handleJoinPart) i.Handlers.AddBg("KICK", b.handleJoinPart)
i.Handlers.Add("INVITE", b.handleInvite)
} }
func (b *Birc) handleNickServ() { func (b *Birc) handleNickServ() {
@@ -170,7 +185,14 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {
if b.skipPrivMsg(event) { if b.skipPrivMsg(event) {
return return
} }
rmsg := config.Message{Username: event.Source.Name, Channel: strings.ToLower(event.Params[0]), Account: b.Account, UserID: event.Source.Ident + "@" + event.Source.Host}
rmsg := config.Message{
Username: event.Source.Name,
Channel: strings.ToLower(event.Params[0]),
Account: b.Account,
UserID: event.Source.Ident + "@" + event.Source.Host,
}
b.Log.Debugf("== Receiving PRIVMSG: %s %s %#v", event.Source.Name, event.Last(), event) b.Log.Debugf("== Receiving PRIVMSG: %s %s %#v", event.Source.Name, event.Last(), event)
// set action event // set action event
@@ -178,6 +200,11 @@ func (b *Birc) handlePrivMsg(client *girc.Client, event girc.Event) {
rmsg.Event = config.EventUserAction rmsg.Event = config.EventUserAction
} }
// set NOTICE event
if event.Command == "NOTICE" {
rmsg.Event = config.EventNoticeIRC
}
// strip action, we made an event if it was an action // strip action, we made an event if it was an action
rmsg.Text += event.StripAction() rmsg.Text += event.StripAction()
+69 -5
View File
@@ -4,6 +4,7 @@ import (
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"hash/crc32" "hash/crc32"
"io/ioutil"
"net" "net"
"sort" "sort"
"strconv" "strconv"
@@ -29,6 +30,7 @@ type Birc struct {
Local chan config.Message // local queue for flood control Local chan config.Message // local queue for flood control
FirstConnection, authDone bool FirstConnection, authDone bool
MessageDelay, MessageQueue, MessageLength int MessageDelay, MessageQueue, MessageLength int
channels map[string]bool
*bridge.Config *bridge.Config
} }
@@ -39,6 +41,8 @@ func New(cfg *bridge.Config) bridge.Bridger {
b.Nick = b.GetString("Nick") b.Nick = b.GetString("Nick")
b.names = make(map[string][]string) b.names = make(map[string][]string)
b.connected = make(chan error) b.connected = make(chan error)
b.channels = make(map[string]bool)
if b.GetInt("MessageDelay") == 0 { if b.GetInt("MessageDelay") == 0 {
b.MessageDelay = 1300 b.MessageDelay = 1300
} else { } else {
@@ -111,6 +115,7 @@ func (b *Birc) Disconnect() error {
} }
func (b *Birc) JoinChannel(channel config.ChannelInfo) error { func (b *Birc) JoinChannel(channel config.ChannelInfo) error {
b.channels[channel.Name] = true
// need to check if we have nickserv auth done before joining channels // need to check if we have nickserv auth done before joining channels
for { for {
if b.authDone { if b.authDone {
@@ -200,25 +205,61 @@ func (b *Birc) doConnect() {
} }
} }
// Sanitize nicks for RELAYMSG: replace IRC characters with special meanings with "-"
func sanitizeNick(nick string) string {
sanitize := func(r rune) rune {
if strings.ContainsRune("!+%@&#$:'\"?*,. ", r) {
return '-'
}
return r
}
return strings.Map(sanitize, nick)
}
func (b *Birc) doSend() { func (b *Birc) doSend() {
rate := time.Millisecond * time.Duration(b.MessageDelay) rate := time.Millisecond * time.Duration(b.MessageDelay)
throttle := time.NewTicker(rate) throttle := time.NewTicker(rate)
for msg := range b.Local { for msg := range b.Local {
<-throttle.C <-throttle.C
username := msg.Username username := msg.Username
if b.GetBool("Colornicks") && len(username) > 1 { // Optional support for the proposed RELAYMSG extension, described at
// https://github.com/jlu5/ircv3-specifications/blob/master/extensions/relaymsg.md
// nolint:nestif
if (b.i.HasCapability("overdrivenetworks.com/relaymsg") || b.i.HasCapability("draft/relaymsg")) &&
b.GetBool("UseRelayMsg") {
username = sanitizeNick(username)
text := msg.Text
// Work around girc chomping leading commas on single word messages?
if strings.HasPrefix(text, ":") && !strings.ContainsRune(text, ' ') {
text = ":" + text
}
if msg.Event == config.EventUserAction {
b.i.Cmd.SendRawf("RELAYMSG %s %s :\x01ACTION %s\x01", msg.Channel, username, text) //nolint:errcheck
} else {
b.Log.Debugf("Sending RELAYMSG to channel %s: nick=%s", msg.Channel, username)
b.i.Cmd.SendRawf("RELAYMSG %s %s :%s", msg.Channel, username, text) //nolint:errcheck
}
} else {
if b.GetBool("Colornicks") {
checksum := crc32.ChecksumIEEE([]byte(msg.Username)) checksum := crc32.ChecksumIEEE([]byte(msg.Username))
colorCode := checksum%14 + 2 // quick fix - prevent white or black color codes colorCode := checksum%14 + 2 // quick fix - prevent white or black color codes
username = fmt.Sprintf("\x03%02d%s\x0F", colorCode, msg.Username) username = fmt.Sprintf("\x03%02d%s\x0F", colorCode, msg.Username)
} }
if msg.Event == config.EventUserAction { switch msg.Event {
case config.EventUserAction:
b.i.Cmd.Action(msg.Channel, username+msg.Text) b.i.Cmd.Action(msg.Channel, username+msg.Text)
} else { case config.EventNoticeIRC:
b.Log.Debugf("Sending notice to channel %s", msg.Channel)
b.i.Cmd.Notice(msg.Channel, username+msg.Text)
default:
b.Log.Debugf("Sending to channel %s", msg.Channel) b.Log.Debugf("Sending to channel %s", msg.Channel)
b.i.Cmd.Message(msg.Channel, username+msg.Text) b.i.Cmd.Message(msg.Channel, username+msg.Text)
} }
} }
} }
}
// validateInput validates the server/port/nick configuration. Returns a *girc.Client if successful // validateInput validates the server/port/nick configuration. Returns a *girc.Client if successful
func (b *Birc) getClient() (*girc.Client, error) { func (b *Birc) getClient() (*girc.Client, error) {
@@ -240,6 +281,18 @@ func (b *Birc) getClient() (*girc.Client, error) {
user = user[1:] user = user[1:]
} }
debug := ioutil.Discard
if b.GetInt("DebugLevel") == 2 {
debug = b.Log.Writer()
}
pingDelay, err := time.ParseDuration(b.GetString("pingdelay"))
if err != nil || pingDelay == 0 {
pingDelay = time.Minute
}
b.Log.Debugf("setting pingdelay to %s", pingDelay)
i := girc.New(girc.Config{ i := girc.New(girc.Config{
Server: server, Server: server,
ServerPass: b.GetString("Password"), ServerPass: b.GetString("Password"),
@@ -249,9 +302,11 @@ func (b *Birc) getClient() (*girc.Client, error) {
Name: b.GetString("Nick"), Name: b.GetString("Nick"),
SSL: b.GetBool("UseTLS"), SSL: b.GetBool("UseTLS"),
TLSConfig: &tls.Config{InsecureSkipVerify: b.GetBool("SkipTLSVerify"), ServerName: server}, //nolint:gosec TLSConfig: &tls.Config{InsecureSkipVerify: b.GetBool("SkipTLSVerify"), ServerName: server}, //nolint:gosec
PingDelay: time.Minute, PingDelay: pingDelay,
// skip gIRC internal rate limiting, since we have our own throttling // skip gIRC internal rate limiting, since we have our own throttling
AllowFlood: true, AllowFlood: true,
Debug: debug,
SupportedCaps: map[string][]string{"overdrivenetworks.com/relaymsg": nil, "draft/relaymsg": nil},
}) })
return i, nil return i, nil
} }
@@ -277,7 +332,7 @@ func (b *Birc) skipPrivMsg(event girc.Event) bool {
b.Nick = b.i.GetNick() b.Nick = b.i.GetNick()
// freenode doesn't send 001 as first reply // freenode doesn't send 001 as first reply
if event.Command == "NOTICE" { if event.Command == "NOTICE" && len(event.Params) != 2 {
return true return true
} }
// don't forward queries to the bot // don't forward queries to the bot
@@ -288,6 +343,15 @@ func (b *Birc) skipPrivMsg(event girc.Event) bool {
if event.Source.Name == b.Nick { if event.Source.Name == b.Nick {
return true return true
} }
// don't forward messages we sent via RELAYMSG
if relayedNick, ok := event.Tags.Get("draft/relaymsg"); ok && relayedNick == b.Nick {
return true
}
// This is the old name of the cap sent in spoofed messages; I've kept this in
// for compatibility reasons
if relayedNick, ok := event.Tags.Get("relaymsg"); ok && relayedNick == b.Nick {
return true
}
return false return false
} }
+215
View File
@@ -0,0 +1,215 @@
package bmatrix
import (
"encoding/json"
"errors"
"fmt"
"html"
"strings"
"time"
matrix "github.com/matrix-org/gomatrix"
)
func newMatrixUsername(username string) *matrixUsername {
mUsername := new(matrixUsername)
// check if we have a </tag>. if we have, we don't escape HTML. #696
if htmlTag.MatchString(username) {
mUsername.formatted = username
// remove the HTML formatting for beautiful push messages #1188
mUsername.plain = htmlReplacementTag.ReplaceAllString(username, "")
} else {
mUsername.formatted = html.EscapeString(username)
mUsername.plain = username
}
return mUsername
}
// getRoomID retrieves a matching room ID from the channel name.
func (b *Bmatrix) getRoomID(channel string) string {
b.RLock()
defer b.RUnlock()
for ID, name := range b.RoomMap {
if name == channel {
return ID
}
}
return ""
}
// interface2Struct marshals and immediately unmarshals an interface.
// Useful for converting map[string]interface{} to a struct.
func interface2Struct(in interface{}, out interface{}) error {
jsonObj, err := json.Marshal(in)
if err != nil {
return err //nolint:wrapcheck
}
return json.Unmarshal(jsonObj, out)
}
// getDisplayName retrieves the displayName for mxid, querying the homserver if the mxid is not in the cache.
func (b *Bmatrix) getDisplayName(mxid string) string {
if b.GetBool("UseUserName") {
return mxid[1:]
}
b.RLock()
if val, present := b.NicknameMap[mxid]; present {
b.RUnlock()
return val.displayName
}
b.RUnlock()
displayName, err := b.mc.GetDisplayName(mxid)
var httpError *matrix.HTTPError
if errors.As(err, &httpError) {
b.Log.Warnf("Couldn't retrieve the display name for %s", mxid)
}
if err != nil {
return b.cacheDisplayName(mxid, mxid[1:])
}
return b.cacheDisplayName(mxid, displayName.DisplayName)
}
// cacheDisplayName stores the mapping between a mxid and a display name, to be reused later without performing a query to the homserver.
// Note that old entries are cleaned when this function is called.
func (b *Bmatrix) cacheDisplayName(mxid string, displayName string) string {
now := time.Now()
// scan to delete old entries, to stop memory usage from becoming too high with old entries.
// In addition, we also detect if another user have the same username, and if so, we append their mxids to their usernames to differentiate them.
toDelete := []string{}
conflict := false
b.Lock()
for mxid, v := range b.NicknameMap {
// to prevent username reuse across matrix servers - or even on the same server, append
// the mxid to the username when there is a conflict
if v.displayName == displayName {
conflict = true
// TODO: it would be nice to be able to rename previous messages from this user.
// The current behavior is that only users with clashing usernames and *that have spoken since the bridge last started* will get their mxids shown, and I don't know if that's the expected behavior.
v.displayName = fmt.Sprintf("%s (%s)", displayName, mxid)
b.NicknameMap[mxid] = v
}
if now.Sub(v.lastUpdated) > 10*time.Minute {
toDelete = append(toDelete, mxid)
}
}
if conflict {
displayName = fmt.Sprintf("%s (%s)", displayName, mxid)
}
for _, v := range toDelete {
delete(b.NicknameMap, v)
}
b.NicknameMap[mxid] = NicknameCacheEntry{
displayName: displayName,
lastUpdated: now,
}
b.Unlock()
return displayName
}
// handleError converts errors into httpError.
//nolint:exhaustivestruct
func handleError(err error) *httpError {
var mErr matrix.HTTPError
if !errors.As(err, &mErr) {
return &httpError{
Err: "not a HTTPError",
}
}
var httpErr httpError
if err := json.Unmarshal(mErr.Contents, &httpErr); err != nil {
return &httpError{
Err: "unmarshal failed",
}
}
return &httpErr
}
func (b *Bmatrix) containsAttachment(content map[string]interface{}) bool {
// Skip empty messages
if content["msgtype"] == nil {
return false
}
// Only allow image,video or file msgtypes
if !(content["msgtype"].(string) == "m.image" ||
content["msgtype"].(string) == "m.video" ||
content["msgtype"].(string) == "m.file") {
return false
}
return true
}
// getAvatarURL returns the avatar URL of the specified sender.
func (b *Bmatrix) getAvatarURL(sender string) string {
urlPath := b.mc.BuildURL("profile", sender, "avatar_url")
s := struct {
AvatarURL string `json:"avatar_url"`
}{}
err := b.mc.MakeRequest("GET", urlPath, nil, &s)
if err != nil {
b.Log.Errorf("getAvatarURL failed: %s", err)
return ""
}
url := strings.ReplaceAll(s.AvatarURL, "mxc://", b.GetString("Server")+"/_matrix/media/r0/thumbnail/")
if url != "" {
url += "?width=37&height=37&method=crop"
}
return url
}
// handleRatelimit handles the ratelimit errors and return if we're ratelimited and the amount of time to sleep
func (b *Bmatrix) handleRatelimit(err error) (time.Duration, bool) {
httpErr := handleError(err)
if httpErr.Errcode != "M_LIMIT_EXCEEDED" {
return 0, false
}
b.Log.Debugf("ratelimited: %s", httpErr.Err)
b.Log.Infof("getting ratelimited by matrix, sleeping approx %d seconds before retrying", httpErr.RetryAfterMs/1000)
return time.Duration(httpErr.RetryAfterMs) * time.Millisecond, true
}
// retry function will check if we're ratelimited and retries again when backoff time expired
// returns original error if not 429 ratelimit
func (b *Bmatrix) retry(f func() error) error {
b.rateMutex.Lock()
defer b.rateMutex.Unlock()
for {
if err := f(); err != nil {
if backoff, ok := b.handleRatelimit(err); ok {
time.Sleep(backoff)
} else {
return err
}
} else {
return nil
}
}
}
+266 -84
View File
@@ -3,31 +3,72 @@ package bmatrix
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"html"
"mime" "mime"
"regexp" "regexp"
"strings" "strings"
"sync" "sync"
"time"
"github.com/42wim/matterbridge/bridge" "github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper" "github.com/42wim/matterbridge/bridge/helper"
matrix "github.com/matterbridge/gomatrix" matrix "github.com/matrix-org/gomatrix"
) )
var (
htmlTag = regexp.MustCompile("</.*?>")
htmlReplacementTag = regexp.MustCompile("<[^>]*>")
)
type NicknameCacheEntry struct {
displayName string
lastUpdated time.Time
}
type Bmatrix struct { type Bmatrix struct {
mc *matrix.Client mc *matrix.Client
UserID string UserID string
NicknameMap map[string]NicknameCacheEntry
RoomMap map[string]string RoomMap map[string]string
rateMutex sync.RWMutex
sync.RWMutex sync.RWMutex
htmlTag *regexp.Regexp
*bridge.Config *bridge.Config
} }
type httpError struct {
Errcode string `json:"errcode"`
Err string `json:"error"`
RetryAfterMs int `json:"retry_after_ms"`
}
type matrixUsername struct {
plain string
formatted string
}
// SubTextMessage represents the new content of the message in edit messages.
type SubTextMessage struct {
MsgType string `json:"msgtype"`
Body string `json:"body"`
}
// MessageRelation explains how the current message relates to a previous message.
// Notably used for message edits.
type MessageRelation struct {
EventID string `json:"event_id"`
Type string `json:"rel_type"`
}
type EditedMessage struct {
NewContent SubTextMessage `json:"m.new_content"`
RelatedTo MessageRelation `json:"m.relates_to"`
matrix.TextMessage
}
func New(cfg *bridge.Config) bridge.Bridger { func New(cfg *bridge.Config) bridge.Bridger {
b := &Bmatrix{Config: cfg} b := &Bmatrix{Config: cfg}
b.htmlTag = regexp.MustCompile("</.*?>")
b.RoomMap = make(map[string]string) b.RoomMap = make(map[string]string)
b.NicknameMap = make(map[string]NicknameCacheEntry)
return b return b
} }
@@ -42,6 +83,7 @@ func (b *Bmatrix) Connect() error {
Type: "m.login.password", Type: "m.login.password",
User: b.GetString("Login"), User: b.GetString("Login"),
Password: b.GetString("Password"), Password: b.GetString("Password"),
Identifier: matrix.NewUserIdentifier(b.GetString("Login")),
}) })
if err != nil { if err != nil {
return err return err
@@ -58,14 +100,18 @@ func (b *Bmatrix) Disconnect() error {
} }
func (b *Bmatrix) JoinChannel(channel config.ChannelInfo) error { func (b *Bmatrix) JoinChannel(channel config.ChannelInfo) error {
return b.retry(func() error {
resp, err := b.mc.JoinRoom(channel.Name, "", nil) resp, err := b.mc.JoinRoom(channel.Name, "", nil)
if err != nil { if err != nil {
return err return err
} }
b.Lock() b.Lock()
b.RoomMap[resp.RoomID] = channel.Name b.RoomMap[resp.RoomID] = channel.Name
b.Unlock() b.Unlock()
return err
return nil
})
} }
func (b *Bmatrix) Send(msg config.Message) (string, error) { func (b *Bmatrix) Send(msg config.Message) (string, error) {
@@ -74,17 +120,30 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) {
channel := b.getRoomID(msg.Channel) channel := b.getRoomID(msg.Channel)
b.Log.Debugf("Channel %s maps to channel id %s", msg.Channel, channel) b.Log.Debugf("Channel %s maps to channel id %s", msg.Channel, channel)
username := newMatrixUsername(msg.Username)
// Make a action /me of the message // Make a action /me of the message
if msg.Event == config.EventUserAction { if msg.Event == config.EventUserAction {
m := matrix.TextMessage{ m := matrix.TextMessage{
MsgType: "m.emote", MsgType: "m.emote",
Body: msg.Username + msg.Text, Body: username.plain + msg.Text,
FormattedBody: username.formatted + msg.Text,
} }
msgID := ""
err := b.retry(func() error {
resp, err := b.mc.SendMessageEvent(channel, "m.room.message", m) resp, err := b.mc.SendMessageEvent(channel, "m.room.message", m)
if err != nil { if err != nil {
return "", err return err
} }
return resp.EventID, err
msgID = resp.EventID
return err
})
return msgID, err
} }
// Delete message // Delete message
@@ -92,17 +151,34 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) {
if msg.ID == "" { if msg.ID == "" {
return "", nil return "", nil
} }
msgID := ""
err := b.retry(func() error {
resp, err := b.mc.RedactEvent(channel, msg.ID, &matrix.ReqRedact{}) resp, err := b.mc.RedactEvent(channel, msg.ID, &matrix.ReqRedact{})
if err != nil { if err != nil {
return "", err return err
} }
return resp.EventID, err
msgID = resp.EventID
return err
})
return msgID, err
} }
// Upload a file if it exists // Upload a file if it exists
if msg.Extra != nil { if msg.Extra != nil {
for _, rmsg := range helper.HandleExtra(&msg, b.General) { for _, rmsg := range helper.HandleExtra(&msg, b.General) {
if _, err := b.mc.SendText(channel, rmsg.Username+rmsg.Text); err != nil { rmsg := rmsg
err := b.retry(func() error {
_, err := b.mc.SendText(channel, rmsg.Username+rmsg.Text)
return err
})
if err != nil {
b.Log.Errorf("sendText failed: %s", err) b.Log.Errorf("sendText failed: %s", err)
} }
} }
@@ -113,53 +189,105 @@ func (b *Bmatrix) Send(msg config.Message) (string, error) {
} }
// Edit message if we have an ID // Edit message if we have an ID
// matrix has no editing support if msg.ID != "" {
rmsg := EditedMessage{TextMessage: matrix.TextMessage{
Body: username.plain + msg.Text,
MsgType: "m.text",
}}
if b.GetBool("HTMLDisable") {
rmsg.TextMessage.FormattedBody = username.formatted + "* " + msg.Text
} else {
rmsg.Format = "org.matrix.custom.html"
rmsg.TextMessage.FormattedBody = username.formatted + "* " + helper.ParseMarkdown(msg.Text)
}
rmsg.NewContent = SubTextMessage{
Body: rmsg.TextMessage.Body,
MsgType: "m.text",
}
rmsg.RelatedTo = MessageRelation{
EventID: msg.ID,
Type: "m.replace",
}
// Use notices to send join/leave events err := b.retry(func() error {
if msg.Event == config.EventJoinLeave { _, err := b.mc.SendMessageEvent(channel, "m.room.message", rmsg)
resp, err := b.mc.SendNotice(channel, msg.Username+msg.Text)
return err
})
if err != nil { if err != nil {
return "", err return "", err
} }
return msg.ID, nil
}
// Use notices to send join/leave events
if msg.Event == config.EventJoinLeave {
m := matrix.TextMessage{
MsgType: "m.notice",
Body: username.plain + msg.Text,
FormattedBody: username.formatted + msg.Text,
}
var (
resp *matrix.RespSendEvent
err error
)
err = b.retry(func() error {
resp, err = b.mc.SendMessageEvent(channel, "m.room.message", m)
return err
})
if err != nil {
return "", err
}
return resp.EventID, err return resp.EventID, err
} }
if b.GetBool("HTMLDisable") { if b.GetBool("HTMLDisable") {
resp, err := b.mc.SendText(channel, msg.Username+msg.Text) var (
resp *matrix.RespSendEvent
err error
)
err = b.retry(func() error {
resp, err = b.mc.SendText(channel, username.plain+msg.Text)
return err
})
if err != nil { if err != nil {
return "", err return "", err
} }
return resp.EventID, err return resp.EventID, err
} }
username := html.EscapeString(msg.Username)
// check if we have a </tag>. if we have, we don't escape HTML. #696
if b.htmlTag.MatchString(msg.Username) {
username = msg.Username
}
// Post normal message with HTML support (eg riot.im) // Post normal message with HTML support (eg riot.im)
resp, err := b.mc.SendHTML(channel, msg.Username+msg.Text, username+helper.ParseMarkdown(msg.Text)) var (
resp *matrix.RespSendEvent
err error
)
err = b.retry(func() error {
resp, err = b.mc.SendFormattedText(channel, username.plain+msg.Text,
username.formatted+helper.ParseMarkdown(msg.Text))
return err
})
if err != nil { if err != nil {
return "", err return "", err
} }
return resp.EventID, err
}
func (b *Bmatrix) getRoomID(channel string) string { return resp.EventID, err
b.RLock()
defer b.RUnlock()
for ID, name := range b.RoomMap {
if name == channel {
return ID
}
}
return ""
} }
func (b *Bmatrix) handlematrix() { func (b *Bmatrix) handlematrix() {
syncer := b.mc.Syncer.(*matrix.DefaultSyncer) syncer := b.mc.Syncer.(*matrix.DefaultSyncer)
syncer.OnEventType("m.room.redaction", b.handleEvent) syncer.OnEventType("m.room.redaction", b.handleEvent)
syncer.OnEventType("m.room.message", b.handleEvent) syncer.OnEventType("m.room.message", b.handleEvent)
syncer.OnEventType("m.room.member", b.handleMemberChange)
go func() { go func() {
for { for {
if err := b.mc.Sync(); err != nil { if err := b.mc.Sync(); err != nil {
@@ -169,6 +297,45 @@ func (b *Bmatrix) handlematrix() {
}() }()
} }
func (b *Bmatrix) handleEdit(ev *matrix.Event, rmsg config.Message) bool {
relationInterface, present := ev.Content["m.relates_to"]
newContentInterface, present2 := ev.Content["m.new_content"]
if !(present && present2) {
return false
}
var relation MessageRelation
if err := interface2Struct(relationInterface, &relation); err != nil {
b.Log.Warnf("Couldn't parse 'm.relates_to' object with value %#v", relationInterface)
return false
}
var newContent SubTextMessage
if err := interface2Struct(newContentInterface, &newContent); err != nil {
b.Log.Warnf("Couldn't parse 'm.new_content' object with value %#v", newContentInterface)
return false
}
if relation.Type != "m.replace" {
return false
}
rmsg.ID = relation.EventID
rmsg.Text = newContent.Body
b.Remote <- rmsg
return true
}
func (b *Bmatrix) handleMemberChange(ev *matrix.Event) {
// Update the displayname on join messages, according to https://matrix.org/docs/spec/client_server/r0.6.1#events-on-change-of-profile-information
if ev.Content["membership"] == "join" {
if dn, ok := ev.Content["displayname"].(string); ok {
b.cacheDisplayName(ev.Sender, dn)
}
}
}
func (b *Bmatrix) handleEvent(ev *matrix.Event) { func (b *Bmatrix) handleEvent(ev *matrix.Event) {
b.Log.Debugf("== Receiving event: %#v", ev) b.Log.Debugf("== Receiving event: %#v", ev)
if ev.Sender != b.UserID { if ev.Sender != b.UserID {
@@ -182,7 +349,7 @@ func (b *Bmatrix) handleEvent(ev *matrix.Event) {
// Create our message // Create our message
rmsg := config.Message{ rmsg := config.Message{
Username: ev.Sender[1:], Username: b.getDisplayName(ev.Sender),
Channel: channel, Channel: channel,
Account: b.Account, Account: b.Account,
UserID: ev.Sender, UserID: ev.Sender,
@@ -217,6 +384,11 @@ func (b *Bmatrix) handleEvent(ev *matrix.Event) {
rmsg.Event = config.EventUserAction rmsg.Event = config.EventUserAction
} }
// Is it an edit?
if b.handleEdit(ev, rmsg) {
return
}
// Do we have attachments // Do we have attachments
if b.containsAttachment(ev.Content) { if b.containsAttachment(ev.Content) {
err := b.handleDownloadFile(&rmsg, ev.Content) err := b.handleDownloadFile(&rmsg, ev.Content)
@@ -227,6 +399,11 @@ func (b *Bmatrix) handleEvent(ev *matrix.Event) {
b.Log.Debugf("<= Sending message from %s on %s to gateway", ev.Sender, b.Account) b.Log.Debugf("<= Sending message from %s on %s to gateway", ev.Sender, b.Account)
b.Remote <- rmsg b.Remote <- rmsg
// not crucial, so no ratelimit check here
if err := b.mc.MarkRead(ev.RoomID, ev.ID); err != nil {
b.Log.Errorf("couldn't mark message as read %s", err.Error())
}
} }
} }
@@ -301,27 +478,30 @@ func (b *Bmatrix) handleUploadFiles(msg *config.Message, channel string) (string
// handleUploadFile handles native upload of a file. // handleUploadFile handles native upload of a file.
func (b *Bmatrix) handleUploadFile(msg *config.Message, channel string, fi *config.FileInfo) { func (b *Bmatrix) handleUploadFile(msg *config.Message, channel string, fi *config.FileInfo) {
username := newMatrixUsername(msg.Username)
content := bytes.NewReader(*fi.Data) content := bytes.NewReader(*fi.Data)
sp := strings.Split(fi.Name, ".") sp := strings.Split(fi.Name, ".")
mtype := mime.TypeByExtension("." + sp[len(sp)-1]) mtype := mime.TypeByExtension("." + sp[len(sp)-1])
if !(strings.Contains(mtype, "image") || strings.Contains(mtype, "video") ||
strings.Contains(mtype, "application") || strings.Contains(mtype, "audio")) {
return
}
if fi.Comment != "" {
_, err := b.mc.SendText(channel, msg.Username+fi.Comment)
if err != nil {
b.Log.Errorf("file comment failed: %#v", err)
}
} else {
// image and video uploads send no username, we have to do this ourself here #715 // image and video uploads send no username, we have to do this ourself here #715
_, err := b.mc.SendText(channel, msg.Username) err := b.retry(func() error {
_, err := b.mc.SendFormattedText(channel, username.plain+fi.Comment, username.formatted+fi.Comment)
return err
})
if err != nil { if err != nil {
b.Log.Errorf("file comment failed: %#v", err) b.Log.Errorf("file comment failed: %#v", err)
} }
}
b.Log.Debugf("uploading file: %s %s", fi.Name, mtype) b.Log.Debugf("uploading file: %s %s", fi.Name, mtype)
res, err := b.mc.UploadToContentRepo(content, mtype, int64(len(*fi.Data)))
var res *matrix.RespMediaUpload
err = b.retry(func() error {
res, err = b.mc.UploadToContentRepo(content, mtype, int64(len(*fi.Data)))
return err
})
if err != nil { if err != nil {
b.Log.Errorf("file upload failed: %#v", err) b.Log.Errorf("file upload failed: %#v", err)
return return
@@ -330,58 +510,60 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, channel string, fi *conf
switch { switch {
case strings.Contains(mtype, "video"): case strings.Contains(mtype, "video"):
b.Log.Debugf("sendVideo %s", res.ContentURI) b.Log.Debugf("sendVideo %s", res.ContentURI)
err = b.retry(func() error {
_, err = b.mc.SendVideo(channel, fi.Name, res.ContentURI) _, err = b.mc.SendVideo(channel, fi.Name, res.ContentURI)
return err
})
if err != nil { if err != nil {
b.Log.Errorf("sendVideo failed: %#v", err) b.Log.Errorf("sendVideo failed: %#v", err)
} }
case strings.Contains(mtype, "image"): case strings.Contains(mtype, "image"):
b.Log.Debugf("sendImage %s", res.ContentURI) b.Log.Debugf("sendImage %s", res.ContentURI)
err = b.retry(func() error {
_, err = b.mc.SendImage(channel, fi.Name, res.ContentURI) _, err = b.mc.SendImage(channel, fi.Name, res.ContentURI)
return err
})
if err != nil { if err != nil {
b.Log.Errorf("sendImage failed: %#v", err) b.Log.Errorf("sendImage failed: %#v", err)
} }
case strings.Contains(mtype, "application"):
b.Log.Debugf("sendFile %s", res.ContentURI)
_, err = b.mc.SendFile(channel, fi.Name, res.ContentURI, mtype, uint(len(*fi.Data)))
if err != nil {
b.Log.Errorf("sendFile failed: %#v", err)
}
case strings.Contains(mtype, "audio"): case strings.Contains(mtype, "audio"):
b.Log.Debugf("sendAudio %s", res.ContentURI) b.Log.Debugf("sendAudio %s", res.ContentURI)
_, err = b.mc.SendAudio(channel, fi.Name, res.ContentURI, mtype, uint(len(*fi.Data))) err = b.retry(func() error {
_, err = b.mc.SendMessageEvent(channel, "m.room.message", matrix.AudioMessage{
MsgType: "m.audio",
Body: fi.Name,
URL: res.ContentURI,
Info: matrix.AudioInfo{
Mimetype: mtype,
Size: uint(len(*fi.Data)),
},
})
return err
})
if err != nil { if err != nil {
b.Log.Errorf("sendAudio failed: %#v", err) b.Log.Errorf("sendAudio failed: %#v", err)
} }
default:
b.Log.Debugf("sendFile %s", res.ContentURI)
err = b.retry(func() error {
_, err = b.mc.SendMessageEvent(channel, "m.room.message", matrix.FileMessage{
MsgType: "m.file",
Body: fi.Name,
URL: res.ContentURI,
Info: matrix.FileInfo{
Mimetype: mtype,
Size: uint(len(*fi.Data)),
},
})
return err
})
if err != nil {
b.Log.Errorf("sendFile failed: %#v", err)
}
} }
b.Log.Debugf("result: %#v", res) b.Log.Debugf("result: %#v", res)
} }
// skipMessages returns true if this message should not be handled
func (b *Bmatrix) containsAttachment(content map[string]interface{}) bool {
// Skip empty messages
if content["msgtype"] == nil {
return false
}
// Only allow image,video or file msgtypes
if !(content["msgtype"].(string) == "m.image" ||
content["msgtype"].(string) == "m.video" ||
content["msgtype"].(string) == "m.file") {
return false
}
return true
}
// getAvatarURL returns the avatar URL of the specified sender
func (b *Bmatrix) getAvatarURL(sender string) string {
mxcURL, err := b.mc.GetSenderAvatarURL(sender)
if err != nil {
b.Log.Errorf("getAvatarURL failed: %s", err)
return ""
}
url := strings.ReplaceAll(mxcURL, "mxc://", b.GetString("Server")+"/_matrix/media/r0/thumbnail/")
if url != "" {
url += "?width=37&height=37&method=crop"
}
return url
}
+28
View File
@@ -0,0 +1,28 @@
package bmatrix
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPlainUsername(t *testing.T) {
uut := newMatrixUsername("MyUser")
assert.Equal(t, "MyUser", uut.formatted)
assert.Equal(t, "MyUser", uut.plain)
}
func TestHTMLUsername(t *testing.T) {
uut := newMatrixUsername("<b>MyUser</b>")
assert.Equal(t, "<b>MyUser</b>", uut.formatted)
assert.Equal(t, "MyUser", uut.plain)
}
func TestFancyUsername(t *testing.T) {
uut := newMatrixUsername("<MyUser>")
assert.Equal(t, "&lt;MyUser&gt;", uut.formatted)
assert.Equal(t, "<MyUser>", uut.plain)
}
+2 -2
View File
@@ -4,7 +4,7 @@ import (
"github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper" "github.com/42wim/matterbridge/bridge/helper"
"github.com/42wim/matterbridge/matterclient" "github.com/42wim/matterbridge/matterclient"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/v5/model"
) )
// handleDownloadAvatar downloads the avatar of userid from channel // handleDownloadAvatar downloads the avatar of userid from channel
@@ -108,7 +108,7 @@ func (b *Bmattermost) handleMatterClient(messages chan *config.Message) {
Channel: message.Channel, Channel: message.Channel,
Text: message.Text, Text: message.Text,
ID: message.Post.Id, ID: message.Post.Id,
ParentID: message.Post.ParentId, ParentID: message.Post.RootId, // ParentID is obsolete with mattermost
Extra: make(map[string][]interface{}), Extra: make(map[string][]interface{}),
} }
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"github.com/42wim/matterbridge/bridge/helper" "github.com/42wim/matterbridge/bridge/helper"
"github.com/42wim/matterbridge/matterclient" "github.com/42wim/matterbridge/matterclient"
"github.com/42wim/matterbridge/matterhook" "github.com/42wim/matterbridge/matterhook"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/v5/model"
) )
func (b *Bmattermost) doConnectWebhookBind() error { func (b *Bmattermost) doConnectWebhookBind() error {
+10 -1
View File
@@ -122,11 +122,20 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) {
} }
// Handle prefix hint for unthreaded messages. // Handle prefix hint for unthreaded messages.
if msg.ParentID == "msg-parent-not-found" { if msg.ParentNotFound() {
msg.ParentID = "" msg.ParentID = ""
msg.Text = fmt.Sprintf("[thread]: %s", msg.Text) msg.Text = fmt.Sprintf("[thread]: %s", msg.Text)
} }
// we only can reply to the root of the thread, not to a specific ID (like discord for example does)
if msg.ParentID != "" {
post, res := b.mc.Client.GetPost(msg.ParentID, "")
if res.Error != nil {
b.Log.Errorf("getting post %s failed: %s", msg.ParentID, res.Error.DetailedError)
}
msg.ParentID = post.RootId
}
// Upload a file if it exists // Upload a file if it exists
if msg.Extra != nil { if msg.Extra != nil {
for _, rmsg := range helper.HandleExtra(&msg, b.General) { for _, rmsg := range helper.HandleExtra(&msg, b.General) {
+5 -2
View File
@@ -86,13 +86,16 @@ func (b *Bmsteams) JoinChannel(channel config.ChannelInfo) error {
func (b *Bmsteams) Send(msg config.Message) (string, error) { func (b *Bmsteams) Send(msg config.Message) (string, error) {
b.Log.Debugf("=> Receiving %#v", msg) b.Log.Debugf("=> Receiving %#v", msg)
if msg.ParentID != "" && msg.ParentID != "msg-parent-not-found" { if msg.ParentValid() {
return b.sendReply(msg) return b.sendReply(msg)
} }
if msg.ParentID == "msg-parent-not-found" {
// Handle prefix hint for unthreaded messages.
if msg.ParentNotFound() {
msg.ParentID = "" msg.ParentID = ""
msg.Text = fmt.Sprintf("[thread]: %s", msg.Text) msg.Text = fmt.Sprintf("[thread]: %s", msg.Text)
} }
ct := b.gc.Teams().ID(b.GetString("TeamID")).Channels().ID(msg.Channel).Messages().Request() ct := b.gc.Teams().ID(b.GetString("TeamID")).Channels().ID(msg.Channel).Messages().Request()
text := msg.Username + msg.Text text := msg.Username + msg.Text
content := &msgraph.ItemBody{Content: &text} content := &msgraph.ItemBody{Content: &text}
+96
View File
@@ -0,0 +1,96 @@
package bmumble
import (
"strconv"
"time"
"layeh.com/gumble/gumble"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
)
func (b *Bmumble) handleServerConfig(event *gumble.ServerConfigEvent) {
b.serverConfigUpdate <- *event
}
func (b *Bmumble) handleTextMessage(event *gumble.TextMessageEvent) {
sender := "unknown"
if event.TextMessage.Sender != nil {
sender = event.TextMessage.Sender.Name
}
// If the text message is received before receiving a ServerSync
// and UserState, Client.Self or Self.Channel are nil
if event.Client.Self == nil || event.Client.Self.Channel == nil {
b.Log.Warn("Connection bootstrap not finished, discarding text message")
return
}
// Convert Mumble HTML messages to markdown
parts, err := b.convertHTMLtoMarkdown(event.TextMessage.Message)
if err != nil {
b.Log.Error(err)
}
now := time.Now().UTC()
for i, part := range parts {
// Construct matterbridge message and pass on to the gateway
rmsg := config.Message{
Channel: strconv.FormatUint(uint64(event.Client.Self.Channel.ID), 10),
Username: sender,
UserID: sender + "@" + b.Host,
Account: b.Account,
}
if part.Image == nil {
rmsg.Text = part.Text
} else {
fname := b.Account + "_" + strconv.FormatInt(now.UnixNano(), 10) + "_" + strconv.Itoa(i) + part.FileExtension
rmsg.Extra = make(map[string][]interface{})
if err = helper.HandleDownloadSize(b.Log, &rmsg, fname, int64(len(part.Image)), b.General); err != nil {
b.Log.WithError(err).Warn("not including image in message")
continue
}
helper.HandleDownloadData(b.Log, &rmsg, fname, "", "", &part.Image, b.General)
}
b.Log.Debugf("Sending message to gateway: %+v", rmsg)
b.Remote <- rmsg
}
}
func (b *Bmumble) handleConnect(event *gumble.ConnectEvent) {
// Set the user's "bio"/comment
if comment := b.GetString("UserComment"); comment != "" && event.Client.Self != nil {
event.Client.Self.SetComment(comment)
}
// No need to talk or listen
event.Client.Self.SetSelfDeafened(true)
event.Client.Self.SetSelfMuted(true)
// if the Channel variable is set, this is a reconnect -> rejoin channel
if b.Channel != nil {
if err := b.doJoin(event.Client, *b.Channel); err != nil {
b.Log.Error(err)
}
b.Remote <- config.Message{
Username: "system",
Text: "rejoin",
Channel: "",
Account: b.Account,
Event: config.EventRejoinChannels,
}
}
}
func (b *Bmumble) handleUserChange(event *gumble.UserChangeEvent) {
// Only care about changes to self
if event.User != event.Client.Self {
return
}
// Someone attempted to move the user out of the configured channel; attempt to join back
if b.Channel != nil {
if err := b.doJoin(event.Client, *b.Channel); err != nil {
b.Log.Error(err)
}
}
}
func (b *Bmumble) handleDisconnect(event *gumble.DisconnectEvent) {
b.connected <- *event
}
+143
View File
@@ -0,0 +1,143 @@
package bmumble
import (
"fmt"
"mime"
"net/http"
"regexp"
"strings"
"github.com/42wim/matterbridge/bridge/config"
"github.com/mattn/godown"
"github.com/vincent-petithory/dataurl"
)
type MessagePart struct {
Text string
FileExtension string
Image []byte
}
func (b *Bmumble) decodeImage(uri string, parts *[]MessagePart) error {
// Decode the data:image/... URI
image, err := dataurl.DecodeString(uri)
if err != nil {
b.Log.WithError(err).Info("No image extracted")
return err
}
// Determine the file extensions for that image
ext, err := mime.ExtensionsByType(image.MediaType.ContentType())
if err != nil || len(ext) == 0 {
b.Log.WithError(err).Infof("No file extension registered for MIME type '%s'", image.MediaType.ContentType())
return err
}
// Add the image to the MessagePart slice
*parts = append(*parts, MessagePart{"", ext[0], image.Data})
return nil
}
func (b *Bmumble) tokenize(t *string) ([]MessagePart, error) {
// `^(.*?)` matches everything before the image
// `!\[[^\]]*\]\(` matches the `![alt](` part of markdown images
// `(data:image\/[^)]+)` matches the data: URI used by Mumble
// `\)` matches the closing parenthesis after the URI
// `(.*)$` matches the remaining text to be examined in the next iteration
p := regexp.MustCompile(`^(?ms)(.*?)!\[[^\]]*\]\((data:image\/[^)]+)\)(.*)$`)
remaining := *t
var parts []MessagePart
for {
tokens := p.FindStringSubmatch(remaining)
if tokens == nil {
// no match -> remaining string is non-image text
pre := strings.TrimSpace(remaining)
if len(pre) > 0 {
parts = append(parts, MessagePart{pre, "", nil})
}
return parts, nil
}
// tokens[1] is the text before the image
if len(tokens[1]) > 0 {
pre := strings.TrimSpace(tokens[1])
parts = append(parts, MessagePart{pre, "", nil})
}
// tokens[2] is the image URL
uri, err := dataurl.UnescapeToString(strings.TrimSpace(strings.ReplaceAll(tokens[2], " ", "")))
if err != nil {
b.Log.WithError(err).Info("URL unescaping failed")
remaining = strings.TrimSpace(tokens[3])
continue
}
err = b.decodeImage(uri, &parts)
if err != nil {
b.Log.WithError(err).Info("Decoding the image failed")
}
// tokens[3] is the text after the image, processed in the next iteration
remaining = strings.TrimSpace(tokens[3])
}
}
func (b *Bmumble) convertHTMLtoMarkdown(html string) ([]MessagePart, error) {
var sb strings.Builder
err := godown.Convert(&sb, strings.NewReader(html), nil)
if err != nil {
return nil, err
}
markdown := sb.String()
b.Log.Debugf("### to markdown: %s", markdown)
return b.tokenize(&markdown)
}
func (b *Bmumble) extractFiles(msg *config.Message) []config.Message {
var messages []config.Message
if msg.Extra == nil || len(msg.Extra["file"]) == 0 {
return messages
}
// Create a separate message for each file
for _, f := range msg.Extra["file"] {
fi := f.(config.FileInfo)
imsg := config.Message{
Channel: msg.Channel,
Username: msg.Username,
UserID: msg.UserID,
Account: msg.Account,
Protocol: msg.Protocol,
Timestamp: msg.Timestamp,
Event: "mumble_image",
}
// If no data is present for the file, send a link instead
if fi.Data == nil || len(*fi.Data) == 0 {
if len(fi.URL) > 0 {
imsg.Text = fmt.Sprintf(`<a href="%s">%s</a>`, fi.URL, fi.URL)
messages = append(messages, imsg)
} else {
b.Log.Infof("Not forwarding file without local data")
}
continue
}
mimeType := http.DetectContentType(*fi.Data)
// Mumble only supports images natively, send a link instead
if !strings.HasPrefix(mimeType, "image/") {
if len(fi.URL) > 0 {
imsg.Text = fmt.Sprintf(`<a href="%s">%s</a>`, fi.URL, fi.URL)
messages = append(messages, imsg)
} else {
b.Log.Infof("Not forwarding file of type %s", mimeType)
}
continue
}
mimeType = strings.TrimSpace(strings.Split(mimeType, ";")[0])
// Build data:image/...;base64,... style image URL and embed image directly into the message
du := dataurl.New(*fi.Data, mimeType)
dataURL, err := du.MarshalText()
if err != nil {
b.Log.WithError(err).Infof("Image Serialization into data URL failed (type: %s, length: %d)", mimeType, len(*fi.Data))
continue
}
imsg.Text = fmt.Sprintf(`<img src="%s"/>`, dataURL)
messages = append(messages, imsg)
}
// Remove files from original message
msg.Extra["file"] = nil
return messages
}
+259
View File
@@ -0,0 +1,259 @@
package bmumble
import (
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"io/ioutil"
"net"
"strconv"
"time"
"layeh.com/gumble/gumble"
"layeh.com/gumble/gumbleutil"
"github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config"
"github.com/42wim/matterbridge/bridge/helper"
stripmd "github.com/writeas/go-strip-markdown"
// We need to import the 'data' package as an implicit dependency.
// See: https://godoc.org/github.com/paulrosania/go-charset/charset
_ "github.com/paulrosania/go-charset/data"
)
type Bmumble struct {
client *gumble.Client
Nick string
Host string
Channel *uint32
local chan config.Message
running chan error
connected chan gumble.DisconnectEvent
serverConfigUpdate chan gumble.ServerConfigEvent
serverConfig gumble.ServerConfigEvent
tlsConfig tls.Config
*bridge.Config
}
func New(cfg *bridge.Config) bridge.Bridger {
b := &Bmumble{}
b.Config = cfg
b.Nick = b.GetString("Nick")
b.local = make(chan config.Message)
b.running = make(chan error)
b.connected = make(chan gumble.DisconnectEvent)
b.serverConfigUpdate = make(chan gumble.ServerConfigEvent)
return b
}
func (b *Bmumble) Connect() error {
b.Log.Infof("Connecting %s", b.GetString("Server"))
host, portstr, err := net.SplitHostPort(b.GetString("Server"))
if err != nil {
return err
}
b.Host = host
_, err = strconv.Atoi(portstr)
if err != nil {
return err
}
if err = b.buildTLSConfig(); err != nil {
return err
}
go b.doSend()
go b.connectLoop()
err = <-b.running
return err
}
func (b *Bmumble) Disconnect() error {
return b.client.Disconnect()
}
func (b *Bmumble) JoinChannel(channel config.ChannelInfo) error {
cid, err := strconv.ParseUint(channel.Name, 10, 32)
if err != nil {
return err
}
channelID := uint32(cid)
if b.Channel != nil && *b.Channel != channelID {
b.Log.Fatalf("Cannot join channel ID '%d', already joined to channel ID %d", channelID, *b.Channel)
return errors.New("the Mumble bridge can only join a single channel")
}
b.Channel = &channelID
return b.doJoin(b.client, channelID)
}
func (b *Bmumble) Send(msg config.Message) (string, error) {
// Only process text messages
b.Log.Debugf("=> Received local message %#v", msg)
if msg.Event != "" && msg.Event != config.EventUserAction {
return "", nil
}
attachments := b.extractFiles(&msg)
b.local <- msg
for _, a := range attachments {
b.local <- a
}
return "", nil
}
func (b *Bmumble) buildTLSConfig() error {
b.tlsConfig = tls.Config{}
// Load TLS client certificate keypair required for registered user authentication
if cpath := b.GetString("TLSClientCertificate"); cpath != "" {
if ckey := b.GetString("TLSClientKey"); ckey != "" {
cert, err := tls.LoadX509KeyPair(cpath, ckey)
if err != nil {
return err
}
b.tlsConfig.Certificates = []tls.Certificate{cert}
}
}
// Load TLS CA used for server verification. If not provided, the Go system trust anchor is used
if capath := b.GetString("TLSCACertificate"); capath != "" {
ca, err := ioutil.ReadFile(capath)
if err != nil {
return err
}
b.tlsConfig.RootCAs = x509.NewCertPool()
b.tlsConfig.RootCAs.AppendCertsFromPEM(ca)
}
b.tlsConfig.InsecureSkipVerify = b.GetBool("SkipTLSVerify")
return nil
}
func (b *Bmumble) connectLoop() {
firstConnect := true
for {
err := b.doConnect()
if firstConnect {
b.running <- err
}
if err != nil {
b.Log.Errorf("Connection to server failed: %#v", err)
if firstConnect {
break
} else {
b.Log.Info("Retrying in 10s")
time.Sleep(10 * time.Second)
continue
}
}
firstConnect = false
d := <-b.connected
switch d.Type {
case gumble.DisconnectError:
b.Log.Errorf("Lost connection to the server (%s), attempting reconnect", d.String)
continue
case gumble.DisconnectKicked:
b.Log.Errorf("Kicked from the server (%s), attempting reconnect", d.String)
continue
case gumble.DisconnectBanned:
b.Log.Errorf("Banned from the server (%s), not attempting reconnect", d.String)
close(b.connected)
close(b.running)
return
case gumble.DisconnectUser:
b.Log.Infof("Disconnect successful")
close(b.connected)
close(b.running)
return
}
}
}
func (b *Bmumble) doConnect() error {
// Create new gumble config and attach event handlers
gumbleConfig := gumble.NewConfig()
gumbleConfig.Attach(gumbleutil.Listener{
ServerConfig: b.handleServerConfig,
TextMessage: b.handleTextMessage,
Connect: b.handleConnect,
Disconnect: b.handleDisconnect,
UserChange: b.handleUserChange,
})
gumbleConfig.Username = b.GetString("Nick")
if password := b.GetString("Password"); password != "" {
gumbleConfig.Password = password
}
client, err := gumble.DialWithDialer(new(net.Dialer), b.GetString("Server"), gumbleConfig, &b.tlsConfig)
if err != nil {
return err
}
b.client = client
return nil
}
func (b *Bmumble) doJoin(client *gumble.Client, channelID uint32) error {
channel, ok := client.Channels[channelID]
if !ok {
return fmt.Errorf("no channel with ID %d", channelID)
}
client.Self.Move(channel)
return nil
}
func (b *Bmumble) doSend() {
// Message sending loop that makes sure server-side
// restrictions and client-side message traits don't conflict
// with each other.
for {
select {
case serverConfig := <-b.serverConfigUpdate:
b.Log.Debugf("Received server config update: AllowHTML=%#v, MaximumMessageLength=%#v", serverConfig.AllowHTML, serverConfig.MaximumMessageLength)
b.serverConfig = serverConfig
case msg := <-b.local:
b.processMessage(&msg)
}
}
}
func (b *Bmumble) processMessage(msg *config.Message) {
b.Log.Debugf("Processing message %s", msg.Text)
allowHTML := true
if b.serverConfig.AllowHTML != nil {
allowHTML = *b.serverConfig.AllowHTML
}
// If this is a specially generated image message, send it unmodified
if msg.Event == "mumble_image" {
if allowHTML {
b.client.Self.Channel.Send(msg.Username+msg.Text, false)
} else {
b.Log.Info("Can't send image, server does not allow HTML messages")
}
return
}
// Don't process empty messages
if len(msg.Text) == 0 {
return
}
// If HTML is allowed, convert markdown into HTML, otherwise strip markdown
if allowHTML {
msg.Text = helper.ParseMarkdown(msg.Text)
} else {
msg.Text = stripmd.Strip(msg.Text)
}
// If there is a maximum message length, split and truncate the lines
var msgLines []string
if maxLength := b.serverConfig.MaximumMessageLength; maxLength != nil {
msgLines = helper.GetSubLines(msg.Text, *maxLength-len(msg.Username))
} else {
msgLines = helper.GetSubLines(msg.Text, 0)
}
// Send the individual lindes
for i := range msgLines {
b.client.Self.Channel.Send(msg.Username+msgLines[i], false)
}
}
+102 -6
View File
@@ -2,12 +2,13 @@ package nctalk
import ( import (
"context" "context"
"crypto/tls"
"strconv" "strconv"
"strings"
"github.com/42wim/matterbridge/bridge" "github.com/42wim/matterbridge/bridge"
"github.com/42wim/matterbridge/bridge/config" "github.com/42wim/matterbridge/bridge/config"
talk "gomod.garykim.dev/nc-talk"
"gomod.garykim.dev/nc-talk/ocs" "gomod.garykim.dev/nc-talk/ocs"
"gomod.garykim.dev/nc-talk/room" "gomod.garykim.dev/nc-talk/room"
"gomod.garykim.dev/nc-talk/user" "gomod.garykim.dev/nc-talk/user"
@@ -31,8 +32,18 @@ type Broom struct {
func (b *Btalk) Connect() error { func (b *Btalk) Connect() error {
b.Log.Info("Connecting") b.Log.Info("Connecting")
b.user = talk.NewUser(b.GetString("Server"), b.GetString("Login"), b.GetString("Password")) tconfig := &user.TalkUserConfig{
_, err := b.user.Capabilities() TLSConfig: &tls.Config{
InsecureSkipVerify: b.GetBool("SkipTLSVerify"), //nolint:gosec
},
}
var err error
b.user, err = user.NewUser(b.GetString("Server"), b.GetString("Login"), b.GetString("Password"), tconfig)
if err != nil {
b.Log.Error("Config could not be used")
return err
}
_, err = b.user.Capabilities()
if err != nil { if err != nil {
b.Log.Error("Cannot Connect") b.Log.Error("Cannot Connect")
return err return err
@@ -49,8 +60,12 @@ func (b *Btalk) Disconnect() error {
} }
func (b *Btalk) JoinChannel(channel config.ChannelInfo) error { func (b *Btalk) JoinChannel(channel config.ChannelInfo) error {
tr, err := room.NewTalkRoom(b.user, channel.Name)
if err != nil {
return err
}
newRoom := Broom{ newRoom := Broom{
room: talk.NewRoom(b.user, channel.Name), room: tr,
} }
newRoom.ctx, newRoom.ctxCancel = context.WithCancel(context.Background()) newRoom.ctx, newRoom.ctxCancel = context.WithCancel(context.Background())
c, err := newRoom.room.ReceiveMessages(newRoom.ctx) c, err := newRoom.room.ReceiveMessages(newRoom.ctx)
@@ -58,8 +73,23 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error {
return err return err
} }
b.rooms = append(b.rooms, newRoom) b.rooms = append(b.rooms, newRoom)
// Config
guestSuffix := " (Guest)"
if b.IsKeySet("GuestSuffix") {
guestSuffix = b.GetString("GuestSuffix")
}
go func() { go func() {
for msg := range c { for msg := range c {
msg := msg
if msg.Error != nil {
b.Log.Errorf("Fatal message poll error: %s\n", msg.Error)
return
}
// ignore messages that are one of the following // ignore messages that are one of the following
// * not a message from a user // * not a message from a user
// * from ourselves // * from ourselves
@@ -67,9 +97,9 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error {
continue continue
} }
remoteMessage := config.Message{ remoteMessage := config.Message{
Text: msg.Message, Text: formatRichObjectString(msg.Message, msg.MessageParameters),
Channel: newRoom.room.Token, Channel: newRoom.room.Token,
Username: msg.ActorDisplayName, Username: DisplayName(msg, guestSuffix),
UserID: msg.ActorID, UserID: msg.ActorID,
Account: b.Account, Account: b.Account,
} }
@@ -78,6 +108,15 @@ func (b *Btalk) JoinChannel(channel config.ChannelInfo) error {
if msg.ID != 0 { if msg.ID != 0 {
remoteMessage.ID = strconv.Itoa(msg.ID) remoteMessage.ID = strconv.Itoa(msg.ID)
} }
// Handle Files
err = b.handleFiles(&remoteMessage, &msg)
if err != nil {
b.Log.Errorf("Error handling file: %#v", msg)
continue
}
b.Log.Debugf("<= Message is %#v", remoteMessage) b.Log.Debugf("<= Message is %#v", remoteMessage)
b.Remote <- remoteMessage b.Remote <- remoteMessage
} }
@@ -112,3 +151,60 @@ func (b *Btalk) getRoom(token string) *Broom {
} }
return nil return nil
} }
func (b *Btalk) handleFiles(mmsg *config.Message, message *ocs.TalkRoomMessageData) error {
for _, parameter := range message.MessageParameters {
if parameter.Type == ocs.ROSTypeFile {
// Get the file
file, err := b.user.DownloadFile(parameter.Path)
if err != nil {
return err
}
if mmsg.Extra == nil {
mmsg.Extra = make(map[string][]interface{})
}
mmsg.Extra["file"] = append(mmsg.Extra["file"], config.FileInfo{
Name: parameter.Name,
Data: file,
Size: int64(len(*file)),
Avatar: false,
})
}
}
return nil
}
// Spec: https://github.com/nextcloud/server/issues/1706#issue-182308785
func formatRichObjectString(message string, parameters map[string]ocs.RichObjectString) string {
for id, parameter := range parameters {
text := parameter.Name
switch parameter.Type {
case ocs.ROSTypeUser, ocs.ROSTypeGroup:
text = "@" + text
case ocs.ROSTypeFile:
if parameter.Link != "" {
text = parameter.Name
}
}
message = strings.ReplaceAll(message, "{"+id+"}", text)
}
return message
}
func DisplayName(msg ocs.TalkRoomMessageData, suffix string) string {
if msg.ActorType == ocs.ActorGuest {
if msg.ActorDisplayName == "" {
return "Guest"
}
return msg.ActorDisplayName + suffix
}
return msg.ActorDisplayName
}
+1 -1
View File
@@ -299,7 +299,7 @@ func (b *Bslack) sendRTM(msg config.Message) (string, error) {
} }
// Handle prefix hint for unthreaded messages. // Handle prefix hint for unthreaded messages.
if msg.ParentID == "msg-parent-not-found" { if msg.ParentNotFound() {
msg.ParentID = "" msg.ParentID = ""
msg.Text = fmt.Sprintf("[thread]: %s", msg.Text) msg.Text = fmt.Sprintf("[thread]: %s", msg.Text)
} }
+51 -8
View File
@@ -217,6 +217,46 @@ func (b *Btelegram) handleDownloadAvatar(userid int, channel string) {
} }
} }
func (b *Btelegram) maybeConvertTgs(name *string, data *[]byte) {
var format string
switch b.GetString("MediaConvertTgs") {
case FormatWebp:
b.Log.Debugf("Tgs to WebP conversion enabled, converting %v", name)
format = FormatWebp
case FormatPng:
// The WebP to PNG converter can't handle animated webp files yet,
// and I'm not going to write a path for x/image/webp.
// The error message would be:
// conversion failed: webp: non-Alpha VP8X is not implemented
// So instead, we tell lottie to directly go to PNG.
b.Log.Debugf("Tgs to PNG conversion enabled, converting %v", name)
format = FormatPng
default:
// Otherwise, no conversion was requested. Trying to run the usual webp
// converter would fail, because '.tgs.webp' is actually a gzipped JSON
// file, and has nothing to do with WebP.
return
}
err := helper.ConvertTgsToX(data, format, b.Log)
if err != nil {
b.Log.Errorf("conversion failed: %v", err)
} else {
*name = strings.Replace(*name, "tgs.webp", format, 1)
}
}
func (b *Btelegram) maybeConvertWebp(name *string, data *[]byte) {
if b.GetBool("MediaConvertWebPToPNG") {
b.Log.Debugf("WebP to PNG conversion enabled, converting %v", name)
err := helper.ConvertWebPToPNG(data)
if err != nil {
b.Log.Errorf("conversion failed: %v", err)
} else {
*name = strings.Replace(*name, ".webp", ".png", 1)
}
}
}
// handleDownloadFile handles file download // handleDownloadFile handles file download
func (b *Btelegram) handleDownload(rmsg *config.Message, message *tgbotapi.Message) error { func (b *Btelegram) handleDownload(rmsg *config.Message, message *tgbotapi.Message) error {
size := 0 size := 0
@@ -264,15 +304,18 @@ func (b *Btelegram) handleDownload(rmsg *config.Message, message *tgbotapi.Messa
if err != nil { if err != nil {
return err return err
} }
if strings.HasSuffix(name, ".webp") && b.GetBool("MediaConvertWebPToPNG") {
b.Log.Debugf("WebP to PNG conversion enabled, converting %s", name) if strings.HasSuffix(name, ".tgs.webp") {
err := helper.ConvertWebPToPNG(data) b.maybeConvertTgs(&name, data)
if err != nil { } else if strings.HasSuffix(name, ".webp") {
b.Log.Errorf("conversion failed: %s", err) b.maybeConvertWebp(&name, data)
} else {
name = strings.Replace(name, ".webp", ".png", 1)
} }
// rename .oga to .ogg https://github.com/42wim/matterbridge/issues/906#issuecomment-741793512
if strings.HasSuffix(name, ".oga") && message.Audio != nil {
name = strings.Replace(name, ".oga", ".ogg", 1)
} }
helper.HandleDownloadData(b.Log, rmsg, name, message.Caption, "", data, b.General) helper.HandleDownloadData(b.Log, rmsg, name, message.Caption, "", data, b.General)
return nil return nil
} }
@@ -346,7 +389,7 @@ func (b *Btelegram) handleUploadFile(msg *config.Message, chatid int64) string {
Name: fi.Name, Name: fi.Name,
Bytes: *fi.Data, Bytes: *fi.Data,
} }
re := regexp.MustCompile(".(jpg|png)$") re := regexp.MustCompile(".(jpg|jpe|png)$")
if re.MatchString(fi.Name) { if re.MatchString(fi.Name) {
c = tgbotapi.NewPhotoUpload(chatid, file) c = tgbotapi.NewPhotoUpload(chatid, file)
} else { } else {
+13
View File
@@ -2,6 +2,7 @@ package btelegram
import ( import (
"html" "html"
"log"
"strconv" "strconv"
"strings" "strings"
@@ -16,6 +17,8 @@ const (
HTMLFormat = "HTML" HTMLFormat = "HTML"
HTMLNick = "htmlnick" HTMLNick = "htmlnick"
MarkdownV2 = "MarkdownV2" MarkdownV2 = "MarkdownV2"
FormatPng = "png"
FormatWebp = "webp"
) )
type Btelegram struct { type Btelegram struct {
@@ -25,6 +28,16 @@ type Btelegram struct {
} }
func New(cfg *bridge.Config) bridge.Bridger { func New(cfg *bridge.Config) bridge.Bridger {
tgsConvertFormat := cfg.GetString("MediaConvertTgs")
if tgsConvertFormat != "" {
err := helper.CanConvertTgsToX()
if err != nil {
log.Fatalf("Telegram bridge configured to convert .tgs files to '%s', but lottie does not appear to work:\n%#v", tgsConvertFormat, err)
}
if tgsConvertFormat != FormatPng && tgsConvertFormat != FormatWebp {
log.Fatalf("Telegram bridge configured to convert .tgs files to '%s', but only '%s' and '%s' are supported.", FormatPng, FormatWebp, tgsConvertFormat)
}
}
return &Btelegram{Config: cfg, avatarMap: make(map[string]string)} return &Btelegram{Config: cfg, avatarMap: make(map[string]string)}
} }
+152 -48
View File
@@ -24,7 +24,8 @@ Check:
func (b *Bwhatsapp) HandleError(err error) { func (b *Bwhatsapp) HandleError(err error) {
// ignore received invalid data errors. https://github.com/42wim/matterbridge/issues/843 // ignore received invalid data errors. https://github.com/42wim/matterbridge/issues/843
// ignore tag 174 errors. https://github.com/42wim/matterbridge/issues/1094 // ignore tag 174 errors. https://github.com/42wim/matterbridge/issues/1094
if strings.Contains(err.Error(), "error processing data: received invalid data") || strings.Contains(err.Error(), "invalid string with tag 174") { if strings.Contains(err.Error(), "error processing data: received invalid data") ||
strings.Contains(err.Error(), "invalid string with tag 174") {
return return
} }
@@ -47,16 +48,22 @@ func (b *Bwhatsapp) reconnect(err error) {
Max: 5 * time.Minute, Max: 5 * time.Minute,
Jitter: true, Jitter: true,
} }
for { for {
d := bf.Duration() d := bf.Duration()
b.Log.Errorf("Connection failed, underlying error: %v", err) b.Log.Errorf("Connection failed, underlying error: %v", err)
b.Log.Infof("Waiting %s...", d) b.Log.Infof("Waiting %s...", d)
time.Sleep(d) time.Sleep(d)
b.Log.Info("Reconnecting...") b.Log.Info("Reconnecting...")
err := b.conn.Restore() err := b.conn.Restore()
if err == nil { if err == nil {
bf.Reset() bf.Reset()
b.startedAt = uint64(time.Now().Unix()) b.startedAt = uint64(time.Now().Unix())
return return
} }
} }
@@ -64,7 +71,7 @@ func (b *Bwhatsapp) reconnect(err error) {
// HandleTextMessage sent from WhatsApp, relay it to the brige // HandleTextMessage sent from WhatsApp, relay it to the brige
func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) { func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) {
if message.Info.FromMe { // || !strings.Contains(strings.ToLower(message.Text), "@echo") { if message.Info.FromMe {
return return
} }
// whatsapp sends last messages to show context , cut them // whatsapp sends last messages to show context , cut them
@@ -72,14 +79,14 @@ func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) {
return return
} }
messageTime := time.Unix(int64(message.Info.Timestamp), 0) // TODO check how behaves between timezones
groupJID := message.Info.RemoteJid groupJID := message.Info.RemoteJid
senderJID := message.Info.SenderJid senderJID := message.Info.SenderJid
if len(senderJID) == 0 { if len(senderJID) == 0 {
// TODO workaround till https://github.com/Rhymen/go-whatsapp/issues/86 resolved if message.Info.Source != nil && message.Info.Source.Participant != nil {
senderJID = *message.Info.Source.Participant senderJID = *message.Info.Source.Participant
} }
}
// translate sender's JID to the nicest username we can get // translate sender's JID to the nicest username we can get
senderName := b.getSenderName(senderJID) senderName := b.getSenderName(senderJID)
@@ -99,108 +106,205 @@ func (b *Bwhatsapp) HandleTextMessage(message whatsapp.TextMessage) {
if mention == "" { if mention == "" {
mention = "someone" mention = "someone"
} }
message.Text = strings.Replace(message.Text, "@"+numberAndSuffix[0], "@"+mention, 1) message.Text = strings.Replace(message.Text, "@"+numberAndSuffix[0], "@"+mention, 1)
} }
} }
b.Log.Debugf("<= Sending message from %s on %s to gateway", senderJID, b.Account)
rmsg := config.Message{ rmsg := config.Message{
UserID: senderJID, UserID: senderJID,
Username: senderName, Username: senderName,
Text: message.Text, Text: message.Text,
Timestamp: messageTime,
Channel: groupJID, Channel: groupJID,
Account: b.Account, Account: b.Account,
Protocol: b.Protocol, Protocol: b.Protocol,
Extra: make(map[string][]interface{}), Extra: make(map[string][]interface{}),
// ParentID: TODO, // TODO handle thread replies // map from Info.QuotedMessageID string // ParentID: TODO, // TODO handle thread replies // map from Info.QuotedMessageID string
// Event string `json:"event"` ID: message.Info.Id,
// Gateway string // will be added during message processing }
ID: message.Info.Id}
if avatarURL, exists := b.userAvatars[senderJID]; exists { if avatarURL, exists := b.userAvatars[senderJID]; exists {
rmsg.Avatar = avatarURL rmsg.Avatar = avatarURL
} }
b.Log.Debugf("<= Sending message from %s on %s to gateway", senderJID, b.Account)
b.Log.Debugf("<= Message is %#v", rmsg) b.Log.Debugf("<= Message is %#v", rmsg)
b.Remote <- rmsg b.Remote <- rmsg
} }
// HandleImageMessage sent from WhatsApp, relay it to the brige // HandleImageMessage sent from WhatsApp, relay it to the brige
func (b *Bwhatsapp) HandleImageMessage(message whatsapp.ImageMessage) { func (b *Bwhatsapp) HandleImageMessage(message whatsapp.ImageMessage) {
if message.Info.FromMe { // || !strings.Contains(strings.ToLower(message.Text), "@echo") { if message.Info.FromMe || message.Info.Timestamp < b.startedAt {
return return
} }
// whatsapp sends last messages to show context , cut them
if message.Info.Timestamp < b.startedAt {
return
}
messageTime := time.Unix(int64(message.Info.Timestamp), 0) // TODO check how behaves between timezones
groupJID := message.Info.RemoteJid
senderJID := message.Info.SenderJid senderJID := message.Info.SenderJid
// if len(senderJid) == 0 { if len(message.Info.SenderJid) == 0 && message.Info.Source != nil && message.Info.Source.Participant != nil {
// // TODO workaround till https://github.com/Rhymen/go-whatsapp/issues/86 resolved senderJID = *message.Info.Source.Participant
// senderJid = *message.Info.Source.Participant }
// }
// translate sender's Jid to the nicest username we can get senderName := b.getSenderName(message.Info.SenderJid)
senderName := b.getSenderName(senderJID)
if senderName == "" { if senderName == "" {
senderName = "Someone" // don't expose telephone number senderName = "Someone" // don't expose telephone number
} }
b.Log.Debugf("<= Sending message from %s on %s to gateway", senderJID, b.Account)
rmsg := config.Message{ rmsg := config.Message{
UserID: senderJID, UserID: senderJID,
Username: senderName, Username: senderName,
Timestamp: messageTime, Channel: message.Info.RemoteJid,
Channel: groupJID,
Account: b.Account, Account: b.Account,
Protocol: b.Protocol, Protocol: b.Protocol,
Extra: make(map[string][]interface{}), Extra: make(map[string][]interface{}),
// ParentID: TODO, // TODO handle thread replies // map from Info.QuotedMessageID string ID: message.Info.Id,
// Event string `json:"event"` }
// Gateway string // will be added during message processing
ID: message.Info.Id}
if avatarURL, exists := b.userAvatars[senderJID]; exists { if avatarURL, exists := b.userAvatars[senderJID]; exists {
rmsg.Avatar = avatarURL rmsg.Avatar = avatarURL
} }
// Download and unencrypt content fileExt, err := mime.ExtensionsByType(message.Type)
data, err := message.Download()
if err != nil { if err != nil {
b.Log.Errorf("%v", err) b.Log.Errorf("Mimetype detection error: %s", err)
return return
} }
// Get file extension by mimetype // rename .jfif to .jpg https://github.com/42wim/matterbridge/issues/1292
if fileExt[0] == ".jfif" {
fileExt[0] = ".jpg"
}
filename := fmt.Sprintf("%v%v", message.Info.Id, fileExt[0])
b.Log.Debugf("Trying to download %s with type %s", filename, message.Type)
data, err := message.Download()
if err != nil {
b.Log.Errorf("Download image failed: %s", err)
return
}
// Move file to bridge storage
helper.HandleDownloadData(b.Log, &rmsg, filename, message.Caption, "", &data, b.General)
b.Log.Debugf("<= Sending message from %s on %s to gateway", senderJID, b.Account)
b.Log.Debugf("<= Message is %#v", rmsg)
b.Remote <- rmsg
}
// HandleVideoMessage downloads video messages
func (b *Bwhatsapp) HandleVideoMessage(message whatsapp.VideoMessage) {
if message.Info.FromMe || message.Info.Timestamp < b.startedAt {
return
}
senderJID := message.Info.SenderJid
if len(message.Info.SenderJid) == 0 && message.Info.Source != nil && message.Info.Source.Participant != nil {
senderJID = *message.Info.Source.Participant
}
senderName := b.getSenderName(message.Info.SenderJid)
if senderName == "" {
senderName = "Someone" // don't expose telephone number
}
rmsg := config.Message{
UserID: senderJID,
Username: senderName,
Channel: message.Info.RemoteJid,
Account: b.Account,
Protocol: b.Protocol,
Extra: make(map[string][]interface{}),
ID: message.Info.Id,
}
if avatarURL, exists := b.userAvatars[senderJID]; exists {
rmsg.Avatar = avatarURL
}
fileExt, err := mime.ExtensionsByType(message.Type) fileExt, err := mime.ExtensionsByType(message.Type)
if err != nil { if err != nil {
b.Log.Errorf("%v", err) b.Log.Errorf("Mimetype detection error: %s", err)
return return
} }
filename := fmt.Sprintf("%v%v", message.Info.Id, fileExt[0]) filename := fmt.Sprintf("%v%v", message.Info.Id, fileExt[0])
b.Log.Debugf("<= Image downloaded and unencrypted") b.Log.Debugf("Trying to download %s with size %#v and type %s", filename, message.Length, message.Type)
data, err := message.Download()
if err != nil {
b.Log.Errorf("Download video failed: %s", err)
return
}
// Move file to bridge storage // Move file to bridge storage
helper.HandleDownloadData(b.Log, &rmsg, filename, message.Caption, "", &data, b.General) helper.HandleDownloadData(b.Log, &rmsg, filename, message.Caption, "", &data, b.General)
b.Log.Debugf("<= Image Message is %#v", rmsg) b.Log.Debugf("<= Sending message from %s on %s to gateway", senderJID, b.Account)
b.Log.Debugf("<= Message is %#v", rmsg)
b.Remote <- rmsg b.Remote <- rmsg
} }
//func (b *Bwhatsapp) HandleVideoMessage(message whatsapp.VideoMessage) { // HandleAudioMessage downloads audio messages
// fmt.Println(message) // TODO implement func (b *Bwhatsapp) HandleAudioMessage(message whatsapp.AudioMessage) {
//} if message.Info.FromMe || message.Info.Timestamp < b.startedAt {
// return
//func (b *Bwhatsapp) HandleJsonMessage(message string) { }
// fmt.Println(message) // TODO implement
//} senderJID := message.Info.SenderJid
// TODO HandleRawMessage if len(message.Info.SenderJid) == 0 && message.Info.Source != nil && message.Info.Source.Participant != nil {
// TODO HandleAudioMessage senderJID = *message.Info.Source.Participant
}
senderName := b.getSenderName(message.Info.SenderJid)
if senderName == "" {
senderName = "Someone" // don't expose telephone number
}
rmsg := config.Message{
UserID: senderJID,
Username: senderName,
Channel: message.Info.RemoteJid,
Account: b.Account,
Protocol: b.Protocol,
Extra: make(map[string][]interface{}),
ID: message.Info.Id,
}
if avatarURL, exists := b.userAvatars[senderJID]; exists {
rmsg.Avatar = avatarURL
}
fileExt, err := mime.ExtensionsByType(message.Type)
if err != nil {
b.Log.Errorf("Mimetype detection error: %s", err)
return
}
filename := fmt.Sprintf("%v%v", message.Info.Id, fileExt[0])
b.Log.Debugf("Trying to download %s with size %#v and type %s", filename, message.Length, message.Type)
data, err := message.Download()
if err != nil {
b.Log.Errorf("Download audio failed: %s", err)
return
}
// Move file to bridge storage
helper.HandleDownloadData(b.Log, &rmsg, filename, "audio message", "", &data, b.General)
b.Log.Debugf("<= Sending message from %s on %s to gateway", senderJID, b.Account)
b.Log.Debugf("<= Message is %#v", rmsg)
b.Remote <- rmsg
}
+41 -10
View File
@@ -6,6 +6,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"os" "os"
"strings"
qrcodeTerminal "github.com/Baozisoftware/qrcode-terminal-go" qrcodeTerminal "github.com/Baozisoftware/qrcode-terminal-go"
"github.com/Rhymen/go-whatsapp" "github.com/Rhymen/go-whatsapp"
@@ -14,14 +15,15 @@ import (
type ProfilePicInfo struct { type ProfilePicInfo struct {
URL string `json:"eurl"` URL string `json:"eurl"`
Tag string `json:"tag"` Tag string `json:"tag"`
Status int16 `json:"status"` Status int16 `json:"status"`
} }
func qrFromTerminal(invert bool) chan string { func qrFromTerminal(invert bool) chan string {
qr := make(chan string) qr := make(chan string)
go func() { go func() {
terminal := qrcodeTerminal.New() terminal := qrcodeTerminal.New()
if invert { if invert {
terminal = qrcodeTerminal.New2(qrcodeTerminal.ConsoleColors.BrightWhite, qrcodeTerminal.ConsoleColors.BrightBlack, qrcodeTerminal.QRCodeRecoveryLevels.Medium) terminal = qrcodeTerminal.New2(qrcodeTerminal.ConsoleColors.BrightWhite, qrcodeTerminal.ConsoleColors.BrightBlack, qrcodeTerminal.QRCodeRecoveryLevels.Medium)
} }
@@ -44,13 +46,12 @@ func (b *Bwhatsapp) readSession() (whatsapp.Session, error) {
if err != nil { if err != nil {
return session, err return session, err
} }
defer file.Close() defer file.Close()
decoder := gob.NewDecoder(file) decoder := gob.NewDecoder(file)
err = decoder.Decode(&session)
if err != nil { return session, decoder.Decode(&session)
return session, err
}
return session, nil
} }
func (b *Bwhatsapp) writeSession(session whatsapp.Session) error { func (b *Bwhatsapp) writeSession(session whatsapp.Session) error {
@@ -65,11 +66,31 @@ func (b *Bwhatsapp) writeSession(session whatsapp.Session) error {
if err != nil { if err != nil {
return err return err
} }
defer file.Close()
encoder := gob.NewEncoder(file)
err = encoder.Encode(session)
return err defer file.Close()
encoder := gob.NewEncoder(file)
return encoder.Encode(session)
}
func (b *Bwhatsapp) restoreSession() (*whatsapp.Session, error) {
session, err := b.readSession()
if err != nil {
b.Log.Warn(err.Error())
}
b.Log.Debugln("Restoring WhatsApp session..")
session, err = b.conn.RestoreWithSession(session)
if err != nil {
// restore session connection timed out (I couldn't get over it without logging in again)
return nil, errors.New("failed to restore session: " + err.Error())
}
b.Log.Debugln("Session restored successfully!")
return &session, nil
} }
func (b *Bwhatsapp) getSenderName(senderJid string) string { func (b *Bwhatsapp) getSenderName(senderJid string) string {
@@ -114,6 +135,7 @@ func (b *Bwhatsapp) getSenderNotify(senderJid string) string {
if sender, exists := b.users[senderJid]; exists { if sender, exists := b.users[senderJid]; exists {
return sender.Notify return sender.Notify
} }
return "" return ""
} }
@@ -122,11 +144,20 @@ func (b *Bwhatsapp) GetProfilePicThumb(jid string) (*ProfilePicInfo, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to get avatar: %v", err) return nil, fmt.Errorf("failed to get avatar: %v", err)
} }
content := <-data content := <-data
info := &ProfilePicInfo{} info := &ProfilePicInfo{}
err = json.Unmarshal([]byte(content), info) err = json.Unmarshal([]byte(content), info)
if err != nil { if err != nil {
return info, fmt.Errorf("failed to unmarshal avatar info: %v", err) return info, fmt.Errorf("failed to unmarshal avatar info: %v", err)
} }
return info, nil return info, nil
} }
func isGroupJid(identifier string) bool {
return strings.HasSuffix(identifier, "@g.us") ||
strings.HasSuffix(identifier, "@temp") ||
strings.HasSuffix(identifier, "@broadcast")
}
+34 -70
View File
@@ -28,7 +28,6 @@ const (
type Bwhatsapp struct { type Bwhatsapp struct {
*bridge.Config *bridge.Config
// https://github.com/Rhymen/go-whatsapp/blob/c31092027237441cffba1b9cb148eadf7c83c3d2/session.go#L18-L21
session *whatsapp.Session session *whatsapp.Session
conn *whatsapp.Conn conn *whatsapp.Conn
startedAt uint64 startedAt uint64
@@ -40,6 +39,7 @@ type Bwhatsapp struct {
// New Create a new WhatsApp bridge. This will be called for each [whatsapp.<server>] entry you have in the config file // New Create a new WhatsApp bridge. This will be called for each [whatsapp.<server>] entry you have in the config file
func New(cfg *bridge.Config) bridge.Bridger { func New(cfg *bridge.Config) bridge.Bridger {
number := cfg.GetString(cfgNumber) number := cfg.GetString(cfgNumber)
if number == "" { if number == "" {
cfg.Log.Fatalf("Missing configuration for WhatsApp bridge: Number") cfg.Log.Fatalf("Missing configuration for WhatsApp bridge: Number")
} }
@@ -50,24 +50,19 @@ func New(cfg *bridge.Config) bridge.Bridger {
users: make(map[string]whatsapp.Contact), users: make(map[string]whatsapp.Contact),
userAvatars: make(map[string]string), userAvatars: make(map[string]string),
} }
return b return b
} }
// Connect to WhatsApp. Required implementation of the Bridger interface // Connect to WhatsApp. Required implementation of the Bridger interface
// https://github.com/42wim/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16
func (b *Bwhatsapp) Connect() error { func (b *Bwhatsapp) Connect() error {
b.RLock() // TODO do we need locking for Whatsapp?
defer b.RUnlock()
number := b.GetString(cfgNumber) number := b.GetString(cfgNumber)
if number == "" { if number == "" {
return errors.New("WhatsApp's telephone Number need to be configured") return errors.New("whatsapp's telephone number need to be configured")
} }
// https://github.com/Rhymen/go-whatsapp#creating-a-connection
b.Log.Debugln("Connecting to WhatsApp..") b.Log.Debugln("Connecting to WhatsApp..")
conn, err := whatsapp.NewConn(20 * time.Second) conn, err := whatsapp.NewConn(20 * time.Second)
conn.SetClientVersion(0, 4, 2080)
if err != nil { if err != nil {
return errors.New("failed to connect to WhatsApp: " + err.Error()) return errors.New("failed to connect to WhatsApp: " + err.Error())
} }
@@ -78,35 +73,18 @@ func (b *Bwhatsapp) Connect() error {
b.Log.Debugln("WhatsApp connection successful") b.Log.Debugln("WhatsApp connection successful")
// load existing session in order to keep it between restarts // load existing session in order to keep it between restarts
if b.session == nil { b.session, err = b.restoreSession()
var session whatsapp.Session
session, err = b.readSession()
if err == nil {
b.Log.Debugln("Restoring WhatsApp session..")
// https://github.com/Rhymen/go-whatsapp#restore
session, err = b.conn.RestoreWithSession(session)
if err != nil { if err != nil {
// TODO return or continue to normal login?
// restore session connection timed out (I couldn't get over it without logging in again)
return errors.New("failed to restore session: " + err.Error())
}
b.session = &session
b.Log.Debugln("Session restored successfully!")
} else {
b.Log.Warn(err.Error()) b.Log.Warn(err.Error())
} }
}
// login to a new session // login to a new session
if b.session == nil { if b.session == nil {
err = b.Login() if err = b.Login(); err != nil {
if err != nil {
return err return err
} }
} }
b.startedAt = uint64(time.Now().Unix()) b.startedAt = uint64(time.Now().Unix())
_, err = b.conn.Contacts() _, err = b.conn.Contacts()
@@ -114,6 +92,13 @@ func (b *Bwhatsapp) Connect() error {
return fmt.Errorf("error on update of contacts: %v", err) return fmt.Errorf("error on update of contacts: %v", err)
} }
// see https://github.com/Rhymen/go-whatsapp/issues/137#issuecomment-480316013
for len(b.conn.Store.Contacts) == 0 {
b.conn.Contacts() // nolint:errcheck
<-time.After(1 * time.Second)
}
// map all the users // map all the users
for id, contact := range b.conn.Store.Contacts { for id, contact := range b.conn.Store.Contacts {
if !isGroupJid(id) && id != "status@broadcast" { if !isGroupJid(id) && id != "status@broadcast" {
@@ -130,12 +115,13 @@ func (b *Bwhatsapp) Connect() error {
info, err := b.GetProfilePicThumb(jid) info, err := b.GetProfilePicThumb(jid)
if err != nil { if err != nil {
b.Log.Warnf("Could not get profile photo of %s: %v", jid, err) b.Log.Warnf("Could not get profile photo of %s: %v", jid, err)
} else { } else {
// TODO any race conditions here? b.Lock()
b.userAvatars[jid] = info.URL b.userAvatars[jid] = info.URL
b.Unlock()
} }
} }
b.Log.Debug("Finished getting avatars..") b.Log.Debug("Finished getting avatars..")
}() }()
@@ -152,8 +138,10 @@ func (b *Bwhatsapp) Login() error {
session, err := b.conn.Login(qrChan) session, err := b.conn.Login(qrChan)
if err != nil { if err != nil {
b.Log.Warnln("Failed to log in:", err) b.Log.Warnln("Failed to log in:", err)
return err return err
} }
b.session = &session b.session = &session
b.Log.Infof("Logged into session: %#v", session) b.Log.Infof("Logged into session: %#v", session)
@@ -164,42 +152,39 @@ func (b *Bwhatsapp) Login() error {
fmt.Fprintf(os.Stderr, "error saving session: %v\n", err) fmt.Fprintf(os.Stderr, "error saving session: %v\n", err)
} }
// TODO change connection strings to configured ones longClientName:"github.com/rhymen/go-whatsapp", shortClientName:"go-whatsapp"}" prefix=whatsapp
// TODO get also a nice logo
// TODO notification about unplugged and dead battery
// conn.Info: Wid, Pushname, Connected, Battery, Plugged
return nil return nil
} }
// Disconnect is called while reconnecting to the bridge // Disconnect is called while reconnecting to the bridge
// TODO 42wim Documentation would be helpful on when reconnects happen and what should be done in this function
// Required implementation of the Bridger interface // Required implementation of the Bridger interface
// https://github.com/42wim/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16
func (b *Bwhatsapp) Disconnect() error { func (b *Bwhatsapp) Disconnect() error {
// We could Logout, but that would close the session completely and would require a new QR code scan // We could Logout, but that would close the session completely and would require a new QR code scan
// https://github.com/Rhymen/go-whatsapp/blob/c31092027237441cffba1b9cb148eadf7c83c3d2/session.go#L377-L381 // https://github.com/Rhymen/go-whatsapp/blob/c31092027237441cffba1b9cb148eadf7c83c3d2/session.go#L377-L381
return nil return nil
} }
func isGroupJid(identifier string) bool {
return strings.HasSuffix(identifier, "@g.us") || strings.HasSuffix(identifier, "@temp")
}
// JoinChannel Join a WhatsApp group specified in gateway config as channel='number-id@g.us' or channel='Channel name' // JoinChannel Join a WhatsApp group specified in gateway config as channel='number-id@g.us' or channel='Channel name'
// Required implementation of the Bridger interface // Required implementation of the Bridger interface
// https://github.com/42wim/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16 // https://github.com/42wim/matterbridge/blob/2cfd880cdb0df29771bf8f31df8d990ab897889d/bridge/bridge.go#L11-L16
func (b *Bwhatsapp) JoinChannel(channel config.ChannelInfo) error { func (b *Bwhatsapp) JoinChannel(channel config.ChannelInfo) error {
byJid := isGroupJid(channel.Name) byJid := isGroupJid(channel.Name)
// see https://github.com/Rhymen/go-whatsapp/issues/137#issuecomment-480316013
for len(b.conn.Store.Contacts) == 0 {
b.conn.Contacts() // nolint:errcheck
<-time.After(1 * time.Second)
}
// verify if we are member of the given group // verify if we are member of the given group
if byJid { if byJid {
// channel.Name specifies static group jID, not the name // channel.Name specifies static group jID, not the name
if _, exists := b.conn.Store.Contacts[channel.Name]; !exists { if _, exists := b.conn.Store.Contacts[channel.Name]; !exists {
return fmt.Errorf("account doesn't belong to group with jid %s", channel.Name) return fmt.Errorf("account doesn't belong to group with jid %s", channel.Name)
} }
} else {
return nil
}
// channel.Name specifies group name that might change, warn about it // channel.Name specifies group name that might change, warn about it
var jids []string var jids []string
for id, contact := range b.conn.Store.Contacts { for id, contact := range b.conn.Store.Contacts {
@@ -211,29 +196,20 @@ func (b *Bwhatsapp) JoinChannel(channel config.ChannelInfo) error {
switch len(jids) { switch len(jids) {
case 0: case 0:
// didn't match any group - print out possibilites // didn't match any group - print out possibilites
// TODO sort
// copy b;
//sort.Slice(people, func(i, j int) bool {
// return people[i].Age > people[j].Age
//})
for id, contact := range b.conn.Store.Contacts { for id, contact := range b.conn.Store.Contacts {
if isGroupJid(id) { if isGroupJid(id) {
b.Log.Infof("%s %s", contact.Jid, contact.Name) b.Log.Infof("%s %s", contact.Jid, contact.Name)
} }
} }
return fmt.Errorf("please specify group's JID from the list above instead of the name '%s'", channel.Name)
return fmt.Errorf("please specify group's JID from the list above instead of the name '%s'", channel.Name)
case 1: case 1:
return fmt.Errorf("group name might change. Please configure gateway with channel=\"%v\" instead of channel=\"%v\"", jids[0], channel.Name) return fmt.Errorf("group name might change. Please configure gateway with channel=\"%v\" instead of channel=\"%v\"", jids[0], channel.Name)
default: default:
return fmt.Errorf("there is more than one group with name '%s'. Please specify one of JIDs as channel name: %v", channel.Name, jids) return fmt.Errorf("there is more than one group with name '%s'. Please specify one of JIDs as channel name: %v", channel.Name, jids)
} }
} }
return nil
}
// Post a document message from the bridge to WhatsApp // Post a document message from the bridge to WhatsApp
func (b *Bwhatsapp) PostDocumentMessage(msg config.Message, filetype string) (string, error) { func (b *Bwhatsapp) PostDocumentMessage(msg config.Message, filetype string) (string, error) {
fi := msg.Extra["file"][0].(config.FileInfo) fi := msg.Extra["file"][0].(config.FileInfo)
@@ -305,14 +281,12 @@ func (b *Bwhatsapp) Send(msg config.Message) (string, error) {
if msg.ID == "" { if msg.ID == "" {
// No message ID in case action is executed on a message sent before the bridge was started // No message ID in case action is executed on a message sent before the bridge was started
// and then the bridge cache doesn't have this message ID mapped // and then the bridge cache doesn't have this message ID mapped
// TODO 42wim Doesn't the app get clogged with a ton of IDs after some time of running?
// WhatsApp allows to set any ID so in that case we could use external IDs and don't do mapping
// but external IDs are not set
return "", nil return "", nil
} }
// TODO delete message on WhatsApp https://github.com/Rhymen/go-whatsapp/issues/100
return "", nil _, err := b.conn.RevokeMessage(msg.Channel, msg.ID, true)
return "", err
} }
// Edit message // Edit message
@@ -320,7 +294,6 @@ func (b *Bwhatsapp) Send(msg config.Message) (string, error) {
b.Log.Debugf("updating message with id %s", msg.ID) b.Log.Debugf("updating message with id %s", msg.ID)
msg.Text += " (edited)" msg.Text += " (edited)"
// TODO handle edit as a message reply with updated text
} }
// Handle Upload a file // Handle Upload a file
@@ -350,16 +323,7 @@ func (b *Bwhatsapp) Send(msg config.Message) (string, error) {
b.Log.Debugf("=> Sending %#v", msg) b.Log.Debugf("=> Sending %#v", msg)
// create message ID return b.conn.Send(message)
// TODO follow and act if https://github.com/Rhymen/go-whatsapp/issues/101 implemented
idBytes := make([]byte, 10)
if _, err := rand.Read(idBytes); err != nil {
b.Log.Warn(err.Error())
}
message.Info.Id = strings.ToUpper(hex.EncodeToString(idBytes))
_, err := b.conn.Send(message)
return message.Info.Id, err
} }
// TODO do we want that? to allow login with QR code from a bridged channel? https://github.com/tulir/mautrix-whatsapp/blob/513eb18e2d59bada0dd515ee1abaaf38a3bfe3d5/commands.go#L76 // TODO do we want that? to allow login with QR code from a bridged channel? https://github.com/tulir/mautrix-whatsapp/blob/513eb18e2d59bada0dd515ee1abaaf38a3bfe3d5/commands.go#L76
+50 -5
View File
@@ -1,8 +1,11 @@
package bxmpp package bxmpp
import ( import (
"bytes"
"crypto/tls" "crypto/tls"
"encoding/json"
"fmt" "fmt"
"net/http"
"strings" "strings"
"sync" "sync"
"time" "time"
@@ -86,14 +89,21 @@ func (b *Bxmpp) Send(msg config.Message) (string, error) {
} }
// Upload a file (in XMPP case send the upload URL because XMPP has no native upload support). // Upload a file (in XMPP case send the upload URL because XMPP has no native upload support).
var err error
if msg.Extra != nil { if msg.Extra != nil {
for _, rmsg := range helper.HandleExtra(&msg, b.General) { for _, rmsg := range helper.HandleExtra(&msg, b.General) {
b.Log.Debugf("=> Sending attachement message %#v", rmsg) b.Log.Debugf("=> Sending attachement message %#v", rmsg)
if _, err := b.xc.Send(xmpp.Chat{ if b.GetString("WebhookURL") != "" {
err = b.postSlackCompatibleWebhook(msg)
} else {
_, err = b.xc.Send(xmpp.Chat{
Type: "groupchat", Type: "groupchat",
Remote: rmsg.Channel + "@" + b.GetString("Muc"), Remote: rmsg.Channel + "@" + b.GetString("Muc"),
Text: rmsg.Username + rmsg.Text, Text: rmsg.Username + rmsg.Text,
}); err != nil { })
}
if err != nil {
b.Log.WithError(err).Error("Unable to send message with share URL.") b.Log.WithError(err).Error("Unable to send message with share URL.")
} }
} }
@@ -102,13 +112,24 @@ func (b *Bxmpp) Send(msg config.Message) (string, error) {
} }
} }
if b.GetString("WebhookURL") != "" {
b.Log.Debugf("Sending message using Webhook")
err := b.postSlackCompatibleWebhook(msg)
if err != nil {
b.Log.Errorf("Failed to send message using webhook: %s", err)
return "", err
}
return "", nil
}
// Post normal message.
var msgReplaceID string var msgReplaceID string
msgID := xid.New().String() msgID := xid.New().String()
if msg.ID != "" { if msg.ID != "" {
msgID = msg.ID msgID = msg.ID
msgReplaceID = msg.ID msgReplaceID = msg.ID
} }
// Post normal message.
b.Log.Debugf("=> Sending message %#v", msg) b.Log.Debugf("=> Sending message %#v", msg)
if _, err := b.xc.Send(xmpp.Chat{ if _, err := b.xc.Send(xmpp.Chat{
Type: "groupchat", Type: "groupchat",
@@ -122,6 +143,25 @@ func (b *Bxmpp) Send(msg config.Message) (string, error) {
return msgID, nil return msgID, nil
} }
func (b *Bxmpp) postSlackCompatibleWebhook(msg config.Message) error {
type XMPPWebhook struct {
Username string `json:"username"`
Text string `json:"text"`
}
webhookBody, err := json.Marshal(XMPPWebhook{
Username: msg.Username,
Text: msg.Text,
})
if err != nil {
b.Log.Errorf("Failed to marshal webhook: %s", err)
return err
}
resp, err := http.Post(b.GetString("WebhookURL")+"/"+msg.Channel, "application/json", bytes.NewReader(webhookBody))
resp.Body.Close()
return err
}
func (b *Bxmpp) createXMPP() error { func (b *Bxmpp) createXMPP() error {
if !strings.Contains(b.GetString("Jid"), "@") { if !strings.Contains(b.GetString("Jid"), "@") {
return fmt.Errorf("the Jid %s doesn't contain an @", b.GetString("Jid")) return fmt.Errorf("the Jid %s doesn't contain an @", b.GetString("Jid"))
@@ -138,14 +178,14 @@ func (b *Bxmpp) createXMPP() error {
User: b.GetString("Jid"), User: b.GetString("Jid"),
Password: b.GetString("Password"), Password: b.GetString("Password"),
NoTLS: true, NoTLS: true,
StartTLS: true, StartTLS: !b.GetBool("NoTLS"),
TLSConfig: tc, TLSConfig: tc,
Debug: b.GetBool("debug"), Debug: b.GetBool("debug"),
Session: true, Session: true,
Status: "", Status: "",
StatusMessage: "", StatusMessage: "",
Resource: "", Resource: "",
InsecureAllowUnencryptedAuth: false, InsecureAllowUnencryptedAuth: b.GetBool("NoTLS"),
} }
var err error var err error
b.xc, err = options.NewClient() b.xc, err = options.NewClient()
@@ -378,6 +418,11 @@ func (b *Bxmpp) skipMessage(message xmpp.Chat) bool {
return true return true
} }
// Ignore messages posted by our webhook
if b.GetString("WebhookURL") != "" && strings.Contains(message.ID, "webhookbot") {
return true
}
// skip delayed messages // skip delayed messages
return !message.Stamp.IsZero() && time.Since(message.Stamp).Minutes() > 5 return !message.Stamp.IsZero() && time.Since(message.Stamp).Minutes() > 5
} }
+8 -2
View File
@@ -135,19 +135,25 @@ func (b *Bzulip) handleQueue() error {
if m.SenderEmail == b.GetString("login") { if m.SenderEmail == b.GetString("login") {
continue continue
} }
avatarURL := m.AvatarURL
if !strings.HasPrefix(avatarURL, "http") {
avatarURL = b.GetString("server") + avatarURL
}
rmsg := config.Message{ rmsg := config.Message{
Username: m.SenderFullName, Username: m.SenderFullName,
Text: m.Content, Text: m.Content,
Channel: b.getChannel(m.StreamID) + "/topic:" + m.Subject, Channel: b.getChannel(m.StreamID) + "/topic:" + m.Subject,
Account: b.Account, Account: b.Account,
UserID: strconv.Itoa(m.SenderID), UserID: strconv.Itoa(m.SenderID),
Avatar: m.AvatarURL, Avatar: avatarURL,
} }
b.Log.Debugf("<= Sending message from %s on %s to gateway", rmsg.Username, b.Account) b.Log.Debugf("<= Sending message from %s on %s to gateway", rmsg.Username, b.Account)
b.Log.Debugf("<= Message is %#v", rmsg) b.Log.Debugf("<= Message is %#v", rmsg)
b.Remote <- rmsg b.Remote <- rmsg
b.q.LastEventID = m.ID
} }
time.Sleep(time.Second * 3) time.Sleep(time.Second * 3)
} }
} }
+140
View File
@@ -1,3 +1,143 @@
# v1.21.0
## Breaking Changes
- discord: Remove WebhookURL support (discord) (#1323)
`WebhookURL` global setting for discord is removed and will quit matterbridge.
New `AutoWebhooks=true` setting, which will automatically use (and create, if they do not exist) webhooks inside specific channels. This only works if the bot has Manage Webhooks permission in bridged channels (global permission or as a channel permission override). Backwards compatibility with channel-specific webhooks. More info [here](https://github.com/42wim/matterbridge/blob/master/matterbridge.toml.sample#L862).
## New features
- discord: Create webhooks automatically (#1323)
- discord: Add threading support with token (discord) (#1342)
- irc: Join on invite (irc). Fixes #1231 (#1306)
- irc: Add support for stateless bridging via draft/relaymsg (irc) (#1339)
- whatsapp: Add support for deleting messages (whatsapp) (#1316)
- whatsapp: Handle video downloads (whatsapp) (#1316)
- whatsapp: Handle audio downloads (whatsapp) (#1316)
## Enhancements
- general: Parse fencedcode in ParseMarkdown. Fixes #1127 (#1329)
- discord: Refactor guild finding code (discord) (#1319)
- discord: Add a prefix handler for unthreaded messages (discord) (#1346)
- irc: Add support for irc to irc notice (irc). Fixes #754 (#1305)
- irc: Make handlers run async (irc) (#1325)
- matrix: Show mxids in case of clashing usernames (matrix) (#1309)
- matrix: Implement ratelimiting (matrix). Fixes #1238 (#1326)
- matrix: Mark messages as read (matrix). Fixes #1317 (#1328)
- nctalk: Update go-nc-talk (nctalk) (#1333)
- rocketchat: Update rocketchat vendor (#1327)
- tengo: Add UserID to RemoteNickFormat and Tengo (#1308)
- whatsapp: Retry until we have contacts (whatsapp). Fixes #1122 (#1304)
- whatsapp: Refactor/cleanup code (whatsapp)
- whatsapp: Refactor handleTextMessage (whatsapp)
- whatsapp: Refactor image downloads (whatsapp)
- whatsapp: Rename jfif to jpg (whatsapp). Fixes #1292
## Bugfix
- discord: Reject cross-channel message references (discord) (#1345)
- mumble: Add nil checks to text message handling (mumble) (#1321)
This release couldn't exist without the following contributors:
@nightmared, @qaisjp, @jlu5, @wschwab, @gary-kim, @s3lph, @JeremyRand
# v1.20.0
## Breaking
- matrix: Send the display name instead of the user name (matrix) (#1282)
Matrix now sends the displayname if set instead of the username. If you want to keep the username, add `UseUsername=true` to your matrix config. <https://github.com/42wim/matterbridge/wiki/Settings#useusername-1>
- discord: Disable webhook editing (discord) (#1296)
Because of issues with ratelimiting of webhook editing, this feature is now disabled. If you have multiple discord channels you bridge, you'll need to add a `webhookURL` to the `[gateway.inout.options]`. See <https://github.com/42wim/matterbridge/blob/master/matterbridge.toml.sample#L1864-L1870> for an example.
## New features
- general: Allow tengo to drop messages using msgDrop (#1272)
- general: Update libraries (whatsapp,markdown,mattermost,ssh-chat)
- irc: Add PingDelay option (irc) (#1269)
- matrix: Allow message edits on matrix (#1286)
- xmpp: add NoTLS option to allow plaintext XMPP connections (#1288)
## Enhancements
- discord: Edit messages via webhook (1287)
- general: Add extra debug to log time spent sending a message per bridge (#1299)
This release couldn't exist without the following contributors:
@nightmared, @zhoreeq
# v1.19.0
## New features
- mumble: new protocol added: Add Mumble support (#1245)
- nctalk: Add support for downloading files (nctalk) (#1249)
- nctalk: Append a suffix if user is a guest user (nctalk) (#1250)
## Enhancements
- irc: Add even more debug for irc (#1266)
- matrix: Add username formatting for all events (matrix) (#1233)
- matrix: Permit uploading files of other mimetypes (#1237)
- whatsapp: Use vendored whatsapp version (#1258)
- whatsapp: Add username for images from WhatsApp (#1232)
This release couldn't exist without the following contributors:
@Dellle, @42wim, @gary-kim, @s3lph, @BenWiederhake
# v1.18.3
## Enhancements
- nctalk: Add TLSConfig to nctalk (#1195)
- whatsapp: Handle broadcasts as groups in Whatsapp #1213
- matrix: switch to upstream gomatrix #1219
- api: support multiple websocket clients #1205
## Bugfix
- general: update vendor
- zulip: Check location of avatarURL (zulip). Fixes #1214 (#1227)
- nctalk: Fix issue with too many open files #1223
- nctalk: Fix mentions #1222
- nctalk: Fix message replays #1220
This release couldn't exist without the following contributors:
@gary-kim, @tilosp, @NikkyAI, @escoand, @42wim
# v1.18.2
## Bugfix
- zulip: Fix error loop (zulip) (#1210)
- whatsapp: Update whatsapp vendor and fix a panic (#1209)
This release couldn't exist without the following contributors:
@SuperSandro2000, @42wim
# v1.18.1
## New features
- telegram: Support Telegram animated stickers (tgs) format (#1173). See https://github.com/42wim/matterbridge/wiki/Settings#mediaConverttgs for more info
## Enhancements
- matrix: Remove HTML formatting for push messages (#1188) (#1189)
- mattermost: Use mattermost v5 module (#1192)
## Bugfix
- whatsapp: Handle panic in whatsapp. Fixes #1180 (#1184)
- nctalk: Fix Nextcloud Talk connection failure (#1179)
- matrix: Sleep when ratelimited on joins (matrix). Fixes #1201 (#1206)
This release couldn't exist without the following contributors:
@42wim, @BenWiederhake, @Dellle, @gary-kim
# v1.18.0 # v1.18.0
## New features ## New features
+11
View File
@@ -0,0 +1,11 @@
// +build !nomumble
package bridgemap
import (
bmumble "github.com/42wim/matterbridge/bridge/mumble"
)
func init() {
FullMap["mumble"] = bmumble.New
}
+70 -23
View File
@@ -1,6 +1,7 @@
package gateway package gateway
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"regexp" "regexp"
@@ -336,20 +337,21 @@ func (gw *Gateway) modifyUsername(msg *config.Message, dest *bridge.Bridge) stri
} }
i++ i++
} }
nick = strings.Replace(nick, "{NOPINGNICK}", msg.Username[:i]+""+msg.Username[i:], -1) nick = strings.ReplaceAll(nick, "{NOPINGNICK}", msg.Username[:i]+"\u200b"+msg.Username[i:])
} }
nick = strings.Replace(nick, "{BRIDGE}", br.Name, -1) nick = strings.ReplaceAll(nick, "{BRIDGE}", br.Name)
nick = strings.Replace(nick, "{PROTOCOL}", br.Protocol, -1) nick = strings.ReplaceAll(nick, "{PROTOCOL}", br.Protocol)
nick = strings.Replace(nick, "{GATEWAY}", gw.Name, -1) nick = strings.ReplaceAll(nick, "{GATEWAY}", gw.Name)
nick = strings.Replace(nick, "{LABEL}", br.GetString("Label"), -1) nick = strings.ReplaceAll(nick, "{LABEL}", br.GetString("Label"))
nick = strings.Replace(nick, "{NICK}", msg.Username, -1) nick = strings.ReplaceAll(nick, "{NICK}", msg.Username)
nick = strings.Replace(nick, "{CHANNEL}", msg.Channel, -1) nick = strings.ReplaceAll(nick, "{USERID}", msg.UserID)
nick = strings.ReplaceAll(nick, "{CHANNEL}", msg.Channel)
tengoNick, err := gw.modifyUsernameTengo(msg, br) tengoNick, err := gw.modifyUsernameTengo(msg, br)
if err != nil { if err != nil {
gw.logger.Errorf("modifyUsernameTengo error: %s", err) gw.logger.Errorf("modifyUsernameTengo error: %s", err)
} }
nick = strings.Replace(nick, "{TENGO}", tengoNick, -1) //nolint:gocritic nick = strings.ReplaceAll(nick, "{TENGO}", tengoNick)
return nick return nick
} }
@@ -363,10 +365,23 @@ func (gw *Gateway) modifyAvatar(msg *config.Message, dest *bridge.Bridge) string
} }
func (gw *Gateway) modifyMessage(msg *config.Message) { func (gw *Gateway) modifyMessage(msg *config.Message) {
if err := modifyMessageTengo(gw.BridgeValues().General.TengoModifyMessage, msg); err != nil { if gw.BridgeValues().General.TengoModifyMessage != "" {
gw.logger.Warnf("General TengoModifyMessage=%s is deprecated and will be removed in v1.20.0, please move to Tengo InMessage=%s", gw.BridgeValues().General.TengoModifyMessage, gw.BridgeValues().General.TengoModifyMessage)
}
if err := modifyInMessageTengo(gw.BridgeValues().General.TengoModifyMessage, msg); err != nil {
gw.logger.Errorf("TengoModifyMessage failed: %s", err) gw.logger.Errorf("TengoModifyMessage failed: %s", err)
} }
if err := modifyMessageTengo(gw.BridgeValues().Tengo.Message, msg); err != nil {
inMessage := gw.BridgeValues().Tengo.InMessage
if inMessage == "" {
inMessage = gw.BridgeValues().Tengo.Message
if inMessage != "" {
gw.logger.Warnf("Tengo Message=%s is deprecated and will be removed in v1.20.0, please move to Tengo InMessage=%s", inMessage, inMessage)
}
}
if err := modifyInMessageTengo(inMessage, msg); err != nil {
gw.logger.Errorf("Tengo.Message failed: %s", err) gw.logger.Errorf("Tengo.Message failed: %s", err)
} }
@@ -416,9 +431,15 @@ func (gw *Gateway) SendMessage(
} }
} }
// Only send irc notices to irc
if msg.Event == config.EventNoticeIRC && dest.Protocol != "irc" {
return "", nil
}
// Too noisy to log like other events // Too noisy to log like other events
debugSendMessage := ""
if msg.Event != config.EventUserTyping { if msg.Event != config.EventUserTyping {
gw.logger.Debugf("=> Sending %#v from %s (%s) to %s (%s)", msg, msg.Account, rmsg.Channel, dest.Account, channel.Name) debugSendMessage = fmt.Sprintf("=> Sending %#v from %s (%s) to %s (%s)", msg, msg.Account, rmsg.Channel, dest.Account, channel.Name)
} }
msg.Channel = channel.Name msg.Channel = channel.Name
@@ -438,22 +459,34 @@ func (gw *Gateway) SendMessage(
} }
// if the parentID is still empty and we have a parentID set in the original message // if the parentID is still empty and we have a parentID set in the original message
// this means that we didn't find it in the cache so set it "msg-parent-not-found" // this means that we didn't find it in the cache so set it to a "msg-parent-not-found" constant
if msg.ParentID == "" && rmsg.ParentID != "" { if msg.ParentID == "" && rmsg.ParentID != "" {
msg.ParentID = "msg-parent-not-found" msg.ParentID = config.ParentIDNotFound
} }
err := gw.modifySendMessageTengo(rmsg, &msg, dest) drop, err := gw.modifyOutMessageTengo(rmsg, &msg, dest)
if err != nil { if err != nil {
gw.logger.Errorf("modifySendMessageTengo: %s", err) gw.logger.Errorf("modifySendMessageTengo: %s", err)
} }
if drop {
gw.logger.Debugf("=> Tengo dropping %#v from %s (%s) to %s (%s)", msg, msg.Account, rmsg.Channel, dest.Account, channel.Name)
return "", nil
}
if debugSendMessage != "" {
gw.logger.Debug(debugSendMessage)
}
// if we are using mattermost plugin account, send messages to MattermostPlugin channel // if we are using mattermost plugin account, send messages to MattermostPlugin channel
// that can be picked up by the mattermost matterbridge plugin // that can be picked up by the mattermost matterbridge plugin
if dest.Account == "mattermost.plugin" { if dest.Account == "mattermost.plugin" {
gw.Router.MattermostPlugin <- msg gw.Router.MattermostPlugin <- msg
} }
defer func(t time.Time) {
gw.logger.Debugf("=> Send from %s (%s) to %s (%s) took %s", msg.Account, rmsg.Channel, dest.Account, channel.Name, time.Since(t))
}(time.Now())
mID, err := dest.Send(msg) mID, err := dest.Send(msg)
if err != nil { if err != nil {
return mID, err return mID, err
@@ -505,7 +538,7 @@ func getProtocol(msg *config.Message) string {
return p[0] return p[0]
} }
func modifyMessageTengo(filename string, msg *config.Message) error { func modifyInMessageTengo(filename string, msg *config.Message) error {
if filename == "" { if filename == "" {
return nil return nil
} }
@@ -517,6 +550,7 @@ func modifyMessageTengo(filename string, msg *config.Message) error {
s.SetImports(stdlib.GetModuleMap(stdlib.AllModuleNames()...)) s.SetImports(stdlib.GetModuleMap(stdlib.AllModuleNames()...))
_ = s.Add("msgText", msg.Text) _ = s.Add("msgText", msg.Text)
_ = s.Add("msgUsername", msg.Username) _ = s.Add("msgUsername", msg.Username)
_ = s.Add("msgUserID", msg.UserID)
_ = s.Add("msgAccount", msg.Account) _ = s.Add("msgAccount", msg.Account)
_ = s.Add("msgChannel", msg.Channel) _ = s.Add("msgChannel", msg.Channel)
c, err := s.Compile() c, err := s.Compile()
@@ -545,6 +579,7 @@ func (gw *Gateway) modifyUsernameTengo(msg *config.Message, br *bridge.Bridge) (
_ = s.Add("result", "") _ = s.Add("result", "")
_ = s.Add("msgText", msg.Text) _ = s.Add("msgText", msg.Text)
_ = s.Add("msgUsername", msg.Username) _ = s.Add("msgUsername", msg.Username)
_ = s.Add("msgUserID", msg.UserID)
_ = s.Add("nick", msg.Username) _ = s.Add("nick", msg.Username)
_ = s.Add("msgAccount", msg.Account) _ = s.Add("msgAccount", msg.Account)
_ = s.Add("msgChannel", msg.Channel) _ = s.Add("msgChannel", msg.Channel)
@@ -564,22 +599,28 @@ func (gw *Gateway) modifyUsernameTengo(msg *config.Message, br *bridge.Bridge) (
return c.Get("result").String(), nil return c.Get("result").String(), nil
} }
func (gw *Gateway) modifySendMessageTengo(origmsg *config.Message, msg *config.Message, br *bridge.Bridge) error { func (gw *Gateway) modifyOutMessageTengo(origmsg *config.Message, msg *config.Message, br *bridge.Bridge) (bool, error) {
filename := gw.BridgeValues().Tengo.OutMessage filename := gw.BridgeValues().Tengo.OutMessage
var res []byte var (
var err error res []byte
err error
drop bool
)
if filename == "" { if filename == "" {
res, err = internal.Asset("tengo/outmessage.tengo") res, err = internal.Asset("tengo/outmessage.tengo")
if err != nil { if err != nil {
return err return drop, err
} }
} else { } else {
res, err = ioutil.ReadFile(filename) res, err = ioutil.ReadFile(filename)
if err != nil { if err != nil {
return err return drop, err
} }
} }
s := tengo.NewScript(res) s := tengo.NewScript(res)
s.SetImports(stdlib.GetModuleMap(stdlib.AllModuleNames()...)) s.SetImports(stdlib.GetModuleMap(stdlib.AllModuleNames()...))
_ = s.Add("inAccount", origmsg.Account) _ = s.Add("inAccount", origmsg.Account)
_ = s.Add("inProtocol", origmsg.Protocol) _ = s.Add("inProtocol", origmsg.Protocol)
@@ -593,14 +634,20 @@ func (gw *Gateway) modifySendMessageTengo(origmsg *config.Message, msg *config.M
_ = s.Add("outEvent", msg.Event) _ = s.Add("outEvent", msg.Event)
_ = s.Add("msgText", msg.Text) _ = s.Add("msgText", msg.Text)
_ = s.Add("msgUsername", msg.Username) _ = s.Add("msgUsername", msg.Username)
_ = s.Add("msgUserID", msg.UserID)
_ = s.Add("msgDrop", drop)
c, err := s.Compile() c, err := s.Compile()
if err != nil { if err != nil {
return err return drop, err
} }
if err := c.Run(); err != nil { if err := c.Run(); err != nil {
return err return drop, err
} }
drop = c.Get("msgDrop").Bool()
msg.Text = c.Get("msgText").String() msg.Text = c.Get("msgText").String()
msg.Username = c.Get("msgUsername").String() msg.Username = c.Get("msgUsername").String()
return nil
return drop, nil
} }
+1 -1
View File
@@ -533,7 +533,7 @@ func (s *ignoreTestSuite) TestIgnoreNicks() {
func BenchmarkTengo(b *testing.B) { func BenchmarkTengo(b *testing.B) {
msg := &config.Message{Username: "user", Text: "blah testing", Account: "protocol.account", Channel: "mychannel"} msg := &config.Message{Username: "user", Text: "blah testing", Account: "protocol.account", Channel: "mychannel"}
for n := 0; n < b.N; n++ { for n := 0; n < b.N; n++ {
err := modifyMessageTengo("bench.tengo", msg) err := modifyInMessageTengo("bench.tengo", msg)
if err != nil { if err != nil {
return return
} }
+1 -1
View File
@@ -160,7 +160,7 @@ func (r *Router) handleReceive() {
// For some bridges we always add/update the message ID. // For some bridges we always add/update the message ID.
// This is necessary as msgIDs will change if a bridge returns // This is necessary as msgIDs will change if a bridge returns
// a different ID in response to edits. // a different ID in response to edits.
if !exists || msg.Protocol == "discord" { if !exists {
gw.Messages.Add(msg.Protocol+" "+msg.ID, msgIDs) gw.Messages.Add(msg.Protocol+" "+msg.ID, msgIDs)
} }
} }
+36 -35
View File
@@ -3,61 +3,62 @@ module github.com/42wim/matterbridge
require ( require (
github.com/42wim/go-gitter v0.0.0-20170828205020-017310c2d557 github.com/42wim/go-gitter v0.0.0-20170828205020-017310c2d557
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f
github.com/Jeffail/gabs v1.1.1 // indirect github.com/Philipp15b/go-steam v1.0.1-0.20200727090957-6ae9b3c0a560
github.com/Philipp15b/go-steam v1.0.1-0.20190816133340-b04c5a83c1c0 github.com/Rhymen/go-whatsapp v0.1.2-0.20201226125722-8029c28f5c5a
github.com/Rhymen/go-whatsapp v0.1.1-0.20200421062035-31e8111ac334 github.com/RocketChat/Rocket.Chat.Go.SDK v0.0.0-20200922220614-e4a51dfb52e4 // indirect
github.com/d5/tengo/v2 v2.6.0 github.com/d5/tengo/v2 v2.6.2
github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew v1.1.1
github.com/fsnotify/fsnotify v1.4.9 github.com/fsnotify/fsnotify v1.4.9
github.com/go-telegram-bot-api/telegram-bot-api v1.0.1-0.20200524105306-7434b0456e81 github.com/go-telegram-bot-api/telegram-bot-api v1.0.1-0.20200524105306-7434b0456e81
github.com/gomarkdown/markdown v0.0.0-20200609195525-3f9352745725 github.com/gomarkdown/markdown v0.0.0-20201113031856-722100d81a8e
github.com/google/gops v0.3.10 github.com/google/gops v0.3.14
github.com/gopackage/ddp v0.0.0-20170117053602-652027933df4 // indirect github.com/gorilla/schema v1.2.0
github.com/gorilla/schema v1.1.0
github.com/gorilla/websocket v1.4.2 github.com/gorilla/websocket v1.4.2
github.com/hashicorp/golang-lru v0.5.4 github.com/hashicorp/golang-lru v0.5.4
github.com/hpcloud/tail v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 github.com/jpillora/backoff v1.0.0
github.com/keybase/go-keybase-chat-bot v0.0.0-20200505163032-5cacf52379da github.com/keybase/go-keybase-chat-bot v0.0.0-20200505163032-5cacf52379da
github.com/labstack/echo/v4 v4.1.16 github.com/labstack/echo/v4 v4.1.17
github.com/lrstanley/girc v0.0.0-20190801035559-4fc93959e1a7 github.com/lrstanley/girc v0.0.0-20190801035559-4fc93959e1a7
github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20200411204219-d5c18ce75048 github.com/matrix-org/gomatrix v0.0.0-20200827122206-7dd5e2a05bcd
github.com/matterbridge/discordgo v0.21.2-0.20200718144317-01fe5db6c78d github.com/matterbridge/Rocket.Chat.Go.SDK v0.0.0-20201206215757-c1d86d75b9f8
github.com/matterbridge/discordgo v0.22.1
github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible github.com/matterbridge/emoji v2.1.1-0.20191117213217-af507f6b02db+incompatible
github.com/matterbridge/go-xmpp v0.0.0-20200418225040-c8a3a57b4050 github.com/matterbridge/go-xmpp v0.0.0-20200418225040-c8a3a57b4050
github.com/matterbridge/gomatrix v0.0.0-20200209224845-c2104d7936a6 github.com/matterbridge/gozulipbot v0.0.0-20200820220548-be5824faa913
github.com/matterbridge/gozulipbot v0.0.0-20190212232658-7aa251978a18
github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba
github.com/mattermost/mattermost-server v5.5.0+incompatible github.com/mattermost/mattermost-server/v5 v5.30.1
github.com/mattn/godown v0.0.0-20200217152941-afc959f6a561 github.com/mattn/godown v0.0.1
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/missdeer/golib v1.0.3 github.com/missdeer/golib v1.0.4
github.com/mitchellh/mapstructure v1.3.3 // indirect
github.com/mreiferson/go-httpclient v0.0.0-20160630210159-31f0106b4474 // indirect github.com/mreiferson/go-httpclient v0.0.0-20160630210159-31f0106b4474 // indirect
github.com/mrexodia/wray v0.0.0-20160318003008-78a2c1f284ff // indirect github.com/mrexodia/wray v0.0.0-20160318003008-78a2c1f284ff // indirect
github.com/nelsonken/gomf v0.0.0-20180504123937-a9dd2f9deae9 github.com/nelsonken/gomf v0.0.0-20180504123937-a9dd2f9deae9
github.com/nicksnyder/go-i18n v1.4.0 // indirect
github.com/onsi/ginkgo v1.6.0 // indirect
github.com/onsi/gomega v1.4.1 // indirect
github.com/paulrosania/go-charset v0.0.0-20190326053356-55c9d7a5834c github.com/paulrosania/go-charset v0.0.0-20190326053356-55c9d7a5834c
github.com/pborman/uuid v0.0.0-20160216163710-c55201b03606 // indirect
github.com/rs/xid v1.2.1 github.com/rs/xid v1.2.1
github.com/russross/blackfriday v1.5.2 github.com/russross/blackfriday v1.6.0
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca
github.com/shazow/ssh-chat v1.8.3-0.20200308224626-80ddf1f43a98 github.com/shazow/ssh-chat v1.10.1
github.com/sirupsen/logrus v1.6.0 github.com/sirupsen/logrus v1.7.0
github.com/slack-go/slack v0.6.5 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
github.com/spf13/viper v1.7.0 github.com/slack-go/slack v0.7.4
github.com/stretchr/testify v1.5.1 github.com/spf13/afero v1.3.4 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.6.1
github.com/vincent-petithory/dataurl v0.0.0-20191104211930-d1553a71de50
github.com/writeas/go-strip-markdown v2.0.1+incompatible github.com/writeas/go-strip-markdown v2.0.1+incompatible
github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect
github.com/yaegashi/msgraph.go v0.1.3 github.com/yaegashi/msgraph.go v0.1.4
github.com/zfjagann/golang-ring v0.0.0-20190304061218-d34796e0a6c2 github.com/zfjagann/golang-ring v0.0.0-20190304061218-d34796e0a6c2
golang.org/x/image v0.0.0-20200618115811-c13761719519 golang.org/x/image v0.0.0-20201208152932-35266b937fa6
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5
gomod.garykim.dev/nc-talk v0.0.1 gomod.garykim.dev/nc-talk v0.1.7
gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect layeh.com/gumble v0.0.0-20200818122324-146f9205029b
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
) )
go 1.13 replace github.com/Rhymen/go-whatsapp => github.com/tulir/go-whatsapp v0.3.16
go 1.15
+1040 -74
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -16,7 +16,7 @@ import (
) )
var ( var (
version = "1.18.0" version = "1.21.1-dev"
githash string githash string
flagConfig = flag.String("conf", "matterbridge.toml", "config file") flagConfig = flag.String("conf", "matterbridge.toml", "config file")
+108 -11
View File
@@ -103,6 +103,12 @@ ColorNicks=false
#OPTIONAL (default empty) #OPTIONAL (default empty)
RunCommands=["PRIVMSG user hello","PRIVMSG chanserv something"] RunCommands=["PRIVMSG user hello","PRIVMSG chanserv something"]
#PingDelay specifies how long to wait to send a ping to the irc server.
#You can use s for second, m for minute
#String
#OPTIONAL (default 1m)
PingDelay="1m"
#StripMarkdown strips markdown from messages #StripMarkdown strips markdown from messages
#OPTIONAL (default false) #OPTIONAL (default false)
StripMarkdown=false StripMarkdown=false
@@ -187,6 +193,19 @@ ShowTopicChange=false
#OPTIONAL (default 0) #OPTIONAL (default 0)
JoinDelay=0 JoinDelay=0
#Use the optional RELAYMSG extension for username spoofing on IRC.
#This requires an IRCd that supports the draft/relaymsg specification: currently this includes
#Oragono 2.4.0+ and InspIRCd 3 with the m_relaymsg contrib module.
#See https://github.com/42wim/matterbridge/issues/667#issuecomment-634214165 for more details.
#Spoofed nicks will use the configured RemoteNickFormat, replacing reserved IRC characters
#(!+%@&#$:'"?*,.) with a hyphen (-).
#On most configurations, the RemoteNickFormat must include a separator character such as "/".
#You should make sure that the settings here match your IRCd.
#This option overrides ColorNicks.
#OPTIONAL (default false)
UseRelayMsg=false
#RemoteNickFormat="{NICK}/{PROTOCOL}"
################################################################### ###################################################################
#XMPP section #XMPP section
################################################################### ###################################################################
@@ -221,6 +240,10 @@ Nick="xmppbot"
#OPTIONAL (default false) #OPTIONAL (default false)
SkipTLSVerify=true SkipTLSVerify=true
#Enable to use plaintext connection to your XMPP server.
#OPTIONAL (default false)
NoTLS=true
## RELOADABLE SETTINGS ## RELOADABLE SETTINGS
## Settings below can be reloaded by editing the file ## Settings below can be reloaded by editing the file
@@ -287,6 +310,11 @@ StripNick=false
#OPTIONAL (default false) #OPTIONAL (default false)
ShowTopicChange=false ShowTopicChange=false
#Enable sending messages using a webhook instead of regular MUC messages.
#Only works with a prosody server using mod_slack_webhook. Does not support editing.
#OPTIONAL (default "")
WebhookURL="https://yourdomain/prosody/msg/someid"
################################################################### ###################################################################
#mattermost section #mattermost section
################################################################### ###################################################################
@@ -836,10 +864,11 @@ UseUserName=false
# UseDiscriminator appends the `#xxxx` discriminator when used with UseUserName # UseDiscriminator appends the `#xxxx` discriminator when used with UseUserName
UseDiscriminator=false UseDiscriminator=false
# WebhookURL sends messages in the style of puppets. # AutoWebhooks automatically configures message sending in the style of puppets.
# This only works if you have one discord channel, if you have multiple discord channels you'll have to specify it in the gateway config # This is an easier alternative to manually configuring "WebhookURL" for each gateway,
# Example: "https://discordapp.com/api/webhooks/1234/abcd_xyzw" # as turning this on will automatically load or create webhooks for each channel.
WebhookURL="" # This feature requires the "Manage Webhooks" permission (either globally or as per-channel).
AutoWebhooks=false
# EditDisable disables sending of edits to other bridges # EditDisable disables sending of edits to other bridges
EditDisable=false EditDisable=false
@@ -1221,6 +1250,9 @@ HTMLDisable=false
## RELOADABLE SETTINGS ## RELOADABLE SETTINGS
## Settings below can be reloaded by editing the file ## Settings below can be reloaded by editing the file
# UseUserName shows the username instead of the server nickname
UseUserName=false
#Whether to prefix messages from other bridges to matrix with the sender's nick. #Whether to prefix messages from other bridges to matrix with the sender's nick.
#Useful if username overrides for incoming webhooks isn't enabled on the #Useful if username overrides for incoming webhooks isn't enabled on the
#matrix server. If you set PrefixMessagesWithNick to true, each message #matrix server. If you set PrefixMessagesWithNick to true, each message
@@ -1394,12 +1426,66 @@ ShowTopicChange=false
# Url of your Nextcloud server # Url of your Nextcloud server
Server = "https://cloud.youdomain.me" Server = "https://cloud.youdomain.me"
# Enable to not verify the certificate on your Nextcloud server.
# e.g. when using selfsigned certificates
# OPTIONAL (default false)
SkipTLSVerify=true
# Username of the bot # Username of the bot
Login = "talkuser" Login = "talkuser"
# Password of the bot # Password of the bot
Password = "talkuserpass" Password = "talkuserpass"
# Suffix for Guest Users
GuestSuffix = " (Guest)"
###################################################################
#
# Mumble
#
###################################################################
[mumble.bridge]
# Host and port of your Mumble server
Server = "mumble.yourdomain.me:64738"
# Nickname to log in as
Nick = "matterbridge"
# Some servers require a password
# OPTIONAL (default empty)
Password = "serverpasswordhere"
# User comment to set on the Mumble user, visible to other users.
# OPTIONAL (default empty)
UserComment="I am bridging text messages between this channel and #general on irc.yourdomain.me"
# Self-signed TLS client certificate + private key used to connect to
# Mumble. This is required if you want to register the matterbridge
# user on your Mumble server, so its nick becomes reserved.
# You can generate a keypair using e.g.
#
# openssl req -x509 -newkey rsa:2048 -nodes -days 10000 \
# -keyout mumble.key -out mumble.crt
#
# To actually register the matterbridege user, connect to Mumble as an
# admin, right click on the user and click "Register".
#
# OPTIONAL (default empty)
TLSClientCertificate="mumble.crt"
TLSClientKey="mumble.key"
# TLS CA certificate used to validate the Mumble server.
# OPTIONAL (defaults to Go system CA)
TLSCACertificate=mumble-ca.crt
# Enable to not verify the certificate on your Mumble server.
# e.g. when using selfsigned certificates
# OPTIONAL (default false)
SkipTLSVerify=false
################################################################### ###################################################################
# #
# WhatsApp # WhatsApp
@@ -1540,6 +1626,8 @@ Buffer=1000
#Bearer token used for authentication #Bearer token used for authentication
#curl -H "Authorization: Bearer token" http://localhost:4242/api/messages #curl -H "Authorization: Bearer token" http://localhost:4242/api/messages
# https://github.com/vi/websocat
# websocat -H="Authorization: Bearer token" ws://127.0.0.1:4242/api/websocket
#OPTIONAL (no authorization if token is empty) #OPTIONAL (no authorization if token is empty)
Token="mytoken" Token="mytoken"
@@ -1563,7 +1651,8 @@ RemoteNickFormat="{NICK}"
## Settings below can be reloaded by editing the file ## Settings below can be reloaded by editing the file
#RemoteNickFormat defines how remote users appear on this bridge #RemoteNickFormat defines how remote users appear on this bridge
#The string "{NICK}" (case sensitive) will be replaced by the actual nick / username. #The string "{NICK}" (case sensitive) will be replaced by the actual nick.
#The string "{USERID}" (case sensitive) will be replaced by the user ID.
#The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge #The string "{BRIDGE}" (case sensitive) will be replaced by the sending bridge
#The string "{LABEL}" (case sensitive) will be replaced by label= field of the sending bridge #The string "{LABEL}" (case sensitive) will be replaced by label= field of the sending bridge
#The string "{PROTOCOL}" (case sensitive) will be replaced by the protocol used by the bridge #The string "{PROTOCOL}" (case sensitive) will be replaced by the protocol used by the bridge
@@ -1625,7 +1714,7 @@ IgnoreFailureOnStart=false
#writing, or if the value is empty. Note that the log won't roll, so #writing, or if the value is empty. Note that the log won't roll, so
#you might want to use logrotate(8) with this feature. #you might want to use logrotate(8) with this feature.
#OPTIONAL (default empty) #OPTIONAL (default empty)
LogFile=/var/log/matterbridge.log LogFile="/var/log/matterbridge.log"
################################################################### ###################################################################
#Tengo configuration #Tengo configuration
@@ -1638,7 +1727,7 @@ LogFile=/var/log/matterbridge.log
#This script will receive every incoming message and can be used to modify the Username and the Text of that message. #This script will receive every incoming message and can be used to modify the Username and the Text of that message.
#The script will have the following global variables: #The script will have the following global variables:
#to modify: msgUsername and msgText #to modify: msgUsername and msgText
#to read: msgChannel and msgAccount #to read: msgUserID, msgChannel, msgAccount
# #
#The script is reloaded on every message, so you can modify the script on the fly. #The script is reloaded on every message, so you can modify the script on the fly.
# #
@@ -1662,9 +1751,12 @@ InMessage="example.tengo"
#read-only: #read-only:
#inAccount, inProtocol, inChannel, inGateway, inEvent #inAccount, inProtocol, inChannel, inGateway, inEvent
#outAccount, outProtocol, outChannel, outGateway, outEvent #outAccount, outProtocol, outChannel, outGateway, outEvent
#msgUserID
# #
#read-write: #read-write:
#msgText, msgUsername #msgText, msgUsername, msgDrop
#
#msgDrop is a bool which is default false, when set true this message will be dropped
# #
#The script is reloaded on every message, so you can modify the script on the fly. #The script is reloaded on every message, so you can modify the script on the fly.
# #
@@ -1677,7 +1769,7 @@ OutMessage="example.tengo"
#RemoteNickFormat allows you to specify the location of a tengo (https://github.com/d5/tengo/) script. #RemoteNickFormat allows you to specify the location of a tengo (https://github.com/d5/tengo/) script.
#The script will have the following global variables: #The script will have the following global variables:
#to modify: result #to modify: result
#to read: channel, bridge, gateway, protocol, nick #to read: channel, bridge, gateway, protocol, nick, msgUserID
# #
#The result will be set in {TENGO} in the RemoteNickFormat key of every bridge where {TENGO} is specified #The result will be set in {TENGO} in the RemoteNickFormat key of every bridge where {TENGO} is specified
# #
@@ -1738,6 +1830,8 @@ enable=true
# ------------------------------------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------------------------------------
# msteams | threadId | 19:82abcxx@thread.skype | You'll find the threadId in the URL # msteams | threadId | 19:82abcxx@thread.skype | You'll find the threadId in the URL
# ------------------------------------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------------------------------------
# mumble | channel id | 42 | The channel ID, as shown in the channel's "Edit" window
# -------------------------------------------------------------------------------------------------------------------------------------
# rocketchat | channel | #channel | # is required for private channels too # rocketchat | channel | #channel | # is required for private channels too
# ------------------------------------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------------------------------------
# slack | channel name | general | Do not include the # symbol # slack | channel name | general | Do not include the # symbol
@@ -1788,13 +1882,16 @@ enable=true
#OPTIONAL - your irc / xmpp channel key #OPTIONAL - your irc / xmpp channel key
key="yourkey" key="yourkey"
# Discord specific gateway options
[[gateway.inout]] [[gateway.inout]]
account="discord.game" account="discord.game"
channel="mygreatgame" channel="mygreatgame"
#OPTIONAL - webhookurl only works for discord (it needs a different URL for each cahnnel)
[gateway.inout.options] [gateway.inout.options]
webhookurl="https://discordapp.com/api/webhooks/123456789123456789/C9WPqExYWONPDZabcdef-def1434FGFjstasJX9pYht73y" # WebhookURL sends messages in the style of "puppets". You must configure a webhook URL for each channel you want to bridge.
# If you have more than one channel and don't wnat to configure each channel manually, see the "AutoWebhooks" option in the gateway config.
# Example: "https://discord.com/api/webhooks/1234/abcd_xyzw"
WebhookURL=""
[[gateway.inout]] [[gateway.inout]]
account="zulip.streamchat" account="zulip.streamchat"
+2 -2
View File
@@ -4,7 +4,7 @@ import (
"errors" "errors"
"strings" "strings"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/v5/model"
) )
// GetChannels returns all channels we're members off // GetChannels returns all channels we're members off
@@ -167,7 +167,7 @@ func (m *MMClient) JoinChannel(channelId string) error { //nolint:golint
} }
func (m *MMClient) UpdateChannelsTeam(teamID string) error { func (m *MMClient) UpdateChannelsTeam(teamID string) error {
mmchannels, resp := m.Client.GetChannelsForTeamForUser(teamID, m.User.Id, "") mmchannels, resp := m.Client.GetChannelsForTeamForUser(teamID, m.User.Id, false, "")
if resp.Error != nil { if resp.Error != nil {
return errors.New(resp.Error.DetailedError) return errors.New(resp.Error.DetailedError)
} }
+2 -2
View File
@@ -13,7 +13,7 @@ import (
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/jpillora/backoff" "github.com/jpillora/backoff"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/v5/model"
) )
func (m *MMClient) doLogin(firstConnection bool, b *backoff.Backoff) error { func (m *MMClient) doLogin(firstConnection bool, b *backoff.Backoff) error {
@@ -154,7 +154,7 @@ func (m *MMClient) initUser() error {
t := &Team{Team: team, Users: usermap, Id: team.Id} t := &Team{Team: team, Users: usermap, Id: team.Id}
mmchannels, resp := m.Client.GetChannelsForTeamForUser(team.Id, m.User.Id, "") mmchannels, resp := m.Client.GetChannelsForTeamForUser(team.Id, m.User.Id, false, "")
if resp.Error != nil { if resp.Error != nil {
return resp.Error return resp.Error
} }
+10 -1
View File
@@ -11,7 +11,7 @@ import (
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
"github.com/jpillora/backoff" "github.com/jpillora/backoff"
prefixed "github.com/matterbridge/logrus-prefixed-formatter" prefixed "github.com/matterbridge/logrus-prefixed-formatter"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/v5/model"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@@ -69,6 +69,7 @@ type MMClient struct {
logger *logrus.Entry logger *logrus.Entry
rootLogger *logrus.Logger rootLogger *logrus.Logger
lruCache *lru.Cache lruCache *lru.Cache
allevents bool
} }
// New will instantiate a new Matterclient with the specified login details without connecting. // New will instantiate a new Matterclient with the specified login details without connecting.
@@ -119,6 +120,10 @@ func (m *MMClient) SetLogLevel(level string) {
} }
} }
func (m *MMClient) EnableAllEvents() {
m.allevents = true
}
// Login tries to connect the client with the loging details with which it was initialized. // Login tries to connect the client with the loging details with which it was initialized.
func (m *MMClient) Login() error { func (m *MMClient) Login() error {
// check if this is a first connect or a reconnection // check if this is a first connect or a reconnection
@@ -220,6 +225,10 @@ func (m *MMClient) WsReceiver() {
continue continue
} }
} }
if m.allevents {
m.MessageChan <- msg
continue
}
switch msg.Raw.Event { switch msg.Raw.Event {
case model.WEBSOCKET_EVENT_USER_ADDED, case model.WEBSOCKET_EVENT_USER_ADDED,
model.WEBSOCKET_EVENT_USER_REMOVED, model.WEBSOCKET_EVENT_USER_REMOVED,
+1 -1
View File
@@ -3,7 +3,7 @@ package matterclient
import ( import (
"strings" "strings"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/v5/model"
) )
func (m *MMClient) parseActionPost(rmsg *Message) { func (m *MMClient) parseActionPost(rmsg *Message) {
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"errors" "errors"
"time" "time"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/v5/model"
) )
func (m *MMClient) GetNickName(userId string) string { //nolint:golint func (m *MMClient) GetNickName(userId string) string { //nolint:golint
+38
View File
@@ -0,0 +1,38 @@
FROM alpine AS builder
COPY . /go/src/github.com/42wim/matterbridge
RUN apk add \
go \
git \
gcc \
musl-dev \
&& cd /go/src/github.com/42wim/matterbridge \
&& export GOPATH=/go \
&& go get \
&& go build -x -ldflags "-X main.githash=$(git log --pretty=format:'%h' -n 1)" -o /bin/matterbridge
FROM alpine
RUN apk --no-cache add \
ca-certificates \
cairo \
libjpeg-turbo \
mailcap \
py3-webencodings \
python3 \
&& apk --no-cache add --virtual .compile \
gcc \
libffi-dev \
libjpeg-turbo-dev \
musl-dev \
py3-pip \
py3-wheel \
python3-dev \
zlib-dev \
&& pip3 install --no-cache-dir lottie[PNG] \
&& apk --no-cache del .compile
COPY --from=builder /bin/matterbridge /bin/matterbridge
RUN mkdir /etc/matterbridge \
&& touch /etc/matterbridge/matterbridge.toml \
&& ln -sf /matterbridge.toml /etc/matterbridge/matterbridge.toml
ENTRYPOINT ["/bin/matterbridge", "-conf", "/etc/matterbridge/matterbridge.toml"]
+26 -51
View File
@@ -7,21 +7,17 @@ It does nothing spectacular except for being fabulous.
https://godoc.org/github.com/Jeffail/gabs https://godoc.org/github.com/Jeffail/gabs
## How to install: ## Install
``` bash ``` bash
go get github.com/Jeffail/gabs go get github.com/Jeffail/gabs
``` ```
## How to use ## Use
### Parsing and searching JSON ### Parsing and searching JSON
``` go ``` go
...
import "github.com/Jeffail/gabs"
jsonParsed, err := gabs.ParseJSON([]byte(`{ jsonParsed, err := gabs.ParseJSON([]byte(`{
"outter":{ "outter":{
"inner":{ "inner":{
@@ -29,7 +25,10 @@ jsonParsed, err := gabs.ParseJSON([]byte(`{
"value2":22 "value2":22
}, },
"alsoInner":{ "alsoInner":{
"value1":20 "value1":20,
"array1":[
30, 40
]
} }
} }
}`)) }`))
@@ -43,26 +42,26 @@ value, ok = jsonParsed.Path("outter.inner.value1").Data().(float64)
value, ok = jsonParsed.Search("outter", "inner", "value1").Data().(float64) value, ok = jsonParsed.Search("outter", "inner", "value1").Data().(float64)
// value == 10.0, ok == true // value == 10.0, ok == true
gObj, err := jsonParsed.JSONPointer("/outter/alsoInner/array1/1")
if err != nil {
panic(err)
}
value, ok = gObj.Data().(float64)
// value == 40.0, ok == true
value, ok = jsonParsed.Path("does.not.exist").Data().(float64) value, ok = jsonParsed.Path("does.not.exist").Data().(float64)
// value == 0.0, ok == false // value == 0.0, ok == false
exists := jsonParsed.Exists("outter", "inner", "value1") exists := jsonParsed.Exists("outter", "inner", "value1")
// exists == true // exists == true
exists := jsonParsed.Exists("does", "not", "exist")
// exists == false
exists := jsonParsed.ExistsP("does.not.exist") exists := jsonParsed.ExistsP("does.not.exist")
// exists == false // exists == false
...
``` ```
### Iterating objects ### Iterating objects
``` go ``` go
...
jsonParsed, _ := gabs.ParseJSON([]byte(`{"object":{ "first": 1, "second": 2, "third": 3 }}`)) jsonParsed, _ := gabs.ParseJSON([]byte(`{"object":{ "first": 1, "second": 2, "third": 3 }}`))
// S is shorthand for Search // S is shorthand for Search
@@ -70,24 +69,25 @@ children, _ := jsonParsed.S("object").ChildrenMap()
for key, child := range children { for key, child := range children {
fmt.Printf("key: %v, value: %v\n", key, child.Data().(string)) fmt.Printf("key: %v, value: %v\n", key, child.Data().(string))
} }
...
``` ```
### Iterating arrays ### Iterating arrays
``` go ``` go
... jsonParsed, err := gabs.ParseJSON([]byte(`{"array":[ "first", "second", "third" ]}`))
if err != nil {
jsonParsed, _ := gabs.ParseJSON([]byte(`{"array":[ "first", "second", "third" ]}`)) panic(err)
}
// S is shorthand for Search // S is shorthand for Search
children, _ := jsonParsed.S("array").Children() children, err := jsonParsed.S("array").Children()
if err != nil {
panic(err)
}
for _, child := range children { for _, child := range children {
fmt.Println(child.Data().(string)) fmt.Println(child.Data().(string))
} }
...
``` ```
Will print: Will print:
@@ -108,12 +108,11 @@ objects within the array, this returns a JSON array containing the results for
each element. each element.
``` go ``` go
... jsonParsed, err := gabs.ParseJSON([]byte(`{"array":[ {"value":1}, {"value":2}, {"value":3} ]}`))
if err != nil {
jsonParsed, _ := gabs.ParseJSON([]byte(`{"array":[ {"value":1}, {"value":2}, {"value":3} ]}`)) panic(err)
}
fmt.Println(jsonParsed.Path("array.value").String()) fmt.Println(jsonParsed.Path("array.value").String())
...
``` ```
Will print: Will print:
@@ -125,8 +124,6 @@ Will print:
### Generating JSON ### Generating JSON
``` go ``` go
...
jsonObj := gabs.New() jsonObj := gabs.New()
// or gabs.Consume(jsonObject) to work on an existing map[string]interface{} // or gabs.Consume(jsonObject) to work on an existing map[string]interface{}
@@ -135,8 +132,6 @@ jsonObj.SetP(20, "outter.inner.value2")
jsonObj.Set(30, "outter", "inner2", "value3") jsonObj.Set(30, "outter", "inner2", "value3")
fmt.Println(jsonObj.String()) fmt.Println(jsonObj.String())
...
``` ```
Will print: Will print:
@@ -148,11 +143,7 @@ Will print:
To pretty-print: To pretty-print:
``` go ``` go
...
fmt.Println(jsonObj.StringIndent("", " ")) fmt.Println(jsonObj.StringIndent("", " "))
...
``` ```
Will print: Will print:
@@ -174,8 +165,6 @@ Will print:
### Generating Arrays ### Generating Arrays
``` go ``` go
...
jsonObj := gabs.New() jsonObj := gabs.New()
jsonObj.Array("foo", "array") jsonObj.Array("foo", "array")
@@ -186,8 +175,6 @@ jsonObj.ArrayAppend(20, "foo", "array")
jsonObj.ArrayAppend(30, "foo", "array") jsonObj.ArrayAppend(30, "foo", "array")
fmt.Println(jsonObj.String()) fmt.Println(jsonObj.String())
...
``` ```
Will print: Will print:
@@ -199,8 +186,6 @@ Will print:
Working with arrays by index: Working with arrays by index:
``` go ``` go
...
jsonObj := gabs.New() jsonObj := gabs.New()
// Create an array with the length of 3 // Create an array with the length of 3
@@ -217,8 +202,6 @@ jsonObj.S("foo").Index(2).SetIndex(2, 1)
jsonObj.S("foo").Index(2).SetIndex(3, 2) jsonObj.S("foo").Index(2).SetIndex(3, 2)
fmt.Println(jsonObj.String()) fmt.Println(jsonObj.String())
...
``` ```
Will print: Will print:
@@ -232,8 +215,6 @@ Will print:
This is the easiest part: This is the easiest part:
``` go ``` go
...
jsonParsedObj, _ := gabs.ParseJSON([]byte(`{ jsonParsedObj, _ := gabs.ParseJSON([]byte(`{
"outter":{ "outter":{
"values":{ "values":{
@@ -246,15 +227,11 @@ jsonParsedObj, _ := gabs.ParseJSON([]byte(`{
jsonOutput := jsonParsedObj.String() jsonOutput := jsonParsedObj.String()
// Becomes `{"outter":{"values":{"first":10,"second":11}},"outter2":"hello world"}` // Becomes `{"outter":{"values":{"first":10,"second":11}},"outter2":"hello world"}`
...
``` ```
And to serialize a specific segment is as simple as: And to serialize a specific segment is as simple as:
``` go ``` go
...
jsonParsedObj := gabs.ParseJSON([]byte(`{ jsonParsedObj := gabs.ParseJSON([]byte(`{
"outter":{ "outter":{
"values":{ "values":{
@@ -267,8 +244,6 @@ jsonParsedObj := gabs.ParseJSON([]byte(`{
jsonOutput := jsonParsedObj.Search("outter").String() jsonOutput := jsonParsedObj.Search("outter").String()
// Becomes `{"values":{"first":10,"second":11}}` // Becomes `{"values":{"first":10,"second":11}}`
...
``` ```
### Merge two containers ### Merge two containers
+245 -99
View File
@@ -20,58 +20,85 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
*/ */
// Package gabs implements a simplified wrapper around creating and parsing JSON. // Package gabs implements a simplified wrapper around creating and parsing
// unknown or dynamic JSON.
package gabs package gabs
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"strconv"
"strings" "strings"
) )
//-------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------
var ( var (
// ErrOutOfBounds - Index out of bounds. // ErrOutOfBounds indicates an index was out of bounds.
ErrOutOfBounds = errors.New("out of bounds") ErrOutOfBounds = errors.New("out of bounds")
// ErrNotObjOrArray - The target is not an object or array type. // ErrNotObjOrArray is returned when a target is not an object or array type
// but needs to be for the intended operation.
ErrNotObjOrArray = errors.New("not an object or array") ErrNotObjOrArray = errors.New("not an object or array")
// ErrNotObj - The target is not an object type. // ErrNotObj is returned when a target is not an object but needs to be for
// the intended operation.
ErrNotObj = errors.New("not an object") ErrNotObj = errors.New("not an object")
// ErrNotArray - The target is not an array type. // ErrNotArray is returned when a target is not an array but needs to be for
// the intended operation.
ErrNotArray = errors.New("not an array") ErrNotArray = errors.New("not an array")
// ErrPathCollision - Creating a path failed because an element collided with an existing value. // ErrPathCollision is returned when creating a path failed because an
// element collided with an existing value.
ErrPathCollision = errors.New("encountered value collision whilst building path") ErrPathCollision = errors.New("encountered value collision whilst building path")
// ErrInvalidInputObj - The input value was not a map[string]interface{}. // ErrInvalidInputObj is returned when the input value was not a
// map[string]interface{}.
ErrInvalidInputObj = errors.New("invalid input object") ErrInvalidInputObj = errors.New("invalid input object")
// ErrInvalidInputText - The input data could not be parsed. // ErrInvalidInputText is returned when the input data could not be parsed.
ErrInvalidInputText = errors.New("input text could not be parsed") ErrInvalidInputText = errors.New("input text could not be parsed")
// ErrInvalidPath - The filepath was not valid. // ErrInvalidPath is returned when the filepath was not valid.
ErrInvalidPath = errors.New("invalid file path") ErrInvalidPath = errors.New("invalid file path")
// ErrInvalidBuffer - The input buffer contained an invalid JSON string // ErrInvalidBuffer is returned when the input buffer contained an invalid
// JSON string.
ErrInvalidBuffer = errors.New("input buffer contained invalid JSON") ErrInvalidBuffer = errors.New("input buffer contained invalid JSON")
) )
//-------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Container - an internal structure that holds a reference to the core interface map of the parsed func resolveJSONPointerHierarchy(path string) ([]string, error) {
// json. Use this container to move context. if len(path) < 1 {
return nil, errors.New("failed to resolve JSON pointer: path must not be empty")
}
if path[0] != '/' {
return nil, errors.New("failed to resolve JSON pointer: path must begin with '/'")
}
hierarchy := strings.Split(path, "/")[1:]
for i, v := range hierarchy {
v = strings.Replace(v, "~1", "/", -1)
v = strings.Replace(v, "~0", "~", -1)
hierarchy[i] = v
}
return hierarchy, nil
}
//------------------------------------------------------------------------------
// Container references a specific element within a JSON structure.
type Container struct { type Container struct {
object interface{} object interface{}
} }
// Data - Return the contained data as an interface{}. // Data returns the underlying interface{} of the target element in the JSON
// structure.
func (g *Container) Data() interface{} { func (g *Container) Data() interface{} {
if g == nil { if g == nil {
return nil return nil
@@ -79,17 +106,18 @@ func (g *Container) Data() interface{} {
return g.object return g.object
} }
//-------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Path - Search for a value using dot notation. // Path searches the JSON structure following a path in dot notation.
func (g *Container) Path(path string) *Container { func (g *Container) Path(path string) *Container {
return g.Search(strings.Split(path, ".")...) return g.Search(strings.Split(path, ".")...)
} }
// Search - Attempt to find and return an object within the JSON structure by specifying the // Search attempts to find and return an object within the JSON structure by
// hierarchy of field names to locate the target. If the search encounters an array and has not // following a provided hierarchy of field names to locate the target. If the
// reached the end target then it will iterate each object of the array for the target and return // search encounters an array and has not reached the end target then it will
// all of the results in a JSON array. // iterate each object of the array for the target and return all of the results
// in a JSON array.
func (g *Container) Search(hierarchy ...string) *Container { func (g *Container) Search(hierarchy ...string) *Container {
var object interface{} var object interface{}
@@ -120,22 +148,55 @@ func (g *Container) Search(hierarchy ...string) *Container {
return &Container{object} return &Container{object}
} }
// S - Shorthand method, does the same thing as Search. // JSONPointer parses a JSON pointer path (https://tools.ietf.org/html/rfc6901)
// and either returns a *gabs.Container containing the result or an error if the
// referenced item could not be found.
func (g *Container) JSONPointer(path string) (*Container, error) {
hierarchy, err := resolveJSONPointerHierarchy(path)
if err != nil {
return nil, err
}
object := g.Data()
for target := 0; target < len(hierarchy); target++ {
pathSeg := hierarchy[target]
if mmap, ok := object.(map[string]interface{}); ok {
object, ok = mmap[pathSeg]
if !ok {
return nil, fmt.Errorf("failed to resolve JSON pointer: index '%v' value '%v' was not found", target, pathSeg)
}
} else if marray, ok := object.([]interface{}); ok {
index, err := strconv.Atoi(pathSeg)
if err != nil {
return nil, fmt.Errorf("failed to resolve JSON pointer: could not parse index '%v' value '%v' into array index: %v", target, pathSeg, err)
}
if len(marray) <= index {
return nil, fmt.Errorf("failed to resolve JSON pointer: index '%v' value '%v' exceeded target array size of '%v'", target, pathSeg, len(marray))
}
object = marray[index]
} else {
return &Container{nil}, fmt.Errorf("failed to resolve JSON pointer: index '%v' field '%v' was not found", target, pathSeg)
}
}
return &Container{object}, nil
}
// S is a shorthand alias for Search.
func (g *Container) S(hierarchy ...string) *Container { func (g *Container) S(hierarchy ...string) *Container {
return g.Search(hierarchy...) return g.Search(hierarchy...)
} }
// Exists - Checks whether a path exists. // Exists checks whether a path exists.
func (g *Container) Exists(hierarchy ...string) bool { func (g *Container) Exists(hierarchy ...string) bool {
return g.Search(hierarchy...) != nil return g.Search(hierarchy...) != nil
} }
// ExistsP - Checks whether a dot notation path exists. // ExistsP checks whether a dot notation path exists.
func (g *Container) ExistsP(path string) bool { func (g *Container) ExistsP(path string) bool {
return g.Exists(strings.Split(path, ".")...) return g.Exists(strings.Split(path, ".")...)
} }
// Index - Attempt to find and return an object within a JSON array by index. // Index attempts to find and return an element within a JSON array by an index.
func (g *Container) Index(index int) *Container { func (g *Container) Index(index int) *Container {
if array, ok := g.Data().([]interface{}); ok { if array, ok := g.Data().([]interface{}); ok {
if index >= len(array) { if index >= len(array) {
@@ -146,9 +207,9 @@ func (g *Container) Index(index int) *Container {
return &Container{nil} return &Container{nil}
} }
// Children - Return a slice of all the children of the array. This also works for objects, however, // Children returns a slice of all children of an array element. This also works
// the children returned for an object will NOT be in order and you lose the names of the returned // for objects, however, the children returned for an object will be in a random
// objects this way. // order and you lose the names of the returned objects this way.
func (g *Container) Children() ([]*Container, error) { func (g *Container) Children() ([]*Container, error) {
if array, ok := g.Data().([]interface{}); ok { if array, ok := g.Data().([]interface{}); ok {
children := make([]*Container, len(array)) children := make([]*Container, len(array))
@@ -167,7 +228,7 @@ func (g *Container) Children() ([]*Container, error) {
return nil, ErrNotObjOrArray return nil, ErrNotObjOrArray
} }
// ChildrenMap - Return a map of all the children of an object. // ChildrenMap returns a map of all the children of an object element.
func (g *Container) ChildrenMap() (map[string]*Container, error) { func (g *Container) ChildrenMap() (map[string]*Container, error) {
if mmap, ok := g.Data().(map[string]interface{}); ok { if mmap, ok := g.Data().(map[string]interface{}); ok {
children := map[string]*Container{} children := map[string]*Container{}
@@ -179,11 +240,11 @@ func (g *Container) ChildrenMap() (map[string]*Container, error) {
return nil, ErrNotObj return nil, ErrNotObj
} }
//-------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Set - Set the value of a field at a JSON path, any parts of the path that do not exist will be // Set the value of a field at a JSON path, any parts of the path that do not
// constructed, and if a collision occurs with a non object type whilst iterating the path an error // exist will be constructed, and if a collision occurs with a non object type
// is returned. // whilst iterating the path an error is returned.
func (g *Container) Set(value interface{}, path ...string) (*Container, error) { func (g *Container) Set(value interface{}, path ...string) (*Container, error) {
if len(path) == 0 { if len(path) == 0 {
g.object = value g.object = value
@@ -209,12 +270,14 @@ func (g *Container) Set(value interface{}, path ...string) (*Container, error) {
return &Container{object}, nil return &Container{object}, nil
} }
// SetP - Does the same as Set, but using a dot notation JSON path. // SetP sets the value of a field at a JSON path using dot notation, any parts
// of the path that do not exist will be constructed, and if a collision occurs
// with a non object type whilst iterating the path an error is returned.
func (g *Container) SetP(value interface{}, path string) (*Container, error) { func (g *Container) SetP(value interface{}, path string) (*Container, error) {
return g.Set(value, strings.Split(path, ".")...) return g.Set(value, strings.Split(path, ".")...)
} }
// SetIndex - Set a value of an array element based on the index. // SetIndex attempts to set a value of an array element based on an index.
func (g *Container) SetIndex(value interface{}, index int) (*Container, error) { func (g *Container) SetIndex(value interface{}, index int) (*Container, error) {
if array, ok := g.Data().([]interface{}); ok { if array, ok := g.Data().([]interface{}); ok {
if index >= len(array) { if index >= len(array) {
@@ -226,60 +289,112 @@ func (g *Container) SetIndex(value interface{}, index int) (*Container, error) {
return &Container{nil}, ErrNotArray return &Container{nil}, ErrNotArray
} }
// Object - Create a new JSON object at a path. Returns an error if the path contains a collision // SetJSONPointer parses a JSON pointer path
// with a non object type. // (https://tools.ietf.org/html/rfc6901) and sets the leaf to a value. Returns
// an error if the pointer could not be resolved due to missing fields.
func (g *Container) SetJSONPointer(value interface{}, path string) error {
hierarchy, err := resolveJSONPointerHierarchy(path)
if err != nil {
return err
}
if len(hierarchy) == 0 {
g.object = value
return nil
}
object := g.object
for target := 0; target < len(hierarchy); target++ {
pathSeg := hierarchy[target]
if mmap, ok := object.(map[string]interface{}); ok {
if target == len(hierarchy)-1 {
object = value
mmap[pathSeg] = object
} else if object = mmap[pathSeg]; object == nil {
return fmt.Errorf("failed to resolve JSON pointer: index '%v' value '%v' was not found", target, pathSeg)
}
} else if marray, ok := object.([]interface{}); ok {
index, err := strconv.Atoi(pathSeg)
if err != nil {
return fmt.Errorf("failed to resolve JSON pointer: could not parse index '%v' value '%v' into array index: %v", target, pathSeg, err)
}
if len(marray) <= index {
return fmt.Errorf("failed to resolve JSON pointer: index '%v' value '%v' exceeded target array size of '%v'", target, pathSeg, len(marray))
}
if target == len(hierarchy)-1 {
object = value
marray[index] = object
} else if object = marray[index]; object == nil {
return fmt.Errorf("failed to resolve JSON pointer: index '%v' value '%v' was not found", target, pathSeg)
}
} else {
return fmt.Errorf("failed to resolve JSON pointer: index '%v' value '%v' was not found", target, pathSeg)
}
}
return nil
}
// Object creates a new JSON object at a target path. Returns an error if the
// path contains a collision with a non object type.
func (g *Container) Object(path ...string) (*Container, error) { func (g *Container) Object(path ...string) (*Container, error) {
return g.Set(map[string]interface{}{}, path...) return g.Set(map[string]interface{}{}, path...)
} }
// ObjectP - Does the same as Object, but using a dot notation JSON path. // ObjectP creates a new JSON object at a target path using dot notation.
// Returns an error if the path contains a collision with a non object type.
func (g *Container) ObjectP(path string) (*Container, error) { func (g *Container) ObjectP(path string) (*Container, error) {
return g.Object(strings.Split(path, ".")...) return g.Object(strings.Split(path, ".")...)
} }
// ObjectI - Create a new JSON object at an array index. Returns an error if the object is not an // ObjectI creates a new JSON object at an array index. Returns an error if the
// array or the index is out of bounds. // object is not an array or the index is out of bounds.
func (g *Container) ObjectI(index int) (*Container, error) { func (g *Container) ObjectI(index int) (*Container, error) {
return g.SetIndex(map[string]interface{}{}, index) return g.SetIndex(map[string]interface{}{}, index)
} }
// Array - Create a new JSON array at a path. Returns an error if the path contains a collision with // Array creates a new JSON array at a path. Returns an error if the path
// a non object type. // contains a collision with a non object type.
func (g *Container) Array(path ...string) (*Container, error) { func (g *Container) Array(path ...string) (*Container, error) {
return g.Set([]interface{}{}, path...) return g.Set([]interface{}{}, path...)
} }
// ArrayP - Does the same as Array, but using a dot notation JSON path. // ArrayP creates a new JSON array at a path using dot notation. Returns an
// error if the path contains a collision with a non object type.
func (g *Container) ArrayP(path string) (*Container, error) { func (g *Container) ArrayP(path string) (*Container, error) {
return g.Array(strings.Split(path, ".")...) return g.Array(strings.Split(path, ".")...)
} }
// ArrayI - Create a new JSON array at an array index. Returns an error if the object is not an // ArrayI creates a new JSON array within an array at an index. Returns an error
// array or the index is out of bounds. // if the element is not an array or the index is out of bounds.
func (g *Container) ArrayI(index int) (*Container, error) { func (g *Container) ArrayI(index int) (*Container, error) {
return g.SetIndex([]interface{}{}, index) return g.SetIndex([]interface{}{}, index)
} }
// ArrayOfSize - Create a new JSON array of a particular size at a path. Returns an error if the // ArrayOfSize creates a new JSON array of a particular size at a path. Returns
// path contains a collision with a non object type. // an error if the path contains a collision with a non object type.
func (g *Container) ArrayOfSize(size int, path ...string) (*Container, error) { func (g *Container) ArrayOfSize(size int, path ...string) (*Container, error) {
a := make([]interface{}, size) a := make([]interface{}, size)
return g.Set(a, path...) return g.Set(a, path...)
} }
// ArrayOfSizeP - Does the same as ArrayOfSize, but using a dot notation JSON path. // ArrayOfSizeP creates a new JSON array of a particular size at a path using
// dot notation. Returns an error if the path contains a collision with a non
// object type.
func (g *Container) ArrayOfSizeP(size int, path string) (*Container, error) { func (g *Container) ArrayOfSizeP(size int, path string) (*Container, error) {
return g.ArrayOfSize(size, strings.Split(path, ".")...) return g.ArrayOfSize(size, strings.Split(path, ".")...)
} }
// ArrayOfSizeI - Create a new JSON array of a particular size at an array index. Returns an error // ArrayOfSizeI create a new JSON array of a particular size within an array at
// if the object is not an array or the index is out of bounds. // an index. Returns an error if the element is not an array or the index is out
// of bounds.
func (g *Container) ArrayOfSizeI(size, index int) (*Container, error) { func (g *Container) ArrayOfSizeI(size, index int) (*Container, error) {
a := make([]interface{}, size) a := make([]interface{}, size)
return g.SetIndex(a, index) return g.SetIndex(a, index)
} }
// Delete - Delete an element at a JSON path, an error is returned if the element does not exist. // Delete an element at a path, an error is returned if the element does not
// exist.
func (g *Container) Delete(path ...string) error { func (g *Container) Delete(path ...string) error {
var object interface{} var object interface{}
@@ -304,45 +419,40 @@ func (g *Container) Delete(path ...string) error {
return nil return nil
} }
// DeleteP - Does the same as Delete, but using a dot notation JSON path. // DeleteP deletes an element at a path using dot notation, an error is returned
// if the element does not exist.
func (g *Container) DeleteP(path string) error { func (g *Container) DeleteP(path string) error {
return g.Delete(strings.Split(path, ".")...) return g.Delete(strings.Split(path, ".")...)
} }
// Merge - Merges two gabs-containers // MergeFn merges two objects using a provided function to resolve collisions.
func (g *Container) Merge(toMerge *Container) error { //
// The collision function receives two interface{} arguments, destination (the
// original object) and source (the object being merged into the destination).
// Which ever value is returned becomes the new value in the destination object
// at the location of the collision.
func (g *Container) MergeFn(source *Container, collisionFn func(destination, source interface{}) interface{}) error {
var recursiveFnc func(map[string]interface{}, []string) error var recursiveFnc func(map[string]interface{}, []string) error
recursiveFnc = func(mmap map[string]interface{}, path []string) error { recursiveFnc = func(mmap map[string]interface{}, path []string) error {
for key, value := range mmap { for key, value := range mmap {
newPath := append(path, key) newPath := append(path, key)
if g.Exists(newPath...) { if g.Exists(newPath...) {
target := g.Search(newPath...) existingData := g.Search(newPath...).Data()
switch t := value.(type) { switch t := value.(type) {
case map[string]interface{}: case map[string]interface{}:
switch targetV := target.Data().(type) { switch existingVal := existingData.(type) {
case map[string]interface{}: case map[string]interface{}:
if err := recursiveFnc(t, newPath); err != nil { if err := recursiveFnc(t, newPath); err != nil {
return err return err
} }
case []interface{}:
g.Set(append(targetV, t), newPath...)
default: default:
newSlice := append([]interface{}{}, targetV) if _, err := g.Set(collisionFn(existingVal, t), newPath...); err != nil {
g.Set(append(newSlice, t), newPath...)
}
case []interface{}:
for _, valueOfSlice := range t {
if err := g.ArrayAppend(valueOfSlice, newPath...); err != nil {
return err return err
} }
} }
default: default:
switch targetV := target.Data().(type) { if _, err := g.Set(collisionFn(existingData, t), newPath...); err != nil {
case []interface{}: return err
g.Set(append(targetV, t), newPath...)
default:
newSlice := append([]interface{}{}, targetV)
g.Set(append(newSlice, t), newPath...)
} }
} }
} else { } else {
@@ -354,21 +464,48 @@ func (g *Container) Merge(toMerge *Container) error {
} }
return nil return nil
} }
if mmap, ok := toMerge.Data().(map[string]interface{}); ok { if mmap, ok := source.Data().(map[string]interface{}); ok {
return recursiveFnc(mmap, []string{}) return recursiveFnc(mmap, []string{})
} }
return nil return nil
} }
//-------------------------------------------------------------------------------------------------- // Merge a source object into an existing destination object. When a collision
// is found within the merged structures (both a source and destination object
// contain the same non-object keys) the result will be an array containing both
// values, where values that are already arrays will be expanded into the
// resulting array.
//
// It is possible to merge structures will different collision behaviours with
// MergeFn.
func (g *Container) Merge(source *Container) error {
return g.MergeFn(source, func(dest, source interface{}) interface{} {
destArr, destIsArray := dest.([]interface{})
sourceArr, sourceIsArray := source.([]interface{})
if destIsArray {
if sourceIsArray {
return append(destArr, sourceArr...)
}
return append(destArr, source)
}
if sourceIsArray {
return append(append([]interface{}{}, dest), sourceArr...)
}
return []interface{}{dest, source}
})
}
//------------------------------------------------------------------------------
/* /*
Array modification/search - Keeping these options simple right now, no need for anything more Array modification/search - Keeping these options simple right now, no need for
complicated since you can just cast to []interface{}, modify and then reassign with Set. anything more complicated since you can just cast to []interface{}, modify and
then reassign with Set.
*/ */
// ArrayAppend - Append a value onto a JSON array. If the target is not a JSON array then it will be // ArrayAppend attempts to append a value onto a JSON array at a path. If the
// converted into one, with its contents as the first element of the array. // target is not a JSON array then it will be converted into one, with its
// original contents set to the first element of the array.
func (g *Container) ArrayAppend(value interface{}, path ...string) error { func (g *Container) ArrayAppend(value interface{}, path ...string) error {
if array, ok := g.Search(path...).Data().([]interface{}); ok { if array, ok := g.Search(path...).Data().([]interface{}); ok {
array = append(array, value) array = append(array, value)
@@ -386,12 +523,15 @@ func (g *Container) ArrayAppend(value interface{}, path ...string) error {
return err return err
} }
// ArrayAppendP - Append a value onto a JSON array using a dot notation JSON path. // ArrayAppendP attempts to append a value onto a JSON array at a path using dot
// notation. If the target is not a JSON array then it will be converted into
// one, with its original contents set to the first element of the array.
func (g *Container) ArrayAppendP(value interface{}, path string) error { func (g *Container) ArrayAppendP(value interface{}, path string) error {
return g.ArrayAppend(value, strings.Split(path, ".")...) return g.ArrayAppend(value, strings.Split(path, ".")...)
} }
// ArrayRemove - Remove an element from a JSON array. // ArrayRemove attempts to remove an element identified by an index from a JSON
// array at a path.
func (g *Container) ArrayRemove(index int, path ...string) error { func (g *Container) ArrayRemove(index int, path ...string) error {
if index < 0 { if index < 0 {
return ErrOutOfBounds return ErrOutOfBounds
@@ -409,12 +549,14 @@ func (g *Container) ArrayRemove(index int, path ...string) error {
return err return err
} }
// ArrayRemoveP - Remove an element from a JSON array using a dot notation JSON path. // ArrayRemoveP attempts to remove an element identified by an index from a JSON
// array at a path using dot notation.
func (g *Container) ArrayRemoveP(index int, path string) error { func (g *Container) ArrayRemoveP(index int, path string) error {
return g.ArrayRemove(index, strings.Split(path, ".")...) return g.ArrayRemove(index, strings.Split(path, ".")...)
} }
// ArrayElement - Access an element from a JSON array. // ArrayElement attempts to access an element by an index from a JSON array at a
// path.
func (g *Container) ArrayElement(index int, path ...string) (*Container, error) { func (g *Container) ArrayElement(index int, path ...string) (*Container, error) {
if index < 0 { if index < 0 {
return &Container{nil}, ErrOutOfBounds return &Container{nil}, ErrOutOfBounds
@@ -429,12 +571,13 @@ func (g *Container) ArrayElement(index int, path ...string) (*Container, error)
return &Container{nil}, ErrOutOfBounds return &Container{nil}, ErrOutOfBounds
} }
// ArrayElementP - Access an element from a JSON array using a dot notation JSON path. // ArrayElementP attempts to access an element by an index from a JSON array at
// a path using dot notation.
func (g *Container) ArrayElementP(index int, path string) (*Container, error) { func (g *Container) ArrayElementP(index int, path string) (*Container, error) {
return g.ArrayElement(index, strings.Split(path, ".")...) return g.ArrayElement(index, strings.Split(path, ".")...)
} }
// ArrayCount - Count the number of elements in a JSON array. // ArrayCount counts the number of elements in a JSON array at a path.
func (g *Container) ArrayCount(path ...string) (int, error) { func (g *Container) ArrayCount(path ...string) (int, error) {
if array, ok := g.Search(path...).Data().([]interface{}); ok { if array, ok := g.Search(path...).Data().([]interface{}); ok {
return len(array), nil return len(array), nil
@@ -442,14 +585,15 @@ func (g *Container) ArrayCount(path ...string) (int, error) {
return 0, ErrNotArray return 0, ErrNotArray
} }
// ArrayCountP - Count the number of elements in a JSON array using a dot notation JSON path. // ArrayCountP counts the number of elements in a JSON array at a path using dot
// notation.
func (g *Container) ArrayCountP(path string) (int, error) { func (g *Container) ArrayCountP(path string) (int, error) {
return g.ArrayCount(strings.Split(path, ".")...) return g.ArrayCount(strings.Split(path, ".")...)
} }
//-------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------
// Bytes - Converts the contained object back to a JSON []byte blob. // Bytes marshals an element to a JSON []byte blob.
func (g *Container) Bytes() []byte { func (g *Container) Bytes() []byte {
if g.Data() != nil { if g.Data() != nil {
if bytes, err := json.Marshal(g.object); err == nil { if bytes, err := json.Marshal(g.object); err == nil {
@@ -459,7 +603,8 @@ func (g *Container) Bytes() []byte {
return []byte("{}") return []byte("{}")
} }
// BytesIndent - Converts the contained object to a JSON []byte blob formatted with prefix, indent. // BytesIndent marshals an element to a JSON []byte blob formatted with a prefix
// and indent string.
func (g *Container) BytesIndent(prefix string, indent string) []byte { func (g *Container) BytesIndent(prefix string, indent string) []byte {
if g.object != nil { if g.object != nil {
if bytes, err := json.MarshalIndent(g.object, prefix, indent); err == nil { if bytes, err := json.MarshalIndent(g.object, prefix, indent); err == nil {
@@ -469,12 +614,13 @@ func (g *Container) BytesIndent(prefix string, indent string) []byte {
return []byte("{}") return []byte("{}")
} }
// String - Converts the contained object to a JSON formatted string. // String marshals an element to a JSON formatted string.
func (g *Container) String() string { func (g *Container) String() string {
return string(g.Bytes()) return string(g.Bytes())
} }
// StringIndent - Converts the contained object back to a JSON formatted string with prefix, indent. // StringIndent marshals an element to a JSON string formatted with a prefix and
// indent string.
func (g *Container) StringIndent(prefix string, indent string) string { func (g *Container) StringIndent(prefix string, indent string) string {
return string(g.BytesIndent(prefix, indent)) return string(g.BytesIndent(prefix, indent))
} }
@@ -496,10 +642,9 @@ func EncodeOptIndent(prefix string, indent string) EncodeOpt {
} }
} }
// EncodeJSON - Encodes the contained object back to a JSON formatted []byte // EncodeJSON marshals an element to a JSON formatted []byte using a variant
// using a variant list of modifier functions for the encoder being used. // list of modifier functions for the encoder being used. Functions for
// Functions for modifying the output are prefixed with EncodeOpt, e.g. // modifying the output are prefixed with EncodeOpt, e.g. EncodeOptHTMLEscape.
// EncodeOptHTMLEscape.
func (g *Container) EncodeJSON(encodeOpts ...EncodeOpt) []byte { func (g *Container) EncodeJSON(encodeOpts ...EncodeOpt) []byte {
var b bytes.Buffer var b bytes.Buffer
encoder := json.NewEncoder(&b) encoder := json.NewEncoder(&b)
@@ -517,17 +662,18 @@ func (g *Container) EncodeJSON(encodeOpts ...EncodeOpt) []byte {
return result return result
} }
// New - Create a new gabs JSON object. // New creates a new gabs JSON object.
func New() *Container { func New() *Container {
return &Container{map[string]interface{}{}} return &Container{map[string]interface{}{}}
} }
// Consume - Gobble up an already converted JSON object, or a fresh map[string]interface{} object. // Consume an already unmarshalled JSON object (or a new map[string]interface{})
// into a *Container.
func Consume(root interface{}) (*Container, error) { func Consume(root interface{}) (*Container, error) {
return &Container{root}, nil return &Container{root}, nil
} }
// ParseJSON - Convert a string into a representation of the parsed JSON. // ParseJSON unmarshals a JSON byte slice into a *Container.
func ParseJSON(sample []byte) (*Container, error) { func ParseJSON(sample []byte) (*Container, error) {
var gabs Container var gabs Container
@@ -538,7 +684,7 @@ func ParseJSON(sample []byte) (*Container, error) {
return &gabs, nil return &gabs, nil
} }
// ParseJSONDecoder - Convert a json.Decoder into a representation of the parsed JSON. // ParseJSONDecoder applies a json.Decoder to a *Container.
func ParseJSONDecoder(decoder *json.Decoder) (*Container, error) { func ParseJSONDecoder(decoder *json.Decoder) (*Container, error) {
var gabs Container var gabs Container
@@ -549,7 +695,7 @@ func ParseJSONDecoder(decoder *json.Decoder) (*Container, error) {
return &gabs, nil return &gabs, nil
} }
// ParseJSONFile - Read a file and convert into a representation of the parsed JSON. // ParseJSONFile reads a file and unmarshals the contents into a *Container.
func ParseJSONFile(path string) (*Container, error) { func ParseJSONFile(path string) (*Container, error) {
if len(path) > 0 { if len(path) > 0 {
cBytes, err := ioutil.ReadFile(path) cBytes, err := ioutil.ReadFile(path)
@@ -567,7 +713,7 @@ func ParseJSONFile(path string) (*Container, error) {
return nil, ErrInvalidPath return nil, ErrInvalidPath
} }
// ParseJSONBuffer - Read the contents of a buffer into a representation of the parsed JSON. // ParseJSONBuffer reads a buffer and unmarshals the contents into a *Container.
func ParseJSONBuffer(buffer io.Reader) (*Container, error) { func ParseJSONBuffer(buffer io.Reader) (*Container, error) {
var gabs Container var gabs Container
jsonDecoder := json.NewDecoder(buffer) jsonDecoder := json.NewDecoder(buffer)
@@ -578,4 +724,4 @@ func ParseJSONBuffer(buffer io.Reader) (*Container, error) {
return &gabs, nil return &gabs, nil
} }
//-------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------
+1
View File
@@ -0,0 +1 @@
module github.com/Jeffail/gabs
+4 -1
View File
@@ -1,3 +1,6 @@
[submodule "generator/SteamKit"] [submodule "generator/SteamKit"]
path = generator/SteamKit path = generator/SteamKit
url = https://github.com/Philipp15b/SteamKit.git url = https://github.com/SteamRE/SteamKit.git
[submodule "generator/Protobufs"]
path = generator/Protobufs
url = https://github.com/SteamDatabase/Protobufs.git
+2 -2
View File
@@ -119,7 +119,7 @@ func (a *Auth) handleLogOnResponse(packet *Packet) {
ExtendedResult: EResult(body.GetEresultExtended()), ExtendedResult: EResult(body.GetEresultExtended()),
OutOfGameSecsPerHeartbeat: body.GetOutOfGameHeartbeatSeconds(), OutOfGameSecsPerHeartbeat: body.GetOutOfGameHeartbeatSeconds(),
InGameSecsPerHeartbeat: body.GetInGameHeartbeatSeconds(), InGameSecsPerHeartbeat: body.GetInGameHeartbeatSeconds(),
PublicIp: body.GetPublicIp(), PublicIp: body.GetDeprecatedPublicIp(),
ServerTime: body.GetRtime32ServerTime(), ServerTime: body.GetRtime32ServerTime(),
AccountFlags: EAccountFlags(body.GetAccountFlags()), AccountFlags: EAccountFlags(body.GetAccountFlags()),
ClientSteamId: SteamId(body.GetClientSuppliedSteamid()), ClientSteamId: SteamId(body.GetClientSuppliedSteamid()),
@@ -127,7 +127,7 @@ func (a *Auth) handleLogOnResponse(packet *Packet) {
CellId: body.GetCellId(), CellId: body.GetCellId(),
CellIdPingThreshold: body.GetCellIdPingThreshold(), CellIdPingThreshold: body.GetCellIdPingThreshold(),
Steam2Ticket: body.GetSteam2Ticket(), Steam2Ticket: body.GetSteam2Ticket(),
UsePics: body.GetUsePics(), UsePics: body.GetDeprecatedUsePics(),
WebApiUserNonce: body.GetWebapiAuthenticateUserNonce(), WebApiUserNonce: body.GetWebapiAuthenticateUserNonce(),
IpCountryCode: body.GetIpCountryCode(), IpCountryCode: body.GetIpCountryCode(),
VanityUrl: body.GetVanityUrl(), VanityUrl: body.GetVanityUrl(),
+8
View File
@@ -0,0 +1,8 @@
module github.com/Philipp15b/go-steam
go 1.14
require (
github.com/davecgh/go-spew v1.1.1
github.com/golang/protobuf v1.4.2
)
+22
View File
@@ -0,0 +1,22 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
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 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
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.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+17 -15
View File
@@ -21,11 +21,11 @@ var _ = math.Inf
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type EncryptedAppTicket struct { type EncryptedAppTicket struct {
TicketVersionNo *uint32 `protobuf:"varint,1,opt,name=ticket_version_no" json:"ticket_version_no,omitempty"` TicketVersionNo *uint32 `protobuf:"varint,1,opt,name=ticket_version_no,json=ticketVersionNo" json:"ticket_version_no,omitempty"`
CrcEncryptedticket *uint32 `protobuf:"varint,2,opt,name=crc_encryptedticket" json:"crc_encryptedticket,omitempty"` CrcEncryptedticket *uint32 `protobuf:"varint,2,opt,name=crc_encryptedticket,json=crcEncryptedticket" json:"crc_encryptedticket,omitempty"`
CbEncrypteduserdata *uint32 `protobuf:"varint,3,opt,name=cb_encrypteduserdata" json:"cb_encrypteduserdata,omitempty"` CbEncrypteduserdata *uint32 `protobuf:"varint,3,opt,name=cb_encrypteduserdata,json=cbEncrypteduserdata" json:"cb_encrypteduserdata,omitempty"`
CbEncryptedAppownershipticket *uint32 `protobuf:"varint,4,opt,name=cb_encrypted_appownershipticket" json:"cb_encrypted_appownershipticket,omitempty"` CbEncryptedAppownershipticket *uint32 `protobuf:"varint,4,opt,name=cb_encrypted_appownershipticket,json=cbEncryptedAppownershipticket" json:"cb_encrypted_appownershipticket,omitempty"`
EncryptedTicket []byte `protobuf:"bytes,5,opt,name=encrypted_ticket" json:"encrypted_ticket,omitempty"` EncryptedTicket []byte `protobuf:"bytes,5,opt,name=encrypted_ticket,json=encryptedTicket" json:"encrypted_ticket,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -98,16 +98,18 @@ func init() {
func init() { proto.RegisterFile("encrypted_app_ticket.proto", fileDescriptor_c6d69fd1cac4e8d5) } func init() { proto.RegisterFile("encrypted_app_ticket.proto", fileDescriptor_c6d69fd1cac4e8d5) }
var fileDescriptor_c6d69fd1cac4e8d5 = []byte{ var fileDescriptor_c6d69fd1cac4e8d5 = []byte{
// 164 bytes of a gzipped FileDescriptorProto // 202 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4a, 0xcd, 0x4b, 0x2e, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x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, 0xd5, 0x42, 0xc9, 0x45, 0xc9, 0xae, 0xa8, 0x32, 0x42, 0x86, 0x5c, 0x22, 0xc9,
0xf2, 0xc8, 0xb2, 0x20, 0xd7, 0xe4, 0x97, 0xe7, 0xa5, 0x16, 0x15, 0x67, 0x64, 0x16, 0x40, 0x8d, 0x49, 0x08, 0xf5, 0xa5, 0xc5, 0xa9, 0x45, 0x29, 0x89, 0x25, 0x89, 0x12, 0xcc, 0x60, 0x1d, 0xc2,
0x61, 0x01, 0x2b, 0x94, 0xe0, 0x12, 0x40, 0xa8, 0x82, 0xca, 0xb0, 0x2a, 0x30, 0x6a, 0xf0, 0x38, 0xc9, 0x49, 0xae, 0xe8, 0x52, 0x42, 0x6e, 0x5c, 0xf2, 0xc8, 0x5a, 0x40, 0xfe, 0xc8, 0x2f, 0xcf,
0xb1, 0x7a, 0x30, 0x36, 0x30, 0x32, 0x00, 0x02, 0x00, 0x00, 0xff, 0xff, 0x03, 0x8c, 0xdb, 0x92, 0x4b, 0x2d, 0x2a, 0xce, 0xc8, 0x2c, 0x80, 0xda, 0xc7, 0x02, 0xd6, 0x2d, 0x8b, 0xa4, 0xdb, 0x11,
0xd3, 0x00, 0x00, 0x00, 0x43, 0x91, 0x90, 0x26, 0x97, 0x00, 0xc2, 0x10, 0xa8, 0x46, 0x56, 0x05, 0x46, 0x0d, 0x9e, 0x20,
0x7e, 0xb8, 0x38, 0x24, 0x08, 0x9c, 0x58, 0x3d, 0x18, 0x1b, 0x18, 0x19, 0x00, 0x01, 0x00, 0x00,
0xff, 0xff, 0xe8, 0x03, 0x98, 0x21, 0x3d, 0x01, 0x00, 0x00,
} }
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -22,10 +22,10 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type CMsgClientFriendMsg struct { type CMsgClientFriendMsg struct {
Steamid *uint64 `protobuf:"fixed64,1,opt,name=steamid" json:"steamid,omitempty"` Steamid *uint64 `protobuf:"fixed64,1,opt,name=steamid" json:"steamid,omitempty"`
ChatEntryType *int32 `protobuf:"varint,2,opt,name=chat_entry_type" json:"chat_entry_type,omitempty"` ChatEntryType *int32 `protobuf:"varint,2,opt,name=chat_entry_type,json=chatEntryType" json:"chat_entry_type,omitempty"`
Message []byte `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"` Message []byte `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"`
Rtime32ServerTimestamp *uint32 `protobuf:"fixed32,4,opt,name=rtime32_server_timestamp" json:"rtime32_server_timestamp,omitempty"` Rtime32ServerTimestamp *uint32 `protobuf:"fixed32,4,opt,name=rtime32_server_timestamp,json=rtime32ServerTimestamp" json:"rtime32_server_timestamp,omitempty"`
EchoToSender *bool `protobuf:"varint,5,opt,name=echo_to_sender" json:"echo_to_sender,omitempty"` EchoToSender *bool `protobuf:"varint,5,opt,name=echo_to_sender,json=echoToSender" json:"echo_to_sender,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -92,11 +92,11 @@ func (m *CMsgClientFriendMsg) GetEchoToSender() bool {
} }
type CMsgClientFriendMsgIncoming struct { type CMsgClientFriendMsgIncoming struct {
SteamidFrom *uint64 `protobuf:"fixed64,1,opt,name=steamid_from" json:"steamid_from,omitempty"` SteamidFrom *uint64 `protobuf:"fixed64,1,opt,name=steamid_from,json=steamidFrom" json:"steamid_from,omitempty"`
ChatEntryType *int32 `protobuf:"varint,2,opt,name=chat_entry_type" json:"chat_entry_type,omitempty"` ChatEntryType *int32 `protobuf:"varint,2,opt,name=chat_entry_type,json=chatEntryType" json:"chat_entry_type,omitempty"`
FromLimitedAccount *bool `protobuf:"varint,3,opt,name=from_limited_account" json:"from_limited_account,omitempty"` FromLimitedAccount *bool `protobuf:"varint,3,opt,name=from_limited_account,json=fromLimitedAccount" json:"from_limited_account,omitempty"`
Message []byte `protobuf:"bytes,4,opt,name=message" json:"message,omitempty"` Message []byte `protobuf:"bytes,4,opt,name=message" json:"message,omitempty"`
Rtime32ServerTimestamp *uint32 `protobuf:"fixed32,5,opt,name=rtime32_server_timestamp" json:"rtime32_server_timestamp,omitempty"` Rtime32ServerTimestamp *uint32 `protobuf:"fixed32,5,opt,name=rtime32_server_timestamp,json=rtime32ServerTimestamp" json:"rtime32_server_timestamp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -163,8 +163,8 @@ func (m *CMsgClientFriendMsgIncoming) GetRtime32ServerTimestamp() uint32 {
} }
type CMsgClientAddFriend struct { type CMsgClientAddFriend struct {
SteamidToAdd *uint64 `protobuf:"fixed64,1,opt,name=steamid_to_add" json:"steamid_to_add,omitempty"` SteamidToAdd *uint64 `protobuf:"fixed64,1,opt,name=steamid_to_add,json=steamidToAdd" json:"steamid_to_add,omitempty"`
AccountnameOrEmailToAdd *string `protobuf:"bytes,2,opt,name=accountname_or_email_to_add" json:"accountname_or_email_to_add,omitempty"` AccountnameOrEmailToAdd *string `protobuf:"bytes,2,opt,name=accountname_or_email_to_add,json=accountnameOrEmailToAdd" json:"accountname_or_email_to_add,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -211,8 +211,8 @@ func (m *CMsgClientAddFriend) GetAccountnameOrEmailToAdd() string {
type CMsgClientAddFriendResponse struct { type CMsgClientAddFriendResponse struct {
Eresult *int32 `protobuf:"varint,1,opt,name=eresult,def=2" json:"eresult,omitempty"` Eresult *int32 `protobuf:"varint,1,opt,name=eresult,def=2" json:"eresult,omitempty"`
SteamIdAdded *uint64 `protobuf:"fixed64,2,opt,name=steam_id_added" json:"steam_id_added,omitempty"` SteamIdAdded *uint64 `protobuf:"fixed64,2,opt,name=steam_id_added,json=steamIdAdded" json:"steam_id_added,omitempty"`
PersonaNameAdded *string `protobuf:"bytes,3,opt,name=persona_name_added" json:"persona_name_added,omitempty"` PersonaNameAdded *string `protobuf:"bytes,3,opt,name=persona_name_added,json=personaNameAdded" json:"persona_name_added,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -355,9 +355,9 @@ func (m *CMsgClientHideFriend) GetHide() bool {
type CMsgClientFriendsList struct { type CMsgClientFriendsList struct {
Bincremental *bool `protobuf:"varint,1,opt,name=bincremental" json:"bincremental,omitempty"` Bincremental *bool `protobuf:"varint,1,opt,name=bincremental" json:"bincremental,omitempty"`
Friends []*CMsgClientFriendsList_Friend `protobuf:"bytes,2,rep,name=friends" json:"friends,omitempty"` Friends []*CMsgClientFriendsList_Friend `protobuf:"bytes,2,rep,name=friends" json:"friends,omitempty"`
MaxFriendCount *uint32 `protobuf:"varint,3,opt,name=max_friend_count" json:"max_friend_count,omitempty"` MaxFriendCount *uint32 `protobuf:"varint,3,opt,name=max_friend_count,json=maxFriendCount" json:"max_friend_count,omitempty"`
ActiveFriendCount *uint32 `protobuf:"varint,4,opt,name=active_friend_count" json:"active_friend_count,omitempty"` ActiveFriendCount *uint32 `protobuf:"varint,4,opt,name=active_friend_count,json=activeFriendCount" json:"active_friend_count,omitempty"`
FriendsLimitHit *bool `protobuf:"varint,5,opt,name=friends_limit_hit" json:"friends_limit_hit,omitempty"` FriendsLimitHit *bool `protobuf:"varint,5,opt,name=friends_limit_hit,json=friendsLimitHit" json:"friends_limit_hit,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -826,7 +826,7 @@ func (m *CMsgClientSetPlayerNicknameResponse) GetEresult() uint32 {
} }
type CMsgClientRequestFriendData struct { type CMsgClientRequestFriendData struct {
PersonaStateRequested *uint32 `protobuf:"varint,1,opt,name=persona_state_requested" json:"persona_state_requested,omitempty"` PersonaStateRequested *uint32 `protobuf:"varint,1,opt,name=persona_state_requested,json=personaStateRequested" json:"persona_state_requested,omitempty"`
Friends []uint64 `protobuf:"fixed64,2,rep,name=friends" json:"friends,omitempty"` Friends []uint64 `protobuf:"fixed64,2,rep,name=friends" json:"friends,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
@@ -873,14 +873,14 @@ func (m *CMsgClientRequestFriendData) GetFriends() []uint64 {
} }
type CMsgClientChangeStatus struct { type CMsgClientChangeStatus struct {
PersonaState *uint32 `protobuf:"varint,1,opt,name=persona_state" json:"persona_state,omitempty"` PersonaState *uint32 `protobuf:"varint,1,opt,name=persona_state,json=personaState" json:"persona_state,omitempty"`
PlayerName *string `protobuf:"bytes,2,opt,name=player_name" json:"player_name,omitempty"` PlayerName *string `protobuf:"bytes,2,opt,name=player_name,json=playerName" json:"player_name,omitempty"`
IsAutoGeneratedName *bool `protobuf:"varint,3,opt,name=is_auto_generated_name" json:"is_auto_generated_name,omitempty"` IsAutoGeneratedName *bool `protobuf:"varint,3,opt,name=is_auto_generated_name,json=isAutoGeneratedName" json:"is_auto_generated_name,omitempty"`
HighPriority *bool `protobuf:"varint,4,opt,name=high_priority" json:"high_priority,omitempty"` HighPriority *bool `protobuf:"varint,4,opt,name=high_priority,json=highPriority" json:"high_priority,omitempty"`
PersonaSetByUser *bool `protobuf:"varint,5,opt,name=persona_set_by_user" json:"persona_set_by_user,omitempty"` PersonaSetByUser *bool `protobuf:"varint,5,opt,name=persona_set_by_user,json=personaSetByUser" json:"persona_set_by_user,omitempty"`
PersonaStateFlags *uint32 `protobuf:"varint,6,opt,name=persona_state_flags,def=0" json:"persona_state_flags,omitempty"` PersonaStateFlags *uint32 `protobuf:"varint,6,opt,name=persona_state_flags,json=personaStateFlags,def=0" json:"persona_state_flags,omitempty"`
NeedPersonaResponse *bool `protobuf:"varint,7,opt,name=need_persona_response" json:"need_persona_response,omitempty"` NeedPersonaResponse *bool `protobuf:"varint,7,opt,name=need_persona_response,json=needPersonaResponse" json:"need_persona_response,omitempty"`
IsClientIdle *bool `protobuf:"varint,8,opt,name=is_client_idle" json:"is_client_idle,omitempty"` IsClientIdle *bool `protobuf:"varint,8,opt,name=is_client_idle,json=isClientIdle" json:"is_client_idle,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -971,7 +971,7 @@ func (m *CMsgClientChangeStatus) GetIsClientIdle() bool {
type CMsgPersonaChangeResponse struct { type CMsgPersonaChangeResponse struct {
Result *uint32 `protobuf:"varint,1,opt,name=result" json:"result,omitempty"` Result *uint32 `protobuf:"varint,1,opt,name=result" json:"result,omitempty"`
PlayerName *string `protobuf:"bytes,2,opt,name=player_name" json:"player_name,omitempty"` PlayerName *string `protobuf:"bytes,2,opt,name=player_name,json=playerName" json:"player_name,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -1017,7 +1017,7 @@ func (m *CMsgPersonaChangeResponse) GetPlayerName() string {
} }
type CMsgClientPersonaState struct { type CMsgClientPersonaState struct {
StatusFlags *uint32 `protobuf:"varint,1,opt,name=status_flags" json:"status_flags,omitempty"` StatusFlags *uint32 `protobuf:"varint,1,opt,name=status_flags,json=statusFlags" json:"status_flags,omitempty"`
Friends []*CMsgClientPersonaState_Friend `protobuf:"bytes,2,rep,name=friends" json:"friends,omitempty"` Friends []*CMsgClientPersonaState_Friend `protobuf:"bytes,2,rep,name=friends" json:"friends,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
@@ -1065,34 +1065,33 @@ func (m *CMsgClientPersonaState) GetFriends() []*CMsgClientPersonaState_Friend {
type CMsgClientPersonaState_Friend struct { type CMsgClientPersonaState_Friend struct {
Friendid *uint64 `protobuf:"fixed64,1,opt,name=friendid" json:"friendid,omitempty"` Friendid *uint64 `protobuf:"fixed64,1,opt,name=friendid" json:"friendid,omitempty"`
PersonaState *uint32 `protobuf:"varint,2,opt,name=persona_state" json:"persona_state,omitempty"` PersonaState *uint32 `protobuf:"varint,2,opt,name=persona_state,json=personaState" json:"persona_state,omitempty"`
GamePlayedAppId *uint32 `protobuf:"varint,3,opt,name=game_played_app_id" json:"game_played_app_id,omitempty"` GamePlayedAppId *uint32 `protobuf:"varint,3,opt,name=game_played_app_id,json=gamePlayedAppId" json:"game_played_app_id,omitempty"`
GameServerIp *uint32 `protobuf:"varint,4,opt,name=game_server_ip" json:"game_server_ip,omitempty"` GameServerIp *uint32 `protobuf:"varint,4,opt,name=game_server_ip,json=gameServerIp" json:"game_server_ip,omitempty"`
GameServerPort *uint32 `protobuf:"varint,5,opt,name=game_server_port" json:"game_server_port,omitempty"` GameServerPort *uint32 `protobuf:"varint,5,opt,name=game_server_port,json=gameServerPort" json:"game_server_port,omitempty"`
PersonaStateFlags *uint32 `protobuf:"varint,6,opt,name=persona_state_flags" json:"persona_state_flags,omitempty"` PersonaStateFlags *uint32 `protobuf:"varint,6,opt,name=persona_state_flags,json=personaStateFlags" json:"persona_state_flags,omitempty"`
OnlineSessionInstances *uint32 `protobuf:"varint,7,opt,name=online_session_instances" json:"online_session_instances,omitempty"` OnlineSessionInstances *uint32 `protobuf:"varint,7,opt,name=online_session_instances,json=onlineSessionInstances" json:"online_session_instances,omitempty"`
PublishedInstanceId *uint32 `protobuf:"varint,8,opt,name=published_instance_id" json:"published_instance_id,omitempty"` PersonaSetByUser *bool `protobuf:"varint,10,opt,name=persona_set_by_user,json=personaSetByUser" json:"persona_set_by_user,omitempty"`
PersonaSetByUser *bool `protobuf:"varint,10,opt,name=persona_set_by_user" json:"persona_set_by_user,omitempty"` PlayerName *string `protobuf:"bytes,15,opt,name=player_name,json=playerName" json:"player_name,omitempty"`
PlayerName *string `protobuf:"bytes,15,opt,name=player_name" json:"player_name,omitempty"` QueryPort *uint32 `protobuf:"varint,20,opt,name=query_port,json=queryPort" json:"query_port,omitempty"`
QueryPort *uint32 `protobuf:"varint,20,opt,name=query_port" json:"query_port,omitempty"` SteamidSource *uint64 `protobuf:"fixed64,25,opt,name=steamid_source,json=steamidSource" json:"steamid_source,omitempty"`
SteamidSource *uint64 `protobuf:"fixed64,25,opt,name=steamid_source" json:"steamid_source,omitempty"` AvatarHash []byte `protobuf:"bytes,31,opt,name=avatar_hash,json=avatarHash" json:"avatar_hash,omitempty"`
AvatarHash []byte `protobuf:"bytes,31,opt,name=avatar_hash" json:"avatar_hash,omitempty"` LastLogoff *uint32 `protobuf:"varint,45,opt,name=last_logoff,json=lastLogoff" json:"last_logoff,omitempty"`
LastLogoff *uint32 `protobuf:"varint,45,opt,name=last_logoff" json:"last_logoff,omitempty"` LastLogon *uint32 `protobuf:"varint,46,opt,name=last_logon,json=lastLogon" json:"last_logon,omitempty"`
LastLogon *uint32 `protobuf:"varint,46,opt,name=last_logon" json:"last_logon,omitempty"` LastSeenOnline *uint32 `protobuf:"varint,47,opt,name=last_seen_online,json=lastSeenOnline" json:"last_seen_online,omitempty"`
LastSeenOnline *uint32 `protobuf:"varint,47,opt,name=last_seen_online" json:"last_seen_online,omitempty"` ClanRank *uint32 `protobuf:"varint,50,opt,name=clan_rank,json=clanRank" json:"clan_rank,omitempty"`
ClanRank *uint32 `protobuf:"varint,50,opt,name=clan_rank" json:"clan_rank,omitempty"` GameName *string `protobuf:"bytes,55,opt,name=game_name,json=gameName" json:"game_name,omitempty"`
GameName *string `protobuf:"bytes,55,opt,name=game_name" json:"game_name,omitempty"`
Gameid *uint64 `protobuf:"fixed64,56,opt,name=gameid" json:"gameid,omitempty"` Gameid *uint64 `protobuf:"fixed64,56,opt,name=gameid" json:"gameid,omitempty"`
GameDataBlob []byte `protobuf:"bytes,60,opt,name=game_data_blob" json:"game_data_blob,omitempty"` GameDataBlob []byte `protobuf:"bytes,60,opt,name=game_data_blob,json=gameDataBlob" json:"game_data_blob,omitempty"`
ClanData *CMsgClientPersonaState_Friend_ClanData `protobuf:"bytes,64,opt,name=clan_data" json:"clan_data,omitempty"` ClanData *CMsgClientPersonaState_Friend_ClanData `protobuf:"bytes,64,opt,name=clan_data,json=clanData" json:"clan_data,omitempty"`
ClanTag *string `protobuf:"bytes,65,opt,name=clan_tag" json:"clan_tag,omitempty"` ClanTag *string `protobuf:"bytes,65,opt,name=clan_tag,json=clanTag" json:"clan_tag,omitempty"`
RichPresence []*CMsgClientPersonaState_Friend_KV `protobuf:"bytes,71,rep,name=rich_presence" json:"rich_presence,omitempty"` RichPresence []*CMsgClientPersonaState_Friend_KV `protobuf:"bytes,71,rep,name=rich_presence,json=richPresence" json:"rich_presence,omitempty"`
BroadcastId *uint64 `protobuf:"fixed64,72,opt,name=broadcast_id" json:"broadcast_id,omitempty"` BroadcastId *uint64 `protobuf:"fixed64,72,opt,name=broadcast_id,json=broadcastId" json:"broadcast_id,omitempty"`
GameLobbyId *uint64 `protobuf:"fixed64,73,opt,name=game_lobby_id" json:"game_lobby_id,omitempty"` GameLobbyId *uint64 `protobuf:"fixed64,73,opt,name=game_lobby_id,json=gameLobbyId" json:"game_lobby_id,omitempty"`
WatchingBroadcastAccountid *uint32 `protobuf:"varint,74,opt,name=watching_broadcast_accountid" json:"watching_broadcast_accountid,omitempty"` WatchingBroadcastAccountid *uint32 `protobuf:"varint,74,opt,name=watching_broadcast_accountid,json=watchingBroadcastAccountid" json:"watching_broadcast_accountid,omitempty"`
WatchingBroadcastAppid *uint32 `protobuf:"varint,75,opt,name=watching_broadcast_appid" json:"watching_broadcast_appid,omitempty"` WatchingBroadcastAppid *uint32 `protobuf:"varint,75,opt,name=watching_broadcast_appid,json=watchingBroadcastAppid" json:"watching_broadcast_appid,omitempty"`
WatchingBroadcastViewers *uint32 `protobuf:"varint,76,opt,name=watching_broadcast_viewers" json:"watching_broadcast_viewers,omitempty"` WatchingBroadcastViewers *uint32 `protobuf:"varint,76,opt,name=watching_broadcast_viewers,json=watchingBroadcastViewers" json:"watching_broadcast_viewers,omitempty"`
WatchingBroadcastTitle *string `protobuf:"bytes,77,opt,name=watching_broadcast_title" json:"watching_broadcast_title,omitempty"` WatchingBroadcastTitle *string `protobuf:"bytes,77,opt,name=watching_broadcast_title,json=watchingBroadcastTitle" json:"watching_broadcast_title,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -1172,13 +1171,6 @@ func (m *CMsgClientPersonaState_Friend) GetOnlineSessionInstances() uint32 {
return 0 return 0
} }
func (m *CMsgClientPersonaState_Friend) GetPublishedInstanceId() uint32 {
if m != nil && m.PublishedInstanceId != nil {
return *m.PublishedInstanceId
}
return 0
}
func (m *CMsgClientPersonaState_Friend) GetPersonaSetByUser() bool { func (m *CMsgClientPersonaState_Friend) GetPersonaSetByUser() bool {
if m != nil && m.PersonaSetByUser != nil { if m != nil && m.PersonaSetByUser != nil {
return *m.PersonaSetByUser return *m.PersonaSetByUser
@@ -1327,8 +1319,8 @@ func (m *CMsgClientPersonaState_Friend) GetWatchingBroadcastTitle() string {
} }
type CMsgClientPersonaState_Friend_ClanData struct { type CMsgClientPersonaState_Friend_ClanData struct {
OggAppId *uint32 `protobuf:"varint,1,opt,name=ogg_app_id" json:"ogg_app_id,omitempty"` OggAppId *uint32 `protobuf:"varint,1,opt,name=ogg_app_id,json=oggAppId" json:"ogg_app_id,omitempty"`
ChatGroupId *uint64 `protobuf:"varint,2,opt,name=chat_group_id" json:"chat_group_id,omitempty"` ChatGroupId *uint64 `protobuf:"varint,2,opt,name=chat_group_id,json=chatGroupId" json:"chat_group_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -1423,7 +1415,7 @@ func (m *CMsgClientPersonaState_Friend_KV) GetValue() string {
} }
type CMsgClientFriendProfileInfo struct { type CMsgClientFriendProfileInfo struct {
SteamidFriend *uint64 `protobuf:"fixed64,1,opt,name=steamid_friend" json:"steamid_friend,omitempty"` SteamidFriend *uint64 `protobuf:"fixed64,1,opt,name=steamid_friend,json=steamidFriend" json:"steamid_friend,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -1463,12 +1455,12 @@ func (m *CMsgClientFriendProfileInfo) GetSteamidFriend() uint64 {
type CMsgClientFriendProfileInfoResponse struct { type CMsgClientFriendProfileInfoResponse struct {
Eresult *int32 `protobuf:"varint,1,opt,name=eresult,def=2" json:"eresult,omitempty"` Eresult *int32 `protobuf:"varint,1,opt,name=eresult,def=2" json:"eresult,omitempty"`
SteamidFriend *uint64 `protobuf:"fixed64,2,opt,name=steamid_friend" json:"steamid_friend,omitempty"` SteamidFriend *uint64 `protobuf:"fixed64,2,opt,name=steamid_friend,json=steamidFriend" json:"steamid_friend,omitempty"`
TimeCreated *uint32 `protobuf:"varint,3,opt,name=time_created" json:"time_created,omitempty"` TimeCreated *uint32 `protobuf:"varint,3,opt,name=time_created,json=timeCreated" json:"time_created,omitempty"`
RealName *string `protobuf:"bytes,4,opt,name=real_name" json:"real_name,omitempty"` RealName *string `protobuf:"bytes,4,opt,name=real_name,json=realName" json:"real_name,omitempty"`
CityName *string `protobuf:"bytes,5,opt,name=city_name" json:"city_name,omitempty"` CityName *string `protobuf:"bytes,5,opt,name=city_name,json=cityName" json:"city_name,omitempty"`
StateName *string `protobuf:"bytes,6,opt,name=state_name" json:"state_name,omitempty"` StateName *string `protobuf:"bytes,6,opt,name=state_name,json=stateName" json:"state_name,omitempty"`
CountryName *string `protobuf:"bytes,7,opt,name=country_name" json:"country_name,omitempty"` CountryName *string `protobuf:"bytes,7,opt,name=country_name,json=countryName" json:"country_name,omitempty"`
Headline *string `protobuf:"bytes,8,opt,name=headline" json:"headline,omitempty"` Headline *string `protobuf:"bytes,8,opt,name=headline" json:"headline,omitempty"`
Summary *string `protobuf:"bytes,9,opt,name=summary" json:"summary,omitempty"` Summary *string `protobuf:"bytes,9,opt,name=summary" json:"summary,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
@@ -1569,7 +1561,7 @@ func (m *CMsgClientFriendProfileInfoResponse) GetSummary() string {
type CMsgClientCreateFriendsGroup struct { type CMsgClientCreateFriendsGroup struct {
Steamid *uint64 `protobuf:"fixed64,1,opt,name=steamid" json:"steamid,omitempty"` Steamid *uint64 `protobuf:"fixed64,1,opt,name=steamid" json:"steamid,omitempty"`
Groupname *string `protobuf:"bytes,2,opt,name=groupname" json:"groupname,omitempty"` Groupname *string `protobuf:"bytes,2,opt,name=groupname" json:"groupname,omitempty"`
SteamidFriends []uint64 `protobuf:"fixed64,3,rep,name=steamid_friends" json:"steamid_friends,omitempty"` SteamidFriends []uint64 `protobuf:"fixed64,3,rep,name=steamid_friends,json=steamidFriends" json:"steamid_friends,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -1757,8 +1749,8 @@ func (m *CMsgClientDeleteFriendsGroupResponse) GetEresult() uint32 {
type CMsgClientManageFriendsGroup struct { type CMsgClientManageFriendsGroup struct {
Groupid *int32 `protobuf:"varint,1,opt,name=groupid" json:"groupid,omitempty"` Groupid *int32 `protobuf:"varint,1,opt,name=groupid" json:"groupid,omitempty"`
Groupname *string `protobuf:"bytes,2,opt,name=groupname" json:"groupname,omitempty"` Groupname *string `protobuf:"bytes,2,opt,name=groupname" json:"groupname,omitempty"`
SteamidFriendsAdded []uint64 `protobuf:"fixed64,3,rep,name=steamid_friends_added" json:"steamid_friends_added,omitempty"` SteamidFriendsAdded []uint64 `protobuf:"fixed64,3,rep,name=steamid_friends_added,json=steamidFriendsAdded" json:"steamid_friends_added,omitempty"`
SteamidFriendsRemoved []uint64 `protobuf:"fixed64,4,rep,name=steamid_friends_removed" json:"steamid_friends_removed,omitempty"` SteamidFriendsRemoved []uint64 `protobuf:"fixed64,4,rep,name=steamid_friends_removed,json=steamidFriendsRemoved" json:"steamid_friends_removed,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -2063,6 +2055,8 @@ var xxx_messageInfo_CMsgClientGetEmoticonList proto.InternalMessageInfo
type CMsgClientEmoticonList struct { type CMsgClientEmoticonList struct {
Emoticons []*CMsgClientEmoticonList_Emoticon `protobuf:"bytes,1,rep,name=emoticons" json:"emoticons,omitempty"` Emoticons []*CMsgClientEmoticonList_Emoticon `protobuf:"bytes,1,rep,name=emoticons" json:"emoticons,omitempty"`
Stickers []*CMsgClientEmoticonList_Sticker `protobuf:"bytes,2,rep,name=stickers" json:"stickers,omitempty"`
Effects []*CMsgClientEmoticonList_Effect `protobuf:"bytes,3,rep,name=effects" json:"effects,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -2100,12 +2094,26 @@ func (m *CMsgClientEmoticonList) GetEmoticons() []*CMsgClientEmoticonList_Emotic
return nil return nil
} }
func (m *CMsgClientEmoticonList) GetStickers() []*CMsgClientEmoticonList_Sticker {
if m != nil {
return m.Stickers
}
return nil
}
func (m *CMsgClientEmoticonList) GetEffects() []*CMsgClientEmoticonList_Effect {
if m != nil {
return m.Effects
}
return nil
}
type CMsgClientEmoticonList_Emoticon struct { type CMsgClientEmoticonList_Emoticon struct {
Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
Count *int32 `protobuf:"varint,2,opt,name=count" json:"count,omitempty"` Count *int32 `protobuf:"varint,2,opt,name=count" json:"count,omitempty"`
TimeLastUsed *uint32 `protobuf:"varint,3,opt,name=time_last_used" json:"time_last_used,omitempty"` TimeLastUsed *uint32 `protobuf:"varint,3,opt,name=time_last_used,json=timeLastUsed" json:"time_last_used,omitempty"`
UseCount *uint32 `protobuf:"varint,4,opt,name=use_count" json:"use_count,omitempty"` UseCount *uint32 `protobuf:"varint,4,opt,name=use_count,json=useCount" json:"use_count,omitempty"`
TimeReceived *uint32 `protobuf:"varint,5,opt,name=time_received" json:"time_received,omitempty"` TimeReceived *uint32 `protobuf:"varint,5,opt,name=time_received,json=timeReceived" json:"time_received,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -2171,6 +2179,140 @@ func (m *CMsgClientEmoticonList_Emoticon) GetTimeReceived() uint32 {
return 0 return 0
} }
type CMsgClientEmoticonList_Sticker struct {
Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
Count *int32 `protobuf:"varint,2,opt,name=count" json:"count,omitempty"`
TimeReceived *uint32 `protobuf:"varint,3,opt,name=time_received,json=timeReceived" json:"time_received,omitempty"`
Appid *uint32 `protobuf:"varint,4,opt,name=appid" json:"appid,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CMsgClientEmoticonList_Sticker) Reset() { *m = CMsgClientEmoticonList_Sticker{} }
func (m *CMsgClientEmoticonList_Sticker) String() string { return proto.CompactTextString(m) }
func (*CMsgClientEmoticonList_Sticker) ProtoMessage() {}
func (*CMsgClientEmoticonList_Sticker) Descriptor() ([]byte, []int) {
return fileDescriptor_4f7c18b08a29999e, []int{28, 1}
}
func (m *CMsgClientEmoticonList_Sticker) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CMsgClientEmoticonList_Sticker.Unmarshal(m, b)
}
func (m *CMsgClientEmoticonList_Sticker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CMsgClientEmoticonList_Sticker.Marshal(b, m, deterministic)
}
func (m *CMsgClientEmoticonList_Sticker) XXX_Merge(src proto.Message) {
xxx_messageInfo_CMsgClientEmoticonList_Sticker.Merge(m, src)
}
func (m *CMsgClientEmoticonList_Sticker) XXX_Size() int {
return xxx_messageInfo_CMsgClientEmoticonList_Sticker.Size(m)
}
func (m *CMsgClientEmoticonList_Sticker) XXX_DiscardUnknown() {
xxx_messageInfo_CMsgClientEmoticonList_Sticker.DiscardUnknown(m)
}
var xxx_messageInfo_CMsgClientEmoticonList_Sticker proto.InternalMessageInfo
func (m *CMsgClientEmoticonList_Sticker) GetName() string {
if m != nil && m.Name != nil {
return *m.Name
}
return ""
}
func (m *CMsgClientEmoticonList_Sticker) GetCount() int32 {
if m != nil && m.Count != nil {
return *m.Count
}
return 0
}
func (m *CMsgClientEmoticonList_Sticker) GetTimeReceived() uint32 {
if m != nil && m.TimeReceived != nil {
return *m.TimeReceived
}
return 0
}
func (m *CMsgClientEmoticonList_Sticker) GetAppid() uint32 {
if m != nil && m.Appid != nil {
return *m.Appid
}
return 0
}
type CMsgClientEmoticonList_Effect struct {
Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
Count *int32 `protobuf:"varint,2,opt,name=count" json:"count,omitempty"`
TimeReceived *uint32 `protobuf:"varint,3,opt,name=time_received,json=timeReceived" json:"time_received,omitempty"`
InfiniteUse *bool `protobuf:"varint,4,opt,name=infinite_use,json=infiniteUse" json:"infinite_use,omitempty"`
Appid *uint32 `protobuf:"varint,5,opt,name=appid" json:"appid,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CMsgClientEmoticonList_Effect) Reset() { *m = CMsgClientEmoticonList_Effect{} }
func (m *CMsgClientEmoticonList_Effect) String() string { return proto.CompactTextString(m) }
func (*CMsgClientEmoticonList_Effect) ProtoMessage() {}
func (*CMsgClientEmoticonList_Effect) Descriptor() ([]byte, []int) {
return fileDescriptor_4f7c18b08a29999e, []int{28, 2}
}
func (m *CMsgClientEmoticonList_Effect) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CMsgClientEmoticonList_Effect.Unmarshal(m, b)
}
func (m *CMsgClientEmoticonList_Effect) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CMsgClientEmoticonList_Effect.Marshal(b, m, deterministic)
}
func (m *CMsgClientEmoticonList_Effect) XXX_Merge(src proto.Message) {
xxx_messageInfo_CMsgClientEmoticonList_Effect.Merge(m, src)
}
func (m *CMsgClientEmoticonList_Effect) XXX_Size() int {
return xxx_messageInfo_CMsgClientEmoticonList_Effect.Size(m)
}
func (m *CMsgClientEmoticonList_Effect) XXX_DiscardUnknown() {
xxx_messageInfo_CMsgClientEmoticonList_Effect.DiscardUnknown(m)
}
var xxx_messageInfo_CMsgClientEmoticonList_Effect proto.InternalMessageInfo
func (m *CMsgClientEmoticonList_Effect) GetName() string {
if m != nil && m.Name != nil {
return *m.Name
}
return ""
}
func (m *CMsgClientEmoticonList_Effect) GetCount() int32 {
if m != nil && m.Count != nil {
return *m.Count
}
return 0
}
func (m *CMsgClientEmoticonList_Effect) GetTimeReceived() uint32 {
if m != nil && m.TimeReceived != nil {
return *m.TimeReceived
}
return 0
}
func (m *CMsgClientEmoticonList_Effect) GetInfiniteUse() bool {
if m != nil && m.InfiniteUse != nil {
return *m.InfiniteUse
}
return false
}
func (m *CMsgClientEmoticonList_Effect) GetAppid() uint32 {
if m != nil && m.Appid != nil {
return *m.Appid
}
return 0
}
func init() { func init() {
proto.RegisterType((*CMsgClientFriendMsg)(nil), "CMsgClientFriendMsg") proto.RegisterType((*CMsgClientFriendMsg)(nil), "CMsgClientFriendMsg")
proto.RegisterType((*CMsgClientFriendMsgIncoming)(nil), "CMsgClientFriendMsgIncoming") proto.RegisterType((*CMsgClientFriendMsgIncoming)(nil), "CMsgClientFriendMsgIncoming")
@@ -2209,6 +2351,8 @@ func init() {
proto.RegisterType((*CMsgClientGetEmoticonList)(nil), "CMsgClientGetEmoticonList") proto.RegisterType((*CMsgClientGetEmoticonList)(nil), "CMsgClientGetEmoticonList")
proto.RegisterType((*CMsgClientEmoticonList)(nil), "CMsgClientEmoticonList") proto.RegisterType((*CMsgClientEmoticonList)(nil), "CMsgClientEmoticonList")
proto.RegisterType((*CMsgClientEmoticonList_Emoticon)(nil), "CMsgClientEmoticonList.Emoticon") proto.RegisterType((*CMsgClientEmoticonList_Emoticon)(nil), "CMsgClientEmoticonList.Emoticon")
proto.RegisterType((*CMsgClientEmoticonList_Sticker)(nil), "CMsgClientEmoticonList.Sticker")
proto.RegisterType((*CMsgClientEmoticonList_Effect)(nil), "CMsgClientEmoticonList.Effect")
} }
func init() { func init() {
@@ -2216,106 +2360,141 @@ func init() {
} }
var fileDescriptor_4f7c18b08a29999e = []byte{ var fileDescriptor_4f7c18b08a29999e = []byte{
// 1607 bytes of a gzipped FileDescriptorProto // 2171 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x57, 0x4b, 0x73, 0x1b, 0xc7, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0xdd, 0x6e, 0x1b, 0xb9,
0x11, 0xce, 0x8a, 0x24, 0x1e, 0x0d, 0x82, 0xa4, 0x96, 0x0f, 0xad, 0x40, 0x3d, 0x90, 0xb5, 0xab, 0x15, 0xae, 0xe4, 0x3f, 0xf9, 0x48, 0x72, 0x36, 0x74, 0xe2, 0x4c, 0x94, 0x6c, 0xe2, 0x4c, 0xd2,
0x8c, 0x4a, 0x25, 0x70, 0x8a, 0x2a, 0xd9, 0x8e, 0x2a, 0x0f, 0xd9, 0x54, 0x2c, 0x2a, 0x32, 0x1d, 0xc6, 0x68, 0xb3, 0x6a, 0xea, 0x14, 0xbb, 0xc1, 0x36, 0xd8, 0xc6, 0xb1, 0xe3, 0x44, 0x1b, 0x7b,
0x95, 0x94, 0xf2, 0x25, 0x87, 0xa9, 0xc1, 0x6e, 0x13, 0x98, 0xd2, 0xee, 0x2c, 0x3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() {
var xxx_messageInfo_CMsgClientHeartBeat proto.InternalMessageInfo var xxx_messageInfo_CMsgClientHeartBeat proto.InternalMessageInfo
type CMsgClientServerTimestampRequest struct { type CMsgClientServerTimestampRequest struct {
ClientRequestTimestamp *uint64 `protobuf:"varint,1,opt,name=client_request_timestamp" json:"client_request_timestamp,omitempty"` ClientRequestTimestamp *uint64 `protobuf:"varint,1,opt,name=client_request_timestamp,json=clientRequestTimestamp" json:"client_request_timestamp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -91,8 +91,8 @@ func (m *CMsgClientServerTimestampRequest) GetClientRequestTimestamp() uint64 {
} }
type CMsgClientServerTimestampResponse struct { type CMsgClientServerTimestampResponse struct {
ClientRequestTimestamp *uint64 `protobuf:"varint,1,opt,name=client_request_timestamp" json:"client_request_timestamp,omitempty"` ClientRequestTimestamp *uint64 `protobuf:"varint,1,opt,name=client_request_timestamp,json=clientRequestTimestamp" json:"client_request_timestamp,omitempty"`
ServerTimestampMs *uint64 `protobuf:"varint,2,opt,name=server_timestamp_ms" json:"server_timestamp_ms,omitempty"` ServerTimestampMs *uint64 `protobuf:"varint,2,opt,name=server_timestamp_ms,json=serverTimestampMs" json:"server_timestamp_ms,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -137,56 +137,131 @@ func (m *CMsgClientServerTimestampResponse) GetServerTimestampMs() uint64 {
return 0 return 0
} }
type CMsgClientSecret struct {
Version *uint32 `protobuf:"varint,1,opt,name=version" json:"version,omitempty"`
Appid *uint32 `protobuf:"varint,2,opt,name=appid" json:"appid,omitempty"`
Deviceid *uint32 `protobuf:"varint,3,opt,name=deviceid" json:"deviceid,omitempty"`
Nonce *uint64 `protobuf:"fixed64,4,opt,name=nonce" json:"nonce,omitempty"`
Hmac []byte `protobuf:"bytes,5,opt,name=hmac" json:"hmac,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CMsgClientSecret) Reset() { *m = CMsgClientSecret{} }
func (m *CMsgClientSecret) String() string { return proto.CompactTextString(m) }
func (*CMsgClientSecret) ProtoMessage() {}
func (*CMsgClientSecret) Descriptor() ([]byte, []int) {
return fileDescriptor_c98cb07f62c057af, []int{3}
}
func (m *CMsgClientSecret) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CMsgClientSecret.Unmarshal(m, b)
}
func (m *CMsgClientSecret) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CMsgClientSecret.Marshal(b, m, deterministic)
}
func (m *CMsgClientSecret) XXX_Merge(src proto.Message) {
xxx_messageInfo_CMsgClientSecret.Merge(m, src)
}
func (m *CMsgClientSecret) XXX_Size() int {
return xxx_messageInfo_CMsgClientSecret.Size(m)
}
func (m *CMsgClientSecret) XXX_DiscardUnknown() {
xxx_messageInfo_CMsgClientSecret.DiscardUnknown(m)
}
var xxx_messageInfo_CMsgClientSecret proto.InternalMessageInfo
func (m *CMsgClientSecret) GetVersion() uint32 {
if m != nil && m.Version != nil {
return *m.Version
}
return 0
}
func (m *CMsgClientSecret) GetAppid() uint32 {
if m != nil && m.Appid != nil {
return *m.Appid
}
return 0
}
func (m *CMsgClientSecret) GetDeviceid() uint32 {
if m != nil && m.Deviceid != nil {
return *m.Deviceid
}
return 0
}
func (m *CMsgClientSecret) GetNonce() uint64 {
if m != nil && m.Nonce != nil {
return *m.Nonce
}
return 0
}
func (m *CMsgClientSecret) GetHmac() []byte {
if m != nil {
return m.Hmac
}
return nil
}
type CMsgClientLogon struct { type CMsgClientLogon struct {
ProtocolVersion *uint32 `protobuf:"varint,1,opt,name=protocol_version" json:"protocol_version,omitempty"` ProtocolVersion *uint32 `protobuf:"varint,1,opt,name=protocol_version,json=protocolVersion" json:"protocol_version,omitempty"`
ObfustucatedPrivateIp *uint32 `protobuf:"varint,2,opt,name=obfustucated_private_ip" json:"obfustucated_private_ip,omitempty"` DeprecatedObfustucatedPrivateIp *uint32 `protobuf:"varint,2,opt,name=deprecated_obfustucated_private_ip,json=deprecatedObfustucatedPrivateIp" json:"deprecated_obfustucated_private_ip,omitempty"`
CellId *uint32 `protobuf:"varint,3,opt,name=cell_id" json:"cell_id,omitempty"` CellId *uint32 `protobuf:"varint,3,opt,name=cell_id,json=cellId" json:"cell_id,omitempty"`
LastSessionId *uint32 `protobuf:"varint,4,opt,name=last_session_id" json:"last_session_id,omitempty"` LastSessionId *uint32 `protobuf:"varint,4,opt,name=last_session_id,json=lastSessionId" json:"last_session_id,omitempty"`
ClientPackageVersion *uint32 `protobuf:"varint,5,opt,name=client_package_version" json:"client_package_version,omitempty"` ClientPackageVersion *uint32 `protobuf:"varint,5,opt,name=client_package_version,json=clientPackageVersion" json:"client_package_version,omitempty"`
ClientLanguage *string `protobuf:"bytes,6,opt,name=client_language" json:"client_language,omitempty"` ClientLanguage *string `protobuf:"bytes,6,opt,name=client_language,json=clientLanguage" json:"client_language,omitempty"`
ClientOsType *uint32 `protobuf:"varint,7,opt,name=client_os_type" json:"client_os_type,omitempty"` ClientOsType *uint32 `protobuf:"varint,7,opt,name=client_os_type,json=clientOsType" json:"client_os_type,omitempty"`
ShouldRememberPassword *bool `protobuf:"varint,8,opt,name=should_remember_password,def=0" json:"should_remember_password,omitempty"` ShouldRememberPassword *bool `protobuf:"varint,8,opt,name=should_remember_password,json=shouldRememberPassword,def=0" json:"should_remember_password,omitempty"`
WineVersion *string `protobuf:"bytes,9,opt,name=wine_version" json:"wine_version,omitempty"` WineVersion *string `protobuf:"bytes,9,opt,name=wine_version,json=wineVersion" json:"wine_version,omitempty"`
PingMsFromCellSearch *uint32 `protobuf:"varint,10,opt,name=ping_ms_from_cell_search" json:"ping_ms_from_cell_search,omitempty"` Deprecated_10 *uint32 `protobuf:"varint,10,opt,name=deprecated_10,json=deprecated10" json:"deprecated_10,omitempty"`
PublicIp *uint32 `protobuf:"varint,20,opt,name=public_ip" json:"public_ip,omitempty"` ObfuscatedPrivateIp *CMsgIPAddress `protobuf:"bytes,11,opt,name=obfuscated_private_ip,json=obfuscatedPrivateIp" json:"obfuscated_private_ip,omitempty"`
QosLevel *uint32 `protobuf:"varint,21,opt,name=qos_level" json:"qos_level,omitempty"` DeprecatedPublicIp *uint32 `protobuf:"varint,20,opt,name=deprecated_public_ip,json=deprecatedPublicIp" json:"deprecated_public_ip,omitempty"`
ClientSuppliedSteamId *uint64 `protobuf:"fixed64,22,opt,name=client_supplied_steam_id" json:"client_supplied_steam_id,omitempty"` QosLevel *uint32 `protobuf:"varint,21,opt,name=qos_level,json=qosLevel" json:"qos_level,omitempty"`
MachineId []byte `protobuf:"bytes,30,opt,name=machine_id" json:"machine_id,omitempty"` ClientSuppliedSteamId *uint64 `protobuf:"fixed64,22,opt,name=client_supplied_steam_id,json=clientSuppliedSteamId" json:"client_supplied_steam_id,omitempty"`
LauncherType *uint32 `protobuf:"varint,31,opt,name=launcher_type,def=0" json:"launcher_type,omitempty"` PublicIp *CMsgIPAddress `protobuf:"bytes,23,opt,name=public_ip,json=publicIp" json:"public_ip,omitempty"`
UiMode *uint32 `protobuf:"varint,32,opt,name=ui_mode,def=0" json:"ui_mode,omitempty"` MachineId []byte `protobuf:"bytes,30,opt,name=machine_id,json=machineId" json:"machine_id,omitempty"`
ChatMode *uint32 `protobuf:"varint,33,opt,name=chat_mode,def=0" json:"chat_mode,omitempty"` LauncherType *uint32 `protobuf:"varint,31,opt,name=launcher_type,json=launcherType,def=0" json:"launcher_type,omitempty"`
Steam2AuthTicket []byte `protobuf:"bytes,41,opt,name=steam2_auth_ticket" json:"steam2_auth_ticket,omitempty"` UiMode *uint32 `protobuf:"varint,32,opt,name=ui_mode,json=uiMode,def=0" json:"ui_mode,omitempty"`
EmailAddress *string `protobuf:"bytes,42,opt,name=email_address" json:"email_address,omitempty"` ChatMode *uint32 `protobuf:"varint,33,opt,name=chat_mode,json=chatMode,def=0" json:"chat_mode,omitempty"`
Rtime32AccountCreation *uint32 `protobuf:"fixed32,43,opt,name=rtime32_account_creation" json:"rtime32_account_creation,omitempty"` Steam2AuthTicket []byte `protobuf:"bytes,41,opt,name=steam2_auth_ticket,json=steam2AuthTicket" json:"steam2_auth_ticket,omitempty"`
AccountName *string `protobuf:"bytes,50,opt,name=account_name" json:"account_name,omitempty"` EmailAddress *string `protobuf:"bytes,42,opt,name=email_address,json=emailAddress" json:"email_address,omitempty"`
Rtime32AccountCreation *uint32 `protobuf:"fixed32,43,opt,name=rtime32_account_creation,json=rtime32AccountCreation" json:"rtime32_account_creation,omitempty"`
AccountName *string `protobuf:"bytes,50,opt,name=account_name,json=accountName" json:"account_name,omitempty"`
Password *string `protobuf:"bytes,51,opt,name=password" json:"password,omitempty"` Password *string `protobuf:"bytes,51,opt,name=password" json:"password,omitempty"`
GameServerToken *string `protobuf:"bytes,52,opt,name=game_server_token" json:"game_server_token,omitempty"` GameServerToken *string `protobuf:"bytes,52,opt,name=game_server_token,json=gameServerToken" json:"game_server_token,omitempty"`
LoginKey *string `protobuf:"bytes,60,opt,name=login_key" json:"login_key,omitempty"` LoginKey *string `protobuf:"bytes,60,opt,name=login_key,json=loginKey" json:"login_key,omitempty"`
WasConvertedDeprecatedMsg *bool `protobuf:"varint,70,opt,name=was_converted_deprecated_msg,def=0" json:"was_converted_deprecated_msg,omitempty"` WasConvertedDeprecatedMsg *bool `protobuf:"varint,70,opt,name=was_converted_deprecated_msg,json=wasConvertedDeprecatedMsg,def=0" json:"was_converted_deprecated_msg,omitempty"`
AnonUserTargetAccountName *string `protobuf:"bytes,80,opt,name=anon_user_target_account_name" json:"anon_user_target_account_name,omitempty"` AnonUserTargetAccountName *string `protobuf:"bytes,80,opt,name=anon_user_target_account_name,json=anonUserTargetAccountName" json:"anon_user_target_account_name,omitempty"`
ResolvedUserSteamId *uint64 `protobuf:"fixed64,81,opt,name=resolved_user_steam_id" json:"resolved_user_steam_id,omitempty"` ResolvedUserSteamId *uint64 `protobuf:"fixed64,81,opt,name=resolved_user_steam_id,json=resolvedUserSteamId" json:"resolved_user_steam_id,omitempty"`
EresultSentryfile *int32 `protobuf:"varint,82,opt,name=eresult_sentryfile" json:"eresult_sentryfile,omitempty"` EresultSentryfile *int32 `protobuf:"varint,82,opt,name=eresult_sentryfile,json=eresultSentryfile" json:"eresult_sentryfile,omitempty"`
ShaSentryfile []byte `protobuf:"bytes,83,opt,name=sha_sentryfile" json:"sha_sentryfile,omitempty"` ShaSentryfile []byte `protobuf:"bytes,83,opt,name=sha_sentryfile,json=shaSentryfile" json:"sha_sentryfile,omitempty"`
AuthCode *string `protobuf:"bytes,84,opt,name=auth_code" json:"auth_code,omitempty"` AuthCode *string `protobuf:"bytes,84,opt,name=auth_code,json=authCode" json:"auth_code,omitempty"`
OtpType *int32 `protobuf:"varint,85,opt,name=otp_type" json:"otp_type,omitempty"` OtpType *int32 `protobuf:"varint,85,opt,name=otp_type,json=otpType" json:"otp_type,omitempty"`
OtpValue *uint32 `protobuf:"varint,86,opt,name=otp_value" json:"otp_value,omitempty"` OtpValue *uint32 `protobuf:"varint,86,opt,name=otp_value,json=otpValue" json:"otp_value,omitempty"`
OtpIdentifier *string `protobuf:"bytes,87,opt,name=otp_identifier" json:"otp_identifier,omitempty"` OtpIdentifier *string `protobuf:"bytes,87,opt,name=otp_identifier,json=otpIdentifier" json:"otp_identifier,omitempty"`
Steam2TicketRequest *bool `protobuf:"varint,88,opt,name=steam2_ticket_request" json:"steam2_ticket_request,omitempty"` Steam2TicketRequest *bool `protobuf:"varint,88,opt,name=steam2_ticket_request,json=steam2TicketRequest" json:"steam2_ticket_request,omitempty"`
SonyPsnTicket []byte `protobuf:"bytes,90,opt,name=sony_psn_ticket" json:"sony_psn_ticket,omitempty"` SonyPsnTicket []byte `protobuf:"bytes,90,opt,name=sony_psn_ticket,json=sonyPsnTicket" json:"sony_psn_ticket,omitempty"`
SonyPsnServiceId *string `protobuf:"bytes,91,opt,name=sony_psn_service_id" json:"sony_psn_service_id,omitempty"` SonyPsnServiceId *string `protobuf:"bytes,91,opt,name=sony_psn_service_id,json=sonyPsnServiceId" json:"sony_psn_service_id,omitempty"`
CreateNewPsnLinkedAccountIfNeeded *bool `protobuf:"varint,92,opt,name=create_new_psn_linked_account_if_needed,def=0" json:"create_new_psn_linked_account_if_needed,omitempty"` CreateNewPsnLinkedAccountIfNeeded *bool `protobuf:"varint,92,opt,name=create_new_psn_linked_account_if_needed,json=createNewPsnLinkedAccountIfNeeded,def=0" json:"create_new_psn_linked_account_if_needed,omitempty"`
SonyPsnName *string `protobuf:"bytes,93,opt,name=sony_psn_name" json:"sony_psn_name,omitempty"` SonyPsnName *string `protobuf:"bytes,93,opt,name=sony_psn_name,json=sonyPsnName" json:"sony_psn_name,omitempty"`
GameServerAppId *int32 `protobuf:"varint,94,opt,name=game_server_app_id" json:"game_server_app_id,omitempty"` GameServerAppId *int32 `protobuf:"varint,94,opt,name=game_server_app_id,json=gameServerAppId" json:"game_server_app_id,omitempty"`
SteamguardDontRememberComputer *bool `protobuf:"varint,95,opt,name=steamguard_dont_remember_computer" json:"steamguard_dont_remember_computer,omitempty"` SteamguardDontRememberComputer *bool `protobuf:"varint,95,opt,name=steamguard_dont_remember_computer,json=steamguardDontRememberComputer" json:"steamguard_dont_remember_computer,omitempty"`
MachineName *string `protobuf:"bytes,96,opt,name=machine_name" json:"machine_name,omitempty"` MachineName *string `protobuf:"bytes,96,opt,name=machine_name,json=machineName" json:"machine_name,omitempty"`
MachineNameUserchosen *string `protobuf:"bytes,97,opt,name=machine_name_userchosen" json:"machine_name_userchosen,omitempty"` MachineNameUserchosen *string `protobuf:"bytes,97,opt,name=machine_name_userchosen,json=machineNameUserchosen" json:"machine_name_userchosen,omitempty"`
CountryOverride *string `protobuf:"bytes,98,opt,name=country_override" json:"country_override,omitempty"` CountryOverride *string `protobuf:"bytes,98,opt,name=country_override,json=countryOverride" json:"country_override,omitempty"`
IsSteamBox *bool `protobuf:"varint,99,opt,name=is_steam_box" json:"is_steam_box,omitempty"` IsSteamBox *bool `protobuf:"varint,99,opt,name=is_steam_box,json=isSteamBox" json:"is_steam_box,omitempty"`
ClientInstanceId *uint64 `protobuf:"varint,100,opt,name=client_instance_id" json:"client_instance_id,omitempty"` ClientInstanceId *uint64 `protobuf:"varint,100,opt,name=client_instance_id,json=clientInstanceId" json:"client_instance_id,omitempty"`
TwoFactorCode *string `protobuf:"bytes,101,opt,name=two_factor_code" json:"two_factor_code,omitempty"` TwoFactorCode *string `protobuf:"bytes,101,opt,name=two_factor_code,json=twoFactorCode" json:"two_factor_code,omitempty"`
SupportsRateLimitResponse *bool `protobuf:"varint,102,opt,name=supports_rate_limit_response" json:"supports_rate_limit_response,omitempty"` SupportsRateLimitResponse *bool `protobuf:"varint,102,opt,name=supports_rate_limit_response,json=supportsRateLimitResponse" json:"supports_rate_limit_response,omitempty"`
WebLogonNonce *string `protobuf:"bytes,103,opt,name=web_logon_nonce" json:"web_logon_nonce,omitempty"` WebLogonNonce *string `protobuf:"bytes,103,opt,name=web_logon_nonce,json=webLogonNonce" json:"web_logon_nonce,omitempty"`
PriorityReason *int32 `protobuf:"varint,104,opt,name=priority_reason" json:"priority_reason,omitempty"` PriorityReason *int32 `protobuf:"varint,104,opt,name=priority_reason,json=priorityReason" json:"priority_reason,omitempty"`
EmbeddedClientSecret *CMsgClientSecret `protobuf:"bytes,105,opt,name=embedded_client_secret,json=embeddedClientSecret" json:"embedded_client_secret,omitempty"`
DisablePartnerAutogrants *bool `protobuf:"varint,106,opt,name=disable_partner_autogrants,json=disablePartnerAutogrants" json:"disable_partner_autogrants,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -196,7 +271,7 @@ func (m *CMsgClientLogon) Reset() { *m = CMsgClientLogon{} }
func (m *CMsgClientLogon) String() string { return proto.CompactTextString(m) } func (m *CMsgClientLogon) String() string { return proto.CompactTextString(m) }
func (*CMsgClientLogon) ProtoMessage() {} func (*CMsgClientLogon) ProtoMessage() {}
func (*CMsgClientLogon) Descriptor() ([]byte, []int) { func (*CMsgClientLogon) Descriptor() ([]byte, []int) {
return fileDescriptor_c98cb07f62c057af, []int{3} return fileDescriptor_c98cb07f62c057af, []int{4}
} }
func (m *CMsgClientLogon) XXX_Unmarshal(b []byte) error { func (m *CMsgClientLogon) XXX_Unmarshal(b []byte) error {
@@ -231,9 +306,9 @@ func (m *CMsgClientLogon) GetProtocolVersion() uint32 {
return 0 return 0
} }
func (m *CMsgClientLogon) GetObfustucatedPrivateIp() uint32 { func (m *CMsgClientLogon) GetDeprecatedObfustucatedPrivateIp() uint32 {
if m != nil && m.ObfustucatedPrivateIp != nil { if m != nil && m.DeprecatedObfustucatedPrivateIp != nil {
return *m.ObfustucatedPrivateIp return *m.DeprecatedObfustucatedPrivateIp
} }
return 0 return 0
} }
@@ -287,16 +362,23 @@ func (m *CMsgClientLogon) GetWineVersion() string {
return "" return ""
} }
func (m *CMsgClientLogon) GetPingMsFromCellSearch() uint32 { func (m *CMsgClientLogon) GetDeprecated_10() uint32 {
if m != nil && m.PingMsFromCellSearch != nil { if m != nil && m.Deprecated_10 != nil {
return *m.PingMsFromCellSearch return *m.Deprecated_10
} }
return 0 return 0
} }
func (m *CMsgClientLogon) GetPublicIp() uint32 { func (m *CMsgClientLogon) GetObfuscatedPrivateIp() *CMsgIPAddress {
if m != nil && m.PublicIp != nil { if m != nil {
return *m.PublicIp return m.ObfuscatedPrivateIp
}
return nil
}
func (m *CMsgClientLogon) GetDeprecatedPublicIp() uint32 {
if m != nil && m.DeprecatedPublicIp != nil {
return *m.DeprecatedPublicIp
} }
return 0 return 0
} }
@@ -315,6 +397,13 @@ func (m *CMsgClientLogon) GetClientSuppliedSteamId() uint64 {
return 0 return 0
} }
func (m *CMsgClientLogon) GetPublicIp() *CMsgIPAddress {
if m != nil {
return m.PublicIp
}
return nil
}
func (m *CMsgClientLogon) GetMachineId() []byte { func (m *CMsgClientLogon) GetMachineId() []byte {
if m != nil { if m != nil {
return m.MachineId return m.MachineId
@@ -567,30 +656,45 @@ func (m *CMsgClientLogon) GetPriorityReason() int32 {
return 0 return 0
} }
func (m *CMsgClientLogon) GetEmbeddedClientSecret() *CMsgClientSecret {
if m != nil {
return m.EmbeddedClientSecret
}
return nil
}
func (m *CMsgClientLogon) GetDisablePartnerAutogrants() bool {
if m != nil && m.DisablePartnerAutogrants != nil {
return *m.DisablePartnerAutogrants
}
return false
}
type CMsgClientLogonResponse struct { type CMsgClientLogonResponse struct {
Eresult *int32 `protobuf:"varint,1,opt,name=eresult,def=2" json:"eresult,omitempty"` Eresult *int32 `protobuf:"varint,1,opt,name=eresult,def=2" json:"eresult,omitempty"`
OutOfGameHeartbeatSeconds *int32 `protobuf:"varint,2,opt,name=out_of_game_heartbeat_seconds" json:"out_of_game_heartbeat_seconds,omitempty"` OutOfGameHeartbeatSeconds *int32 `protobuf:"varint,2,opt,name=out_of_game_heartbeat_seconds,json=outOfGameHeartbeatSeconds" json:"out_of_game_heartbeat_seconds,omitempty"`
InGameHeartbeatSeconds *int32 `protobuf:"varint,3,opt,name=in_game_heartbeat_seconds" json:"in_game_heartbeat_seconds,omitempty"` InGameHeartbeatSeconds *int32 `protobuf:"varint,3,opt,name=in_game_heartbeat_seconds,json=inGameHeartbeatSeconds" json:"in_game_heartbeat_seconds,omitempty"`
PublicIp *uint32 `protobuf:"varint,4,opt,name=public_ip" json:"public_ip,omitempty"` DeprecatedPublicIp *uint32 `protobuf:"varint,4,opt,name=deprecated_public_ip,json=deprecatedPublicIp" json:"deprecated_public_ip,omitempty"`
Rtime32ServerTime *uint32 `protobuf:"fixed32,5,opt,name=rtime32_server_time" json:"rtime32_server_time,omitempty"` Rtime32ServerTime *uint32 `protobuf:"fixed32,5,opt,name=rtime32_server_time,json=rtime32ServerTime" json:"rtime32_server_time,omitempty"`
AccountFlags *uint32 `protobuf:"varint,6,opt,name=account_flags" json:"account_flags,omitempty"` AccountFlags *uint32 `protobuf:"varint,6,opt,name=account_flags,json=accountFlags" json:"account_flags,omitempty"`
CellId *uint32 `protobuf:"varint,7,opt,name=cell_id" json:"cell_id,omitempty"` CellId *uint32 `protobuf:"varint,7,opt,name=cell_id,json=cellId" json:"cell_id,omitempty"`
EmailDomain *string `protobuf:"bytes,8,opt,name=email_domain" json:"email_domain,omitempty"` EmailDomain *string `protobuf:"bytes,8,opt,name=email_domain,json=emailDomain" json:"email_domain,omitempty"`
Steam2Ticket []byte `protobuf:"bytes,9,opt,name=steam2_ticket" json:"steam2_ticket,omitempty"` Steam2Ticket []byte `protobuf:"bytes,9,opt,name=steam2_ticket,json=steam2Ticket" json:"steam2_ticket,omitempty"`
EresultExtended *int32 `protobuf:"varint,10,opt,name=eresult_extended" json:"eresult_extended,omitempty"` EresultExtended *int32 `protobuf:"varint,10,opt,name=eresult_extended,json=eresultExtended" json:"eresult_extended,omitempty"`
WebapiAuthenticateUserNonce *string `protobuf:"bytes,11,opt,name=webapi_authenticate_user_nonce" json:"webapi_authenticate_user_nonce,omitempty"` WebapiAuthenticateUserNonce *string `protobuf:"bytes,11,opt,name=webapi_authenticate_user_nonce,json=webapiAuthenticateUserNonce" json:"webapi_authenticate_user_nonce,omitempty"`
CellIdPingThreshold *uint32 `protobuf:"varint,12,opt,name=cell_id_ping_threshold" json:"cell_id_ping_threshold,omitempty"` CellIdPingThreshold *uint32 `protobuf:"varint,12,opt,name=cell_id_ping_threshold,json=cellIdPingThreshold" json:"cell_id_ping_threshold,omitempty"`
UsePics *bool `protobuf:"varint,13,opt,name=use_pics" json:"use_pics,omitempty"` DeprecatedUsePics *bool `protobuf:"varint,13,opt,name=deprecated_use_pics,json=deprecatedUsePics" json:"deprecated_use_pics,omitempty"`
VanityUrl *string `protobuf:"bytes,14,opt,name=vanity_url" json:"vanity_url,omitempty"` VanityUrl *string `protobuf:"bytes,14,opt,name=vanity_url,json=vanityUrl" json:"vanity_url,omitempty"`
ClientSuppliedSteamid *uint64 `protobuf:"fixed64,20,opt,name=client_supplied_steamid" json:"client_supplied_steamid,omitempty"` PublicIp *CMsgIPAddress `protobuf:"bytes,15,opt,name=public_ip,json=publicIp" json:"public_ip,omitempty"`
IpCountryCode *string `protobuf:"bytes,21,opt,name=ip_country_code" json:"ip_country_code,omitempty"` ClientSuppliedSteamid *uint64 `protobuf:"fixed64,20,opt,name=client_supplied_steamid,json=clientSuppliedSteamid" json:"client_supplied_steamid,omitempty"`
ParentalSettings []byte `protobuf:"bytes,22,opt,name=parental_settings" json:"parental_settings,omitempty"` IpCountryCode *string `protobuf:"bytes,21,opt,name=ip_country_code,json=ipCountryCode" json:"ip_country_code,omitempty"`
ParentalSettingSignature []byte `protobuf:"bytes,23,opt,name=parental_setting_signature" json:"parental_setting_signature,omitempty"` ParentalSettings []byte `protobuf:"bytes,22,opt,name=parental_settings,json=parentalSettings" json:"parental_settings,omitempty"`
CountLoginfailuresToMigrate *int32 `protobuf:"varint,24,opt,name=count_loginfailures_to_migrate" json:"count_loginfailures_to_migrate,omitempty"` ParentalSettingSignature []byte `protobuf:"bytes,23,opt,name=parental_setting_signature,json=parentalSettingSignature" json:"parental_setting_signature,omitempty"`
CountDisconnectsToMigrate *int32 `protobuf:"varint,25,opt,name=count_disconnects_to_migrate" json:"count_disconnects_to_migrate,omitempty"` CountLoginfailuresToMigrate *int32 `protobuf:"varint,24,opt,name=count_loginfailures_to_migrate,json=countLoginfailuresToMigrate" json:"count_loginfailures_to_migrate,omitempty"`
OgsDataReportTimeWindow *int32 `protobuf:"varint,26,opt,name=ogs_data_report_time_window" json:"ogs_data_report_time_window,omitempty"` CountDisconnectsToMigrate *int32 `protobuf:"varint,25,opt,name=count_disconnects_to_migrate,json=countDisconnectsToMigrate" json:"count_disconnects_to_migrate,omitempty"`
ClientInstanceId *uint64 `protobuf:"varint,27,opt,name=client_instance_id" json:"client_instance_id,omitempty"` OgsDataReportTimeWindow *int32 `protobuf:"varint,26,opt,name=ogs_data_report_time_window,json=ogsDataReportTimeWindow" json:"ogs_data_report_time_window,omitempty"`
ForceClientUpdateCheck *bool `protobuf:"varint,28,opt,name=force_client_update_check" json:"force_client_update_check,omitempty"` ClientInstanceId *uint64 `protobuf:"varint,27,opt,name=client_instance_id,json=clientInstanceId" json:"client_instance_id,omitempty"`
ForceClientUpdateCheck *bool `protobuf:"varint,28,opt,name=force_client_update_check,json=forceClientUpdateCheck" json:"force_client_update_check,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -600,7 +704,7 @@ func (m *CMsgClientLogonResponse) Reset() { *m = CMsgClientLogonResponse
func (m *CMsgClientLogonResponse) String() string { return proto.CompactTextString(m) } func (m *CMsgClientLogonResponse) String() string { return proto.CompactTextString(m) }
func (*CMsgClientLogonResponse) ProtoMessage() {} func (*CMsgClientLogonResponse) ProtoMessage() {}
func (*CMsgClientLogonResponse) Descriptor() ([]byte, []int) { func (*CMsgClientLogonResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_c98cb07f62c057af, []int{4} return fileDescriptor_c98cb07f62c057af, []int{5}
} }
func (m *CMsgClientLogonResponse) XXX_Unmarshal(b []byte) error { func (m *CMsgClientLogonResponse) XXX_Unmarshal(b []byte) error {
@@ -644,9 +748,9 @@ func (m *CMsgClientLogonResponse) GetInGameHeartbeatSeconds() int32 {
return 0 return 0
} }
func (m *CMsgClientLogonResponse) GetPublicIp() uint32 { func (m *CMsgClientLogonResponse) GetDeprecatedPublicIp() uint32 {
if m != nil && m.PublicIp != nil { if m != nil && m.DeprecatedPublicIp != nil {
return *m.PublicIp return *m.DeprecatedPublicIp
} }
return 0 return 0
} }
@@ -707,9 +811,9 @@ func (m *CMsgClientLogonResponse) GetCellIdPingThreshold() uint32 {
return 0 return 0
} }
func (m *CMsgClientLogonResponse) GetUsePics() bool { func (m *CMsgClientLogonResponse) GetDeprecatedUsePics() bool {
if m != nil && m.UsePics != nil { if m != nil && m.DeprecatedUsePics != nil {
return *m.UsePics return *m.DeprecatedUsePics
} }
return false return false
} }
@@ -721,6 +825,13 @@ func (m *CMsgClientLogonResponse) GetVanityUrl() string {
return "" return ""
} }
func (m *CMsgClientLogonResponse) GetPublicIp() *CMsgIPAddress {
if m != nil {
return m.PublicIp
}
return nil
}
func (m *CMsgClientLogonResponse) GetClientSuppliedSteamid() uint64 { func (m *CMsgClientLogonResponse) GetClientSuppliedSteamid() uint64 {
if m != nil && m.ClientSuppliedSteamid != nil { if m != nil && m.ClientSuppliedSteamid != nil {
return *m.ClientSuppliedSteamid return *m.ClientSuppliedSteamid
@@ -785,7 +896,7 @@ func (m *CMsgClientLogonResponse) GetForceClientUpdateCheck() bool {
} }
type CMsgClientRequestWebAPIAuthenticateUserNonce struct { type CMsgClientRequestWebAPIAuthenticateUserNonce struct {
TokenType *int32 `protobuf:"varint,1,opt,name=token_type,def=-1" json:"token_type,omitempty"` TokenType *int32 `protobuf:"varint,1,opt,name=token_type,json=tokenType,def=-1" json:"token_type,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -799,7 +910,7 @@ func (m *CMsgClientRequestWebAPIAuthenticateUserNonce) String() string {
} }
func (*CMsgClientRequestWebAPIAuthenticateUserNonce) ProtoMessage() {} func (*CMsgClientRequestWebAPIAuthenticateUserNonce) ProtoMessage() {}
func (*CMsgClientRequestWebAPIAuthenticateUserNonce) Descriptor() ([]byte, []int) { func (*CMsgClientRequestWebAPIAuthenticateUserNonce) Descriptor() ([]byte, []int) {
return fileDescriptor_c98cb07f62c057af, []int{5} return fileDescriptor_c98cb07f62c057af, []int{6}
} }
func (m *CMsgClientRequestWebAPIAuthenticateUserNonce) XXX_Unmarshal(b []byte) error { func (m *CMsgClientRequestWebAPIAuthenticateUserNonce) XXX_Unmarshal(b []byte) error {
@@ -831,8 +942,8 @@ func (m *CMsgClientRequestWebAPIAuthenticateUserNonce) GetTokenType() int32 {
type CMsgClientRequestWebAPIAuthenticateUserNonceResponse struct { type CMsgClientRequestWebAPIAuthenticateUserNonceResponse struct {
Eresult *int32 `protobuf:"varint,1,opt,name=eresult,def=2" json:"eresult,omitempty"` Eresult *int32 `protobuf:"varint,1,opt,name=eresult,def=2" json:"eresult,omitempty"`
WebapiAuthenticateUserNonce *string `protobuf:"bytes,11,opt,name=webapi_authenticate_user_nonce" json:"webapi_authenticate_user_nonce,omitempty"` WebapiAuthenticateUserNonce *string `protobuf:"bytes,11,opt,name=webapi_authenticate_user_nonce,json=webapiAuthenticateUserNonce" json:"webapi_authenticate_user_nonce,omitempty"`
TokenType *int32 `protobuf:"varint,3,opt,name=token_type,def=-1" json:"token_type,omitempty"` TokenType *int32 `protobuf:"varint,3,opt,name=token_type,json=tokenType,def=-1" json:"token_type,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -846,7 +957,7 @@ func (m *CMsgClientRequestWebAPIAuthenticateUserNonceResponse) String() string {
} }
func (*CMsgClientRequestWebAPIAuthenticateUserNonceResponse) ProtoMessage() {} func (*CMsgClientRequestWebAPIAuthenticateUserNonceResponse) ProtoMessage() {}
func (*CMsgClientRequestWebAPIAuthenticateUserNonceResponse) Descriptor() ([]byte, []int) { func (*CMsgClientRequestWebAPIAuthenticateUserNonceResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_c98cb07f62c057af, []int{6} return fileDescriptor_c98cb07f62c057af, []int{7}
} }
func (m *CMsgClientRequestWebAPIAuthenticateUserNonceResponse) XXX_Unmarshal(b []byte) error { func (m *CMsgClientRequestWebAPIAuthenticateUserNonceResponse) XXX_Unmarshal(b []byte) error {
@@ -901,7 +1012,7 @@ func (m *CMsgClientLogOff) Reset() { *m = CMsgClientLogOff{} }
func (m *CMsgClientLogOff) String() string { return proto.CompactTextString(m) } func (m *CMsgClientLogOff) String() string { return proto.CompactTextString(m) }
func (*CMsgClientLogOff) ProtoMessage() {} func (*CMsgClientLogOff) ProtoMessage() {}
func (*CMsgClientLogOff) Descriptor() ([]byte, []int) { func (*CMsgClientLogOff) Descriptor() ([]byte, []int) {
return fileDescriptor_c98cb07f62c057af, []int{7} return fileDescriptor_c98cb07f62c057af, []int{8}
} }
func (m *CMsgClientLogOff) XXX_Unmarshal(b []byte) error { func (m *CMsgClientLogOff) XXX_Unmarshal(b []byte) error {
@@ -933,7 +1044,7 @@ func (m *CMsgClientLoggedOff) Reset() { *m = CMsgClientLoggedOff{} }
func (m *CMsgClientLoggedOff) String() string { return proto.CompactTextString(m) } func (m *CMsgClientLoggedOff) String() string { return proto.CompactTextString(m) }
func (*CMsgClientLoggedOff) ProtoMessage() {} func (*CMsgClientLoggedOff) ProtoMessage() {}
func (*CMsgClientLoggedOff) Descriptor() ([]byte, []int) { func (*CMsgClientLoggedOff) Descriptor() ([]byte, []int) {
return fileDescriptor_c98cb07f62c057af, []int{8} return fileDescriptor_c98cb07f62c057af, []int{9}
} }
func (m *CMsgClientLoggedOff) XXX_Unmarshal(b []byte) error { func (m *CMsgClientLoggedOff) XXX_Unmarshal(b []byte) error {
@@ -964,8 +1075,8 @@ func (m *CMsgClientLoggedOff) GetEresult() int32 {
} }
type CMsgClientNewLoginKey struct { type CMsgClientNewLoginKey struct {
UniqueId *uint32 `protobuf:"varint,1,opt,name=unique_id" json:"unique_id,omitempty"` UniqueId *uint32 `protobuf:"varint,1,opt,name=unique_id,json=uniqueId" json:"unique_id,omitempty"`
LoginKey *string `protobuf:"bytes,2,opt,name=login_key" json:"login_key,omitempty"` LoginKey *string `protobuf:"bytes,2,opt,name=login_key,json=loginKey" json:"login_key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -975,7 +1086,7 @@ func (m *CMsgClientNewLoginKey) Reset() { *m = CMsgClientNewLoginKey{} }
func (m *CMsgClientNewLoginKey) String() string { return proto.CompactTextString(m) } func (m *CMsgClientNewLoginKey) String() string { return proto.CompactTextString(m) }
func (*CMsgClientNewLoginKey) ProtoMessage() {} func (*CMsgClientNewLoginKey) ProtoMessage() {}
func (*CMsgClientNewLoginKey) Descriptor() ([]byte, []int) { func (*CMsgClientNewLoginKey) Descriptor() ([]byte, []int) {
return fileDescriptor_c98cb07f62c057af, []int{9} return fileDescriptor_c98cb07f62c057af, []int{10}
} }
func (m *CMsgClientNewLoginKey) XXX_Unmarshal(b []byte) error { func (m *CMsgClientNewLoginKey) XXX_Unmarshal(b []byte) error {
@@ -1011,7 +1122,7 @@ func (m *CMsgClientNewLoginKey) GetLoginKey() string {
} }
type CMsgClientNewLoginKeyAccepted struct { type CMsgClientNewLoginKeyAccepted struct {
UniqueId *uint32 `protobuf:"varint,1,opt,name=unique_id" json:"unique_id,omitempty"` UniqueId *uint32 `protobuf:"varint,1,opt,name=unique_id,json=uniqueId" json:"unique_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -1021,7 +1132,7 @@ func (m *CMsgClientNewLoginKeyAccepted) Reset() { *m = CMsgClientNewLogi
func (m *CMsgClientNewLoginKeyAccepted) String() string { return proto.CompactTextString(m) } func (m *CMsgClientNewLoginKeyAccepted) String() string { return proto.CompactTextString(m) }
func (*CMsgClientNewLoginKeyAccepted) ProtoMessage() {} func (*CMsgClientNewLoginKeyAccepted) ProtoMessage() {}
func (*CMsgClientNewLoginKeyAccepted) Descriptor() ([]byte, []int) { func (*CMsgClientNewLoginKeyAccepted) Descriptor() ([]byte, []int) {
return fileDescriptor_c98cb07f62c057af, []int{10} return fileDescriptor_c98cb07f62c057af, []int{11}
} }
func (m *CMsgClientNewLoginKeyAccepted) XXX_Unmarshal(b []byte) error { func (m *CMsgClientNewLoginKeyAccepted) XXX_Unmarshal(b []byte) error {
@@ -1050,18 +1161,18 @@ func (m *CMsgClientNewLoginKeyAccepted) GetUniqueId() uint32 {
} }
type CMsgClientAccountInfo struct { type CMsgClientAccountInfo struct {
PersonaName *string `protobuf:"bytes,1,opt,name=persona_name" json:"persona_name,omitempty"` PersonaName *string `protobuf:"bytes,1,opt,name=persona_name,json=personaName" json:"persona_name,omitempty"`
IpCountry *string `protobuf:"bytes,2,opt,name=ip_country" json:"ip_country,omitempty"` IpCountry *string `protobuf:"bytes,2,opt,name=ip_country,json=ipCountry" json:"ip_country,omitempty"`
CountAuthedComputers *int32 `protobuf:"varint,5,opt,name=count_authed_computers" json:"count_authed_computers,omitempty"` CountAuthedComputers *int32 `protobuf:"varint,5,opt,name=count_authed_computers,json=countAuthedComputers" json:"count_authed_computers,omitempty"`
AccountFlags *uint32 `protobuf:"varint,7,opt,name=account_flags" json:"account_flags,omitempty"` AccountFlags *uint32 `protobuf:"varint,7,opt,name=account_flags,json=accountFlags" json:"account_flags,omitempty"`
FacebookId *uint64 `protobuf:"varint,8,opt,name=facebook_id" json:"facebook_id,omitempty"` FacebookId *uint64 `protobuf:"varint,8,opt,name=facebook_id,json=facebookId" json:"facebook_id,omitempty"`
FacebookName *string `protobuf:"bytes,9,opt,name=facebook_name" json:"facebook_name,omitempty"` FacebookName *string `protobuf:"bytes,9,opt,name=facebook_name,json=facebookName" json:"facebook_name,omitempty"`
SteamguardNotifyNewmachines *bool `protobuf:"varint,14,opt,name=steamguard_notify_newmachines" json:"steamguard_notify_newmachines,omitempty"` SteamguardNotifyNewmachines *bool `protobuf:"varint,14,opt,name=steamguard_notify_newmachines,json=steamguardNotifyNewmachines" json:"steamguard_notify_newmachines,omitempty"`
SteamguardMachineNameUserChosen *string `protobuf:"bytes,15,opt,name=steamguard_machine_name_user_chosen" json:"steamguard_machine_name_user_chosen,omitempty"` SteamguardMachineNameUserChosen *string `protobuf:"bytes,15,opt,name=steamguard_machine_name_user_chosen,json=steamguardMachineNameUserChosen" json:"steamguard_machine_name_user_chosen,omitempty"`
IsPhoneVerified *bool `protobuf:"varint,16,opt,name=is_phone_verified" json:"is_phone_verified,omitempty"` IsPhoneVerified *bool `protobuf:"varint,16,opt,name=is_phone_verified,json=isPhoneVerified" json:"is_phone_verified,omitempty"`
TwoFactorState *uint32 `protobuf:"varint,17,opt,name=two_factor_state" json:"two_factor_state,omitempty"` TwoFactorState *uint32 `protobuf:"varint,17,opt,name=two_factor_state,json=twoFactorState" json:"two_factor_state,omitempty"`
IsPhoneIdentifying *bool `protobuf:"varint,18,opt,name=is_phone_identifying" json:"is_phone_identifying,omitempty"` IsPhoneIdentifying *bool `protobuf:"varint,18,opt,name=is_phone_identifying,json=isPhoneIdentifying" json:"is_phone_identifying,omitempty"`
IsPhoneNeedingReverify *bool `protobuf:"varint,19,opt,name=is_phone_needing_reverify" json:"is_phone_needing_reverify,omitempty"` IsPhoneNeedingReverify *bool `protobuf:"varint,19,opt,name=is_phone_needing_reverify,json=isPhoneNeedingReverify" json:"is_phone_needing_reverify,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -1071,7 +1182,7 @@ func (m *CMsgClientAccountInfo) Reset() { *m = CMsgClientAccountInfo{} }
func (m *CMsgClientAccountInfo) String() string { return proto.CompactTextString(m) } func (m *CMsgClientAccountInfo) String() string { return proto.CompactTextString(m) }
func (*CMsgClientAccountInfo) ProtoMessage() {} func (*CMsgClientAccountInfo) ProtoMessage() {}
func (*CMsgClientAccountInfo) Descriptor() ([]byte, []int) { func (*CMsgClientAccountInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_c98cb07f62c057af, []int{11} return fileDescriptor_c98cb07f62c057af, []int{12}
} }
func (m *CMsgClientAccountInfo) XXX_Unmarshal(b []byte) error { func (m *CMsgClientAccountInfo) XXX_Unmarshal(b []byte) error {
@@ -1176,10 +1287,89 @@ func (m *CMsgClientAccountInfo) GetIsPhoneNeedingReverify() bool {
return false return false
} }
type CMsgClientChallengeRequest struct {
Steamid *uint64 `protobuf:"fixed64,1,opt,name=steamid" json:"steamid,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CMsgClientChallengeRequest) Reset() { *m = CMsgClientChallengeRequest{} }
func (m *CMsgClientChallengeRequest) String() string { return proto.CompactTextString(m) }
func (*CMsgClientChallengeRequest) ProtoMessage() {}
func (*CMsgClientChallengeRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_c98cb07f62c057af, []int{13}
}
func (m *CMsgClientChallengeRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CMsgClientChallengeRequest.Unmarshal(m, b)
}
func (m *CMsgClientChallengeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CMsgClientChallengeRequest.Marshal(b, m, deterministic)
}
func (m *CMsgClientChallengeRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CMsgClientChallengeRequest.Merge(m, src)
}
func (m *CMsgClientChallengeRequest) XXX_Size() int {
return xxx_messageInfo_CMsgClientChallengeRequest.Size(m)
}
func (m *CMsgClientChallengeRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CMsgClientChallengeRequest.DiscardUnknown(m)
}
var xxx_messageInfo_CMsgClientChallengeRequest proto.InternalMessageInfo
func (m *CMsgClientChallengeRequest) GetSteamid() uint64 {
if m != nil && m.Steamid != nil {
return *m.Steamid
}
return 0
}
type CMsgClientChallengeResponse struct {
Challenge *uint64 `protobuf:"fixed64,1,opt,name=challenge" json:"challenge,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CMsgClientChallengeResponse) Reset() { *m = CMsgClientChallengeResponse{} }
func (m *CMsgClientChallengeResponse) String() string { return proto.CompactTextString(m) }
func (*CMsgClientChallengeResponse) ProtoMessage() {}
func (*CMsgClientChallengeResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_c98cb07f62c057af, []int{14}
}
func (m *CMsgClientChallengeResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CMsgClientChallengeResponse.Unmarshal(m, b)
}
func (m *CMsgClientChallengeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CMsgClientChallengeResponse.Marshal(b, m, deterministic)
}
func (m *CMsgClientChallengeResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_CMsgClientChallengeResponse.Merge(m, src)
}
func (m *CMsgClientChallengeResponse) XXX_Size() int {
return xxx_messageInfo_CMsgClientChallengeResponse.Size(m)
}
func (m *CMsgClientChallengeResponse) XXX_DiscardUnknown() {
xxx_messageInfo_CMsgClientChallengeResponse.DiscardUnknown(m)
}
var xxx_messageInfo_CMsgClientChallengeResponse proto.InternalMessageInfo
func (m *CMsgClientChallengeResponse) GetChallenge() uint64 {
if m != nil && m.Challenge != nil {
return *m.Challenge
}
return 0
}
func init() { func init() {
proto.RegisterType((*CMsgClientHeartBeat)(nil), "CMsgClientHeartBeat") proto.RegisterType((*CMsgClientHeartBeat)(nil), "CMsgClientHeartBeat")
proto.RegisterType((*CMsgClientServerTimestampRequest)(nil), "CMsgClientServerTimestampRequest") proto.RegisterType((*CMsgClientServerTimestampRequest)(nil), "CMsgClientServerTimestampRequest")
proto.RegisterType((*CMsgClientServerTimestampResponse)(nil), "CMsgClientServerTimestampResponse") proto.RegisterType((*CMsgClientServerTimestampResponse)(nil), "CMsgClientServerTimestampResponse")
proto.RegisterType((*CMsgClientSecret)(nil), "CMsgClientSecret")
proto.RegisterType((*CMsgClientLogon)(nil), "CMsgClientLogon") proto.RegisterType((*CMsgClientLogon)(nil), "CMsgClientLogon")
proto.RegisterType((*CMsgClientLogonResponse)(nil), "CMsgClientLogonResponse") proto.RegisterType((*CMsgClientLogonResponse)(nil), "CMsgClientLogonResponse")
proto.RegisterType((*CMsgClientRequestWebAPIAuthenticateUserNonce)(nil), "CMsgClientRequestWebAPIAuthenticateUserNonce") proto.RegisterType((*CMsgClientRequestWebAPIAuthenticateUserNonce)(nil), "CMsgClientRequestWebAPIAuthenticateUserNonce")
@@ -1189,6 +1379,8 @@ func init() {
proto.RegisterType((*CMsgClientNewLoginKey)(nil), "CMsgClientNewLoginKey") proto.RegisterType((*CMsgClientNewLoginKey)(nil), "CMsgClientNewLoginKey")
proto.RegisterType((*CMsgClientNewLoginKeyAccepted)(nil), "CMsgClientNewLoginKeyAccepted") proto.RegisterType((*CMsgClientNewLoginKeyAccepted)(nil), "CMsgClientNewLoginKeyAccepted")
proto.RegisterType((*CMsgClientAccountInfo)(nil), "CMsgClientAccountInfo") proto.RegisterType((*CMsgClientAccountInfo)(nil), "CMsgClientAccountInfo")
proto.RegisterType((*CMsgClientChallengeRequest)(nil), "CMsgClientChallengeRequest")
proto.RegisterType((*CMsgClientChallengeResponse)(nil), "CMsgClientChallengeResponse")
} }
func init() { func init() {
@@ -1196,99 +1388,151 @@ func init() {
} }
var fileDescriptor_c98cb07f62c057af = []byte{ var fileDescriptor_c98cb07f62c057af = []byte{
// 1495 bytes of a gzipped FileDescriptorProto // 2325 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x56, 0x5b, 0x73, 0x13, 0x47, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x58, 0x5b, 0x77, 0x1b, 0xb7,
0x16, 0x5e, 0x01, 0xc2, 0xd6, 0xc1, 0xc6, 0xf2, 0xd8, 0xb2, 0xdb, 0x57, 0x64, 0x71, 0x33, 0xcb, 0xd5, 0xfd, 0x98, 0x58, 0x96, 0x08, 0x51, 0xb7, 0xd1, 0x0d, 0x92, 0x7c, 0x91, 0x98, 0xaf, 0x8e,
0xee, 0xd6, 0xae, 0xa1, 0xf6, 0x81, 0x4a, 0x1e, 0x0c, 0x29, 0x0a, 0x2a, 0x04, 0x08, 0x97, 0x90, 0x12, 0x27, 0x5e, 0x8e, 0x9c, 0x95, 0x36, 0xa9, 0xd7, 0x4a, 0x65, 0xb9, 0x4e, 0xb8, 0xa2, 0x0b,
0xca, 0xad, 0xd3, 0xea, 0x39, 0x33, 0xea, 0xf2, 0x4c, 0xf7, 0xd0, 0xdd, 0x23, 0xa1, 0xb7, 0x3c, 0x33, 0x92, 0x9c, 0x5e, 0xd2, 0xa2, 0xe0, 0xcc, 0xe1, 0x10, 0xd5, 0x10, 0x18, 0x0f, 0x30, 0x62,
0xe7, 0xcf, 0xe4, 0x7f, 0xe4, 0xc7, 0xe4, 0x37, 0xa4, 0xfa, 0x8c, 0x46, 0x92, 0xc1, 0x21, 0xc9, 0xf8, 0xd6, 0xc7, 0xbe, 0xf4, 0xa9, 0x7f, 0xa5, 0x6f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b, 0xb5, 0x39,
0x7e, 0x64, 0xf0, 0x98, 0x77, 0x78, 0x4b, 0xb8, 0xfc, 0xfd, 0x09, 0xf5, 0x64, 0xda, 0xeb, 0x1d,
0x39, 0xaf, 0xf7, 0x21, 0x59, 0x11, 0x9a, 0x65, 0x03, 0xe5, 0xfe, 0x6d, 0x60, 0xdd, 0x7d, 0x4c,
0x97, 0x31, 0x8b, 0x25, 0xa1, 0xbb, 0x16, 0x7f, 0xe9, 0xe1, 0x60, 0x9f, 0x2c, 0xd7, 0xcc, 0x99,
0x36, 0xb6, 0x01, 0xad, 0xe0, 0x59, 0x2d, 0x56, 0xee, 0xec, 0xdc, 0xa2, 0xf6, 0x3d, 0xaf, 0x66,
0xf5, 0x3f, 0x25, 0xc6, 0x42, 0x26, 0x34, 0xc0, 0x89, 0x03, 0x3f, 0x71, 0x67, 0x12, 0x41, 0xf3,
0x50, 0x8e, 0xb0, 0x6e, 0xdd, 0xf6, 0xda, 0x1c, 0x30, 0xa3, 0x31, 0x5d, 0x75, 0xbd, 0xc3, 0x0f,
0x3b, 0x75, 0xe1, 0xd0, 0x47, 0xdb, 0x9f, 0x91, 0xed, 0x89, 0xa0, 0x8e, 0x06, 0x3c, 0x4d, 0x41,
0x26, 0x50, 0xfe, 0xea, 0xa0, 0x64, 0xb6, 0x7c, 0x41, 0x1a, 0xf8, 0x82, 0x94, 0x9f, 0xed, 0x9f,
0x93, 0x9d, 0x1b, 0xc7, 0xf9, 0x36, 0x70, 0x07, 0x7f, 0xa8, 0x3b, 0xd0, 0x0f, 0x9d, 0x00, 0xcf,
0x66, 0xbe, 0x6e, 0xfc, 0xa9, 0xf1, 0x7f, 0xff, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xa0, 0x4a, 0xca,
0x5a, 0xd7, 0x14, 0x00, 0x00,
} }
@@ -21,9 +21,9 @@ var _ = math.Inf
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type CMsgClientSiteInfo struct { type CMsgClientSiteInfo struct {
SiteId *uint64 `protobuf:"varint,1,opt,name=site_id" json:"site_id,omitempty"` SiteId *uint64 `protobuf:"varint,1,opt,name=site_id,json=siteId" json:"site_id,omitempty"`
SiteName *string `protobuf:"bytes,2,opt,name=site_name" json:"site_name,omitempty"` SiteName *string `protobuf:"bytes,2,opt,name=site_name,json=siteName" json:"site_name,omitempty"`
AllowCachedCredentials *bool `protobuf:"varint,3,opt,name=allow_cached_credentials" json:"allow_cached_credentials,omitempty"` AllowCachedCredentials *bool `protobuf:"varint,3,opt,name=allow_cached_credentials,json=allowCachedCredentials" json:"allow_cached_credentials,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -283,11 +283,11 @@ func (m *CMsgClientSiteLicenseGetContentCacheInfo) XXX_DiscardUnknown() {
var xxx_messageInfo_CMsgClientSiteLicenseGetContentCacheInfo proto.InternalMessageInfo var xxx_messageInfo_CMsgClientSiteLicenseGetContentCacheInfo proto.InternalMessageInfo
type CMsgClientSiteLicenseGetContentCacheInfoResponse struct { type CMsgClientSiteLicenseGetContentCacheInfoResponse struct {
UseCache *bool `protobuf:"varint,1,opt,name=use_cache" json:"use_cache,omitempty"` UseCache *bool `protobuf:"varint,1,opt,name=use_cache,json=useCache" json:"use_cache,omitempty"`
Ipv4Address *uint32 `protobuf:"varint,2,opt,name=ipv4_address" json:"ipv4_address,omitempty"` Ipv4Address *uint32 `protobuf:"varint,2,opt,name=ipv4_address,json=ipv4Address" json:"ipv4_address,omitempty"`
PortNumber *uint32 `protobuf:"varint,3,opt,name=port_number" json:"port_number,omitempty"` PortNumber *uint32 `protobuf:"varint,3,opt,name=port_number,json=portNumber" json:"port_number,omitempty"`
P2PGroup *uint32 `protobuf:"varint,4,opt,name=p2p_group" json:"p2p_group,omitempty"` P2PGroup *uint32 `protobuf:"varint,4,opt,name=p2p_group,json=p2pGroup" json:"p2p_group,omitempty"`
IpAddress *string `protobuf:"bytes,5,opt,name=ip_address" json:"ip_address,omitempty"` IpAddress *string `protobuf:"bytes,5,opt,name=ip_address,json=ipAddress" json:"ip_address,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -372,26 +372,30 @@ func init() {
} }
var fileDescriptor_0a32817a56a37a6e = []byte{ var fileDescriptor_0a32817a56a37a6e = []byte{
// 335 bytes of a gzipped FileDescriptorProto // 393 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x41, 0x4b, 0xfb, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x4f, 0x8b, 0xd3, 0x40,
0x14, 0xc4, 0xff, 0xfb, 0xb7, 0xa1, 0xed, 0xd3, 0x20, 0x5d, 0x3d, 0x04, 0x41, 0x08, 0x81, 0x4a, 0x14, 0x77, 0x74, 0xe3, 0x26, 0x6f, 0xed, 0x65, 0x10, 0x0d, 0x2e, 0x8b, 0x35, 0xb0, 0x12, 0x3c,
0xf0, 0x50, 0xa4, 0x08, 0x82, 0x9e, 0x34, 0x07, 0x15, 0xf4, 0x62, 0x6f, 0x5e, 0xc2, 0x36, 0x79, 0x2c, 0x52, 0x14, 0xc4, 0x83, 0xb0, 0x46, 0x58, 0x17, 0xb4, 0x87, 0xe9, 0x07, 0x08, 0xd3, 0xe4,
0xb6, 0x8b, 0x9b, 0xdd, 0x25, 0x6f, 0x53, 0xaf, 0x7e, 0x0b, 0xbf, 0xae, 0x64, 0x5b,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x67, 0x7b, 0x5f, 0x9b, 0xa1, 0x5b, 0x62, 0x1f,
0xef, 0x3d, 0x11, 0x10, 0xa8, 0x79, 0x64, 0xc2, 0x00, 0x37, 0x73, 0xf5, 0xaa, 0xb7, 0x83, 0xcb,
0x4f, 0xa2, 0x9c, 0xba, 0x99, 0xbb, 0x09, 0x98, 0x5f, 0x00, 0x28, 0xf7, 0x3b, 0x3e, 0x89, 0x3f,
0x56, 0xa6, 0xdc, 0x36, 0xfc, 0x7d, 0xf2, 0x91, 0x7d, 0x67, 0x77, 0x7e, 0x05, 0x00, 0x00, 0xff,
0xff, 0x35, 0x87, 0xfb, 0x5f, 0xef, 0x02, 0x00, 0x00,
} }
@@ -20,6 +20,46 @@ var _ = math.Inf
// proto package protobuf to be updated. // proto package protobuf to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type EContentDeltaChunkDataLocation int32
const (
EContentDeltaChunkDataLocation_k_EContentDeltaChunkDataLocationInProtobuf EContentDeltaChunkDataLocation = 0
EContentDeltaChunkDataLocation_k_EContentDeltaChunkDataLocationAfterProtobuf EContentDeltaChunkDataLocation = 1
)
var EContentDeltaChunkDataLocation_name = map[int32]string{
0: "k_EContentDeltaChunkDataLocationInProtobuf",
1: "k_EContentDeltaChunkDataLocationAfterProtobuf",
}
var EContentDeltaChunkDataLocation_value = map[string]int32{
"k_EContentDeltaChunkDataLocationInProtobuf": 0,
"k_EContentDeltaChunkDataLocationAfterProtobuf": 1,
}
func (x EContentDeltaChunkDataLocation) Enum() *EContentDeltaChunkDataLocation {
p := new(EContentDeltaChunkDataLocation)
*p = x
return p
}
func (x EContentDeltaChunkDataLocation) String() string {
return proto.EnumName(EContentDeltaChunkDataLocation_name, int32(x))
}
func (x *EContentDeltaChunkDataLocation) UnmarshalJSON(data []byte) error {
value, err := proto.UnmarshalJSONEnum(EContentDeltaChunkDataLocation_value, data, "EContentDeltaChunkDataLocation")
if err != nil {
return err
}
*x = EContentDeltaChunkDataLocation(value)
return nil
}
func (EContentDeltaChunkDataLocation) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_e3cda137a29253ba, []int{0}
}
type ContentManifestPayload struct { type ContentManifestPayload struct {
Mappings []*ContentManifestPayload_FileMapping `protobuf:"bytes,1,rep,name=mappings" json:"mappings,omitempty"` Mappings []*ContentManifestPayload_FileMapping `protobuf:"bytes,1,rep,name=mappings" json:"mappings,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
@@ -63,8 +103,8 @@ type ContentManifestPayload_FileMapping struct {
Filename *string `protobuf:"bytes,1,opt,name=filename" json:"filename,omitempty"` Filename *string `protobuf:"bytes,1,opt,name=filename" json:"filename,omitempty"`
Size *uint64 `protobuf:"varint,2,opt,name=size" json:"size,omitempty"` Size *uint64 `protobuf:"varint,2,opt,name=size" json:"size,omitempty"`
Flags *uint32 `protobuf:"varint,3,opt,name=flags" json:"flags,omitempty"` Flags *uint32 `protobuf:"varint,3,opt,name=flags" json:"flags,omitempty"`
ShaFilename []byte `protobuf:"bytes,4,opt,name=sha_filename" json:"sha_filename,omitempty"` ShaFilename []byte `protobuf:"bytes,4,opt,name=sha_filename,json=shaFilename" json:"sha_filename,omitempty"`
ShaContent []byte `protobuf:"bytes,5,opt,name=sha_content" json:"sha_content,omitempty"` ShaContent []byte `protobuf:"bytes,5,opt,name=sha_content,json=shaContent" json:"sha_content,omitempty"`
Chunks []*ContentManifestPayload_FileMapping_ChunkData `protobuf:"bytes,6,rep,name=chunks" json:"chunks,omitempty"` Chunks []*ContentManifestPayload_FileMapping_ChunkData `protobuf:"bytes,6,rep,name=chunks" json:"chunks,omitempty"`
Linktarget *string `protobuf:"bytes,7,opt,name=linktarget" json:"linktarget,omitempty"` Linktarget *string `protobuf:"bytes,7,opt,name=linktarget" json:"linktarget,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
@@ -150,8 +190,8 @@ type ContentManifestPayload_FileMapping_ChunkData struct {
Sha []byte `protobuf:"bytes,1,opt,name=sha" json:"sha,omitempty"` Sha []byte `protobuf:"bytes,1,opt,name=sha" json:"sha,omitempty"`
Crc *uint32 `protobuf:"fixed32,2,opt,name=crc" json:"crc,omitempty"` Crc *uint32 `protobuf:"fixed32,2,opt,name=crc" json:"crc,omitempty"`
Offset *uint64 `protobuf:"varint,3,opt,name=offset" json:"offset,omitempty"` Offset *uint64 `protobuf:"varint,3,opt,name=offset" json:"offset,omitempty"`
CbOriginal *uint32 `protobuf:"varint,4,opt,name=cb_original" json:"cb_original,omitempty"` CbOriginal *uint32 `protobuf:"varint,4,opt,name=cb_original,json=cbOriginal" json:"cb_original,omitempty"`
CbCompressed *uint32 `protobuf:"varint,5,opt,name=cb_compressed" json:"cb_compressed,omitempty"` CbCompressed *uint32 `protobuf:"varint,5,opt,name=cb_compressed,json=cbCompressed" json:"cb_compressed,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -222,15 +262,15 @@ func (m *ContentManifestPayload_FileMapping_ChunkData) GetCbCompressed() uint32
} }
type ContentManifestMetadata struct { type ContentManifestMetadata struct {
DepotId *uint32 `protobuf:"varint,1,opt,name=depot_id" json:"depot_id,omitempty"` DepotId *uint32 `protobuf:"varint,1,opt,name=depot_id,json=depotId" json:"depot_id,omitempty"`
GidManifest *uint64 `protobuf:"varint,2,opt,name=gid_manifest" json:"gid_manifest,omitempty"` GidManifest *uint64 `protobuf:"varint,2,opt,name=gid_manifest,json=gidManifest" json:"gid_manifest,omitempty"`
CreationTime *uint32 `protobuf:"varint,3,opt,name=creation_time" json:"creation_time,omitempty"` CreationTime *uint32 `protobuf:"varint,3,opt,name=creation_time,json=creationTime" json:"creation_time,omitempty"`
FilenamesEncrypted *bool `protobuf:"varint,4,opt,name=filenames_encrypted" json:"filenames_encrypted,omitempty"` FilenamesEncrypted *bool `protobuf:"varint,4,opt,name=filenames_encrypted,json=filenamesEncrypted" json:"filenames_encrypted,omitempty"`
CbDiskOriginal *uint64 `protobuf:"varint,5,opt,name=cb_disk_original" json:"cb_disk_original,omitempty"` CbDiskOriginal *uint64 `protobuf:"varint,5,opt,name=cb_disk_original,json=cbDiskOriginal" json:"cb_disk_original,omitempty"`
CbDiskCompressed *uint64 `protobuf:"varint,6,opt,name=cb_disk_compressed" json:"cb_disk_compressed,omitempty"` CbDiskCompressed *uint64 `protobuf:"varint,6,opt,name=cb_disk_compressed,json=cbDiskCompressed" json:"cb_disk_compressed,omitempty"`
UniqueChunks *uint32 `protobuf:"varint,7,opt,name=unique_chunks" json:"unique_chunks,omitempty"` UniqueChunks *uint32 `protobuf:"varint,7,opt,name=unique_chunks,json=uniqueChunks" json:"unique_chunks,omitempty"`
CrcEncrypted *uint32 `protobuf:"varint,8,opt,name=crc_encrypted" json:"crc_encrypted,omitempty"` CrcEncrypted *uint32 `protobuf:"varint,8,opt,name=crc_encrypted,json=crcEncrypted" json:"crc_encrypted,omitempty"`
CrcClear *uint32 `protobuf:"varint,9,opt,name=crc_clear" json:"crc_clear,omitempty"` CrcClear *uint32 `protobuf:"varint,9,opt,name=crc_clear,json=crcClear" json:"crc_clear,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -364,10 +404,11 @@ func (m *ContentManifestSignature) GetSignature() []byte {
} }
type ContentDeltaChunks struct { type ContentDeltaChunks struct {
DepotId *uint32 `protobuf:"varint,1,opt,name=depot_id" json:"depot_id,omitempty"` DepotId *uint32 `protobuf:"varint,1,opt,name=depot_id,json=depotId" json:"depot_id,omitempty"`
ManifestIdSource *uint64 `protobuf:"varint,2,opt,name=manifest_id_source" json:"manifest_id_source,omitempty"` ManifestIdSource *uint64 `protobuf:"varint,2,opt,name=manifest_id_source,json=manifestIdSource" json:"manifest_id_source,omitempty"`
ManifestIdTarget *uint64 `protobuf:"varint,3,opt,name=manifest_id_target" json:"manifest_id_target,omitempty"` ManifestIdTarget *uint64 `protobuf:"varint,3,opt,name=manifest_id_target,json=manifestIdTarget" json:"manifest_id_target,omitempty"`
DeltaChunks []*ContentDeltaChunks_DeltaChunk `protobuf:"bytes,4,rep,name=deltaChunks" json:"deltaChunks,omitempty"` DeltaChunks []*ContentDeltaChunks_DeltaChunk `protobuf:"bytes,4,rep,name=deltaChunks" json:"deltaChunks,omitempty"`
ChunkDataLocation *EContentDeltaChunkDataLocation `protobuf:"varint,5,opt,name=chunk_data_location,json=chunkDataLocation,enum=EContentDeltaChunkDataLocation,def=0" json:"chunk_data_location,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -398,6 +439,8 @@ func (m *ContentDeltaChunks) XXX_DiscardUnknown() {
var xxx_messageInfo_ContentDeltaChunks proto.InternalMessageInfo var xxx_messageInfo_ContentDeltaChunks proto.InternalMessageInfo
const Default_ContentDeltaChunks_ChunkDataLocation EContentDeltaChunkDataLocation = EContentDeltaChunkDataLocation_k_EContentDeltaChunkDataLocationInProtobuf
func (m *ContentDeltaChunks) GetDepotId() uint32 { func (m *ContentDeltaChunks) GetDepotId() uint32 {
if m != nil && m.DepotId != nil { if m != nil && m.DepotId != nil {
return *m.DepotId return *m.DepotId
@@ -426,12 +469,20 @@ func (m *ContentDeltaChunks) GetDeltaChunks() []*ContentDeltaChunks_DeltaChunk {
return nil return nil
} }
func (m *ContentDeltaChunks) GetChunkDataLocation() EContentDeltaChunkDataLocation {
if m != nil && m.ChunkDataLocation != nil {
return *m.ChunkDataLocation
}
return Default_ContentDeltaChunks_ChunkDataLocation
}
type ContentDeltaChunks_DeltaChunk struct { type ContentDeltaChunks_DeltaChunk struct {
ShaSource []byte `protobuf:"bytes,1,opt,name=sha_source" json:"sha_source,omitempty"` ShaSource []byte `protobuf:"bytes,1,opt,name=sha_source,json=shaSource" json:"sha_source,omitempty"`
ShaTarget []byte `protobuf:"bytes,2,opt,name=sha_target" json:"sha_target,omitempty"` ShaTarget []byte `protobuf:"bytes,2,opt,name=sha_target,json=shaTarget" json:"sha_target,omitempty"`
SizeOriginal *uint32 `protobuf:"varint,3,opt,name=size_original" json:"size_original,omitempty"` SizeOriginal *uint32 `protobuf:"varint,3,opt,name=size_original,json=sizeOriginal" json:"size_original,omitempty"`
PatchMethod *uint32 `protobuf:"varint,4,opt,name=patch_method" json:"patch_method,omitempty"` PatchMethod *uint32 `protobuf:"varint,4,opt,name=patch_method,json=patchMethod" json:"patch_method,omitempty"`
Chunk []byte `protobuf:"bytes,5,opt,name=chunk" json:"chunk,omitempty"` Chunk []byte `protobuf:"bytes,5,opt,name=chunk" json:"chunk,omitempty"`
SizeDelta *uint32 `protobuf:"varint,6,opt,name=size_delta,json=sizeDelta" json:"size_delta,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@@ -497,7 +548,15 @@ func (m *ContentDeltaChunks_DeltaChunk) GetChunk() []byte {
return nil return nil
} }
func (m *ContentDeltaChunks_DeltaChunk) GetSizeDelta() uint32 {
if m != nil && m.SizeDelta != nil {
return *m.SizeDelta
}
return 0
}
func init() { func init() {
proto.RegisterEnum("EContentDeltaChunkDataLocation", EContentDeltaChunkDataLocation_name, EContentDeltaChunkDataLocation_value)
proto.RegisterType((*ContentManifestPayload)(nil), "ContentManifestPayload") proto.RegisterType((*ContentManifestPayload)(nil), "ContentManifestPayload")
proto.RegisterType((*ContentManifestPayload_FileMapping)(nil), "ContentManifestPayload.FileMapping") proto.RegisterType((*ContentManifestPayload_FileMapping)(nil), "ContentManifestPayload.FileMapping")
proto.RegisterType((*ContentManifestPayload_FileMapping_ChunkData)(nil), "ContentManifestPayload.FileMapping.ChunkData") proto.RegisterType((*ContentManifestPayload_FileMapping_ChunkData)(nil), "ContentManifestPayload.FileMapping.ChunkData")
@@ -510,37 +569,52 @@ func init() {
func init() { proto.RegisterFile("content_manifest.proto", fileDescriptor_e3cda137a29253ba) } func init() { proto.RegisterFile("content_manifest.proto", fileDescriptor_e3cda137a29253ba) }
var fileDescriptor_e3cda137a29253ba = []byte{ var fileDescriptor_e3cda137a29253ba = []byte{
// 508 bytes of a gzipped FileDescriptorProto // 742 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcd, 0x8e, 0xd3, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4f, 0x6f, 0xd3, 0x4e,
0x10, 0xc7, 0x49, 0xbf, 0x3b, 0x6d, 0x50, 0xf1, 0xb2, 0x8b, 0x55, 0x24, 0x54, 0x95, 0x4b, 0x2f, 0x10, 0xad, 0x9b, 0xff, 0x93, 0xa4, 0xca, 0x6f, 0xfb, 0x53, 0x31, 0x01, 0xda, 0x34, 0xbd, 0x44,
0x9b, 0x03, 0x88, 0x23, 0x17, 0x76, 0x85, 0xb8, 0x54, 0x42, 0xe2, 0x01, 0x2c, 0xd7, 0x76, 0x53, 0x55, 0x6b, 0x44, 0x4f, 0x88, 0x0b, 0x7f, 0xd2, 0x56, 0x54, 0x22, 0xa2, 0xda, 0xf6, 0xbe, 0xda,
0xab, 0x89, 0x1d, 0x6c,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xd9, 0x81, 0xdd, 0xfb, 0x9d, 0x40, 0x1e,
0xfc, 0x83, 0x5b, 0x9d, 0x0d, 0xf4, 0x0c, 0x8e, 0xff, 0x84, 0x7f, 0x3d, 0x51, 0x3c, 0xc9, 0x5b,
0x9c, 0x37, 0x95, 0xb7, 0xce, 0x27, 0x67, 0xe3, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x9c,
0xf1, 0x49, 0x52, 0x06, 0x00, 0x00,
} }
+378 -29
View File
@@ -400,6 +400,7 @@ const (
EMsg_FBSBootstrapperGetPackageChunkResponse EMsg = 1131 EMsg_FBSBootstrapperGetPackageChunkResponse EMsg = 1131
EMsg_FBSBootstrapperPackageTransferProgress EMsg = 1132 EMsg_FBSBootstrapperPackageTransferProgress EMsg = 1132
EMsg_FBSRestartBootstrapper EMsg = 1133 EMsg_FBSRestartBootstrapper EMsg = 1133
EMsg_FBSPauseFrozenDumps EMsg = 1134
EMsg_BaseFileXfer EMsg = 1200 EMsg_BaseFileXfer EMsg = 1200
EMsg_FileXferRequest EMsg = 1200 EMsg_FileXferRequest EMsg = 1200
EMsg_FileXferResponse EMsg = 1201 EMsg_FileXferResponse EMsg = 1201
@@ -416,6 +417,8 @@ const (
EMsg_BaseBS EMsg = 1400 EMsg_BaseBS EMsg = 1400
EMsg_BSPurchaseStart EMsg = 1401 EMsg_BSPurchaseStart EMsg = 1401
EMsg_BSPurchaseResponse EMsg = 1402 EMsg_BSPurchaseResponse EMsg = 1402
EMsg_BSAuthenticateCCTrans EMsg = 1403
EMsg_BSAuthenticateCCTransResponse EMsg = 1404
EMsg_BSSettleComplete EMsg = 1406 EMsg_BSSettleComplete EMsg = 1406
EMsg_BSInitPayPalTxn EMsg = 1408 EMsg_BSInitPayPalTxn EMsg = 1408
EMsg_BSInitPayPalTxnResponse EMsg = 1409 EMsg_BSInitPayPalTxnResponse EMsg = 1409
@@ -979,6 +982,8 @@ const (
EMsg_AMFundedPayment EMsg = 4418 EMsg_AMFundedPayment EMsg = 4418
EMsg_AMFundedPaymentResponse EMsg = 4419 EMsg_AMFundedPaymentResponse EMsg = 4419
EMsg_AMRequestPersonaUpdateForChatServer EMsg = 4420 EMsg_AMRequestPersonaUpdateForChatServer EMsg = 4420
EMsg_AMPerfectWorldPayment EMsg = 4421
EMsg_AMPerfectWorldPaymentResponse EMsg = 4422
EMsg_BasePSRange EMsg = 5000 EMsg_BasePSRange EMsg = 5000
EMsg_PSCreateShoppingCart EMsg = 5001 EMsg_PSCreateShoppingCart EMsg = 5001
EMsg_PSCreateShoppingCartResponse EMsg = 5002 EMsg_PSCreateShoppingCartResponse EMsg = 5002
@@ -1238,6 +1243,9 @@ const (
EMsg_ClientNetworkingCertRequestResponse EMsg = 5622 EMsg_ClientNetworkingCertRequestResponse EMsg = 5622
EMsg_ClientChallengeRequest EMsg = 5623 EMsg_ClientChallengeRequest EMsg = 5623
EMsg_ClientChallengeResponse EMsg = 5624 EMsg_ClientChallengeResponse EMsg = 5624
EMsg_BadgeCraftedNotification EMsg = 5625
EMsg_ClientNetworkingMobileCertRequest EMsg = 5626
EMsg_ClientNetworkingMobileCertRequestResponse EMsg = 5627
EMsg_BaseMDS EMsg = 5800 EMsg_BaseMDS EMsg = 5800
EMsg_AMToMDSGetDepotDecryptionKey EMsg = 5812 EMsg_AMToMDSGetDepotDecryptionKey EMsg = 5812
EMsg_MDSToAMGetDepotDecryptionKeyResponse EMsg = 5813 EMsg_MDSToAMGetDepotDecryptionKeyResponse EMsg = 5813
@@ -1303,6 +1311,8 @@ const (
EMsg_ClientMMSSetRatelimitPolicyOnClient EMsg = 6625 EMsg_ClientMMSSetRatelimitPolicyOnClient EMsg = 6625
EMsg_ClientMMSGetLobbyStatus EMsg = 6626 EMsg_ClientMMSGetLobbyStatus EMsg = 6626
EMsg_ClientMMSGetLobbyStatusResponse EMsg = 6627 EMsg_ClientMMSGetLobbyStatusResponse EMsg = 6627
EMsg_MMSGetLobbyList EMsg = 6628
EMsg_MMSGetLobbyListResponse EMsg = 6629
EMsg_NonStdMsgBase EMsg = 6800 EMsg_NonStdMsgBase EMsg = 6800
EMsg_NonStdMsgMemcached EMsg = 6801 EMsg_NonStdMsgMemcached EMsg = 6801
EMsg_NonStdMsgHTTPServer EMsg = 6802 EMsg_NonStdMsgHTTPServer EMsg = 6802
@@ -1318,6 +1328,7 @@ const (
EMsg_NonStdMsgSteam2Emulator EMsg = 6812 EMsg_NonStdMsgSteam2Emulator EMsg = 6812
EMsg_NonStdMsgRTMPServer EMsg = 6813 EMsg_NonStdMsgRTMPServer EMsg = 6813
EMsg_NonStdMsgWebSocket EMsg = 6814 EMsg_NonStdMsgWebSocket EMsg = 6814
EMsg_NonStdMsgRedis EMsg = 6815
EMsg_UDSBase EMsg = 7000 EMsg_UDSBase EMsg = 7000
EMsg_ClientUDSP2PSessionStarted EMsg = 7001 EMsg_ClientUDSP2PSessionStarted EMsg = 7001
EMsg_ClientUDSP2PSessionEnded EMsg = 7002 EMsg_ClientUDSP2PSessionEnded EMsg = 7002
@@ -2072,6 +2083,7 @@ var EMsg_name = map[EMsg]string{
1131: "EMsg_FBSBootstrapperGetPackageChunkResponse", 1131: "EMsg_FBSBootstrapperGetPackageChunkResponse",
1132: "EMsg_FBSBootstrapperPackageTransferProgress", 1132: "EMsg_FBSBootstrapperPackageTransferProgress",
1133: "EMsg_FBSRestartBootstrapper", 1133: "EMsg_FBSRestartBootstrapper",
1134: "EMsg_FBSPauseFrozenDumps",
1200: "EMsg_BaseFileXfer", 1200: "EMsg_BaseFileXfer",
1201: "EMsg_FileXferResponse", 1201: "EMsg_FileXferResponse",
1202: "EMsg_FileXferData", 1202: "EMsg_FileXferData",
@@ -2086,7 +2098,8 @@ var EMsg_name = map[EMsg]string{
1400: "EMsg_BaseBS", 1400: "EMsg_BaseBS",
1401: "EMsg_BSPurchaseStart", 1401: "EMsg_BSPurchaseStart",
1402: "EMsg_BSPurchaseResponse", 1402: "EMsg_BSPurchaseResponse",
1404: "EMsg_BSSettleNOVA", 1403: "EMsg_BSAuthenticateCCTrans",
1404: "EMsg_BSAuthenticateCCTransResponse",
1406: "EMsg_BSSettleComplete", 1406: "EMsg_BSSettleComplete",
1407: "EMsg_BSBannedRequest", 1407: "EMsg_BSBannedRequest",
1408: "EMsg_BSInitPayPalTxn", 1408: "EMsg_BSInitPayPalTxn",
@@ -2772,6 +2785,8 @@ var EMsg_name = map[EMsg]string{
4418: "EMsg_AMFundedPayment", 4418: "EMsg_AMFundedPayment",
4419: "EMsg_AMFundedPaymentResponse", 4419: "EMsg_AMFundedPaymentResponse",
4420: "EMsg_AMRequestPersonaUpdateForChatServer", 4420: "EMsg_AMRequestPersonaUpdateForChatServer",
4421: "EMsg_AMPerfectWorldPayment",
4422: "EMsg_AMPerfectWorldPaymentResponse",
5000: "EMsg_BasePSRange", 5000: "EMsg_BasePSRange",
5001: "EMsg_PSCreateShoppingCart", 5001: "EMsg_PSCreateShoppingCart",
5002: "EMsg_PSCreateShoppingCartResponse", 5002: "EMsg_PSCreateShoppingCartResponse",
@@ -3041,6 +3056,9 @@ var EMsg_name = map[EMsg]string{
5622: "EMsg_ClientNetworkingCertRequestResponse", 5622: "EMsg_ClientNetworkingCertRequestResponse",
5623: "EMsg_ClientChallengeRequest", 5623: "EMsg_ClientChallengeRequest",
5624: "EMsg_ClientChallengeResponse", 5624: "EMsg_ClientChallengeResponse",
5625: "EMsg_BadgeCraftedNotification",
5626: "EMsg_ClientNetworkingMobileCertRequest",
5627: "EMsg_ClientNetworkingMobileCertRequestResponse",
5800: "EMsg_BaseMDS", 5800: "EMsg_BaseMDS",
5801: "EMsg_ClientMDSLoginRequest", 5801: "EMsg_ClientMDSLoginRequest",
5802: "EMsg_ClientMDSLoginResponse", 5802: "EMsg_ClientMDSLoginResponse",
@@ -3136,6 +3154,8 @@ var EMsg_name = map[EMsg]string{
6625: "EMsg_ClientMMSSetRatelimitPolicyOnClient", 6625: "EMsg_ClientMMSSetRatelimitPolicyOnClient",
6626: "EMsg_ClientMMSGetLobbyStatus", 6626: "EMsg_ClientMMSGetLobbyStatus",
6627: "EMsg_ClientMMSGetLobbyStatusResponse", 6627: "EMsg_ClientMMSGetLobbyStatusResponse",
6628: "EMsg_MMSGetLobbyList",
6629: "EMsg_MMSGetLobbyListResponse",
6800: "EMsg_NonStdMsgBase", 6800: "EMsg_NonStdMsgBase",
6801: "EMsg_NonStdMsgMemcached", 6801: "EMsg_NonStdMsgMemcached",
6802: "EMsg_NonStdMsgHTTPServer", 6802: "EMsg_NonStdMsgHTTPServer",
@@ -3151,6 +3171,7 @@ var EMsg_name = map[EMsg]string{
6812: "EMsg_NonStdMsgSteam2Emulator", 6812: "EMsg_NonStdMsgSteam2Emulator",
6813: "EMsg_NonStdMsgRTMPServer", 6813: "EMsg_NonStdMsgRTMPServer",
6814: "EMsg_NonStdMsgWebSocket", 6814: "EMsg_NonStdMsgWebSocket",
6815: "EMsg_NonStdMsgRedis",
7000: "EMsg_UDSBase", 7000: "EMsg_UDSBase",
7001: "EMsg_ClientUDSP2PSessionStarted", 7001: "EMsg_ClientUDSP2PSessionStarted",
7002: "EMsg_ClientUDSP2PSessionEnded", 7002: "EMsg_ClientUDSP2PSessionEnded",
@@ -3600,6 +3621,9 @@ const (
EResult_AccountNotFriends EResult = 111 EResult_AccountNotFriends EResult = 111
EResult_LimitedUserAccount EResult = 112 EResult_LimitedUserAccount EResult = 112
EResult_CantRemoveItem EResult = 113 EResult_CantRemoveItem EResult = 113
EResult_AccountHasBeenDeleted EResult = 114
EResult_AccountHasAnExistingUserCancelledLicense EResult = 115
EResult_DeniedDueToCommunityCooldown EResult = 116
) )
var EResult_name = map[EResult]string{ var EResult_name = map[EResult]string{
@@ -3716,6 +3740,9 @@ var EResult_name = map[EResult]string{
111: "EResult_AccountNotFriends", 111: "EResult_AccountNotFriends",
112: "EResult_LimitedUserAccount", 112: "EResult_LimitedUserAccount",
113: "EResult_CantRemoveItem", 113: "EResult_CantRemoveItem",
114: "EResult_AccountHasBeenDeleted",
115: "EResult_AccountHasAnExistingUserCancelledLicense",
116: "EResult_DeniedDueToCommunityCooldown",
} }
func (e EResult) String() string { func (e EResult) String() string {
@@ -3743,7 +3770,6 @@ const (
EUniverse_Beta EUniverse = 2 EUniverse_Beta EUniverse = 2
EUniverse_Internal EUniverse = 3 EUniverse_Internal EUniverse = 3
EUniverse_Dev EUniverse = 4 EUniverse_Dev EUniverse = 4
EUniverse_Max EUniverse = 5
) )
var EUniverse_name = map[EUniverse]string{ var EUniverse_name = map[EUniverse]string{
@@ -3752,7 +3778,6 @@ var EUniverse_name = map[EUniverse]string{
2: "EUniverse_Beta", 2: "EUniverse_Beta",
3: "EUniverse_Internal", 3: "EUniverse_Internal",
4: "EUniverse_Dev", 4: "EUniverse_Dev",
5: "EUniverse_Max",
} }
func (e EUniverse) String() string { func (e EUniverse) String() string {
@@ -3836,7 +3861,6 @@ const (
EPersonaState_LookingToTrade EPersonaState = 5 EPersonaState_LookingToTrade EPersonaState = 5
EPersonaState_LookingToPlay EPersonaState = 6 EPersonaState_LookingToPlay EPersonaState = 6
EPersonaState_Invisible EPersonaState = 7 EPersonaState_Invisible EPersonaState = 7
EPersonaState_Max EPersonaState = 8
) )
var EPersonaState_name = map[EPersonaState]string{ var EPersonaState_name = map[EPersonaState]string{
@@ -3848,7 +3872,6 @@ var EPersonaState_name = map[EPersonaState]string{
5: "EPersonaState_LookingToTrade", 5: "EPersonaState_LookingToTrade",
6: "EPersonaState_LookingToPlay", 6: "EPersonaState_LookingToPlay",
7: "EPersonaState_Invisible", 7: "EPersonaState_Invisible",
8: "EPersonaState_Max",
} }
func (e EPersonaState) String() string { func (e EPersonaState) String() string {
@@ -3882,7 +3905,6 @@ const (
EAccountType_Chat EAccountType = 8 EAccountType_Chat EAccountType = 8
EAccountType_ConsoleUser EAccountType = 9 EAccountType_ConsoleUser EAccountType = 9
EAccountType_AnonUser EAccountType = 10 EAccountType_AnonUser EAccountType = 10
EAccountType_Max EAccountType = 11
) )
var EAccountType_name = map[EAccountType]string{ var EAccountType_name = map[EAccountType]string{
@@ -3897,7 +3919,6 @@ var EAccountType_name = map[EAccountType]string{
8: "EAccountType_Chat", 8: "EAccountType_Chat",
9: "EAccountType_ConsoleUser", 9: "EAccountType_ConsoleUser",
10: "EAccountType_AnonUser", 10: "EAccountType_AnonUser",
11: "EAccountType_Max",
} }
func (e EAccountType) String() string { func (e EAccountType) String() string {
@@ -3927,7 +3948,6 @@ const (
EFriendRelationship_RequestInitiator EFriendRelationship = 4 EFriendRelationship_RequestInitiator EFriendRelationship = 4
EFriendRelationship_Ignored EFriendRelationship = 5 EFriendRelationship_Ignored EFriendRelationship = 5
EFriendRelationship_IgnoredFriend EFriendRelationship = 6 EFriendRelationship_IgnoredFriend EFriendRelationship = 6
EFriendRelationship_Max EFriendRelationship = 8
) )
var EFriendRelationship_name = map[EFriendRelationship]string{ var EFriendRelationship_name = map[EFriendRelationship]string{
@@ -3939,7 +3959,6 @@ var EFriendRelationship_name = map[EFriendRelationship]string{
5: "EFriendRelationship_Ignored", 5: "EFriendRelationship_Ignored",
6: "EFriendRelationship_IgnoredFriend", 6: "EFriendRelationship_IgnoredFriend",
7: "EFriendRelationship_SuggestedFriend", 7: "EFriendRelationship_SuggestedFriend",
8: "EFriendRelationship_Max",
} }
func (e EFriendRelationship) String() string { func (e EFriendRelationship) String() string {
@@ -4212,6 +4231,7 @@ const (
EPersonaStateFlag_HasRichPresence EPersonaStateFlag = 1 EPersonaStateFlag_HasRichPresence EPersonaStateFlag = 1
EPersonaStateFlag_InJoinableGame EPersonaStateFlag = 2 EPersonaStateFlag_InJoinableGame EPersonaStateFlag = 2
EPersonaStateFlag_Golden EPersonaStateFlag = 4 EPersonaStateFlag_Golden EPersonaStateFlag = 4
EPersonaStateFlag_RemotePlayTogether EPersonaStateFlag = 8
EPersonaStateFlag_ClientTypeWeb EPersonaStateFlag = 256 EPersonaStateFlag_ClientTypeWeb EPersonaStateFlag = 256
EPersonaStateFlag_ClientTypeMobile EPersonaStateFlag = 512 EPersonaStateFlag_ClientTypeMobile EPersonaStateFlag = 512
EPersonaStateFlag_ClientTypeTenfoot EPersonaStateFlag = 1024 EPersonaStateFlag_ClientTypeTenfoot EPersonaStateFlag = 1024
@@ -4224,6 +4244,7 @@ var EPersonaStateFlag_name = map[EPersonaStateFlag]string{
1: "EPersonaStateFlag_HasRichPresence", 1: "EPersonaStateFlag_HasRichPresence",
2: "EPersonaStateFlag_InJoinableGame", 2: "EPersonaStateFlag_InJoinableGame",
4: "EPersonaStateFlag_Golden", 4: "EPersonaStateFlag_Golden",
8: "EPersonaStateFlag_RemotePlayTogether",
256: "EPersonaStateFlag_OnlineUsingWeb", 256: "EPersonaStateFlag_OnlineUsingWeb",
512: "EPersonaStateFlag_OnlineUsingMobile", 512: "EPersonaStateFlag_OnlineUsingMobile",
1024: "EPersonaStateFlag_OnlineUsingBigPicture", 1024: "EPersonaStateFlag_OnlineUsingBigPicture",
@@ -4524,6 +4545,7 @@ const (
EPaymentMethod_Valve EPaymentMethod = 129 EPaymentMethod_Valve EPaymentMethod = 129
EPaymentMethod_MasterComp EPaymentMethod = 130 EPaymentMethod_MasterComp EPaymentMethod = 130
EPaymentMethod_Promotional EPaymentMethod = 131 EPaymentMethod_Promotional EPaymentMethod = 131
EPaymentMethod_MasterSubscription EPaymentMethod = 134
EPaymentMethod_OEMTicket EPaymentMethod = 256 EPaymentMethod_OEMTicket EPaymentMethod = 256
EPaymentMethod_Split EPaymentMethod = 512 EPaymentMethod_Split EPaymentMethod = 512
EPaymentMethod_Complimentary EPaymentMethod = 1024 EPaymentMethod_Complimentary EPaymentMethod = 1024
@@ -4613,6 +4635,7 @@ var EPaymentMethod_name = map[EPaymentMethod]string{
129: "EPaymentMethod_Valve", 129: "EPaymentMethod_Valve",
130: "EPaymentMethod_SteamPressMaster", 130: "EPaymentMethod_SteamPressMaster",
131: "EPaymentMethod_StorePromotion", 131: "EPaymentMethod_StorePromotion",
134: "EPaymentMethod_MasterSubscription",
256: "EPaymentMethod_OEMTicket", 256: "EPaymentMethod_OEMTicket",
512: "EPaymentMethod_Split", 512: "EPaymentMethod_Split",
1024: "EPaymentMethod_Complimentary", 1024: "EPaymentMethod_Complimentary",
@@ -4706,6 +4729,22 @@ const (
EPurchaseResultDetail_PurchaseCannotBeReplayed EPurchaseResultDetail = 65 EPurchaseResultDetail_PurchaseCannotBeReplayed EPurchaseResultDetail = 65
EPurchaseResultDetail_DelayedCompletion EPurchaseResultDetail = 66 EPurchaseResultDetail_DelayedCompletion EPurchaseResultDetail = 66
EPurchaseResultDetail_BundleTypeCannotBeGifted EPurchaseResultDetail = 67 EPurchaseResultDetail_BundleTypeCannotBeGifted EPurchaseResultDetail = 67
EPurchaseResultDetail_BlockedByUSGov EPurchaseResultDetail = 68
EPurchaseResultDetail_ItemsReservedForCommercialUse EPurchaseResultDetail = 69
EPurchaseResultDetail_GiftAlreadyOwned EPurchaseResultDetail = 70
EPurchaseResultDetail_GiftInvalidForRecipientRegion EPurchaseResultDetail = 71
EPurchaseResultDetail_GiftPricingImbalance EPurchaseResultDetail = 72
EPurchaseResultDetail_GiftRecipientNotSpecified EPurchaseResultDetail = 73
EPurchaseResultDetail_ItemsNotAllowedForCommercialUse EPurchaseResultDetail = 74
EPurchaseResultDetail_BusinessStoreCountryCodeMismatch EPurchaseResultDetail = 75
EPurchaseResultDetail_UserAssociatedWithManyCafes EPurchaseResultDetail = 76
EPurchaseResultDetail_UserNotAssociatedWithCafe EPurchaseResultDetail = 77
EPurchaseResultDetail_AddressInvalid EPurchaseResultDetail = 78
EPurchaseResultDetail_CreditCardNumberInvalid EPurchaseResultDetail = 79
EPurchaseResultDetail_CannotShipToMilitaryPostOffice EPurchaseResultDetail = 80
EPurchaseResultDetail_BillingNameInvalidResemblesCreditCard EPurchaseResultDetail = 81
EPurchaseResultDetail_PaymentMethodTemporarilyUnavailable EPurchaseResultDetail = 82
EPurchaseResultDetail_PaymentMethodNotSupportedForProduct EPurchaseResultDetail = 83
) )
var EPurchaseResultDetail_name = map[EPurchaseResultDetail]string{ var EPurchaseResultDetail_name = map[EPurchaseResultDetail]string{
@@ -4777,6 +4816,22 @@ var EPurchaseResultDetail_name = map[EPurchaseResultDetail]string{
65: "EPurchaseResultDetail_PurchaseCannotBeReplayed", 65: "EPurchaseResultDetail_PurchaseCannotBeReplayed",
66: "EPurchaseResultDetail_DelayedCompletion", 66: "EPurchaseResultDetail_DelayedCompletion",
67: "EPurchaseResultDetail_BundleTypeCannotBeGifted", 67: "EPurchaseResultDetail_BundleTypeCannotBeGifted",
68: "EPurchaseResultDetail_BlockedByUSGov",
69: "EPurchaseResultDetail_ItemsReservedForCommercialUse",
70: "EPurchaseResultDetail_GiftAlreadyOwned",
71: "EPurchaseResultDetail_GiftInvalidForRecipientRegion",
72: "EPurchaseResultDetail_GiftPricingImbalance",
73: "EPurchaseResultDetail_GiftRecipientNotSpecified",
74: "EPurchaseResultDetail_ItemsNotAllowedForCommercialUse",
75: "EPurchaseResultDetail_BusinessStoreCountryCodeMismatch",
76: "EPurchaseResultDetail_UserAssociatedWithManyCafes",
77: "EPurchaseResultDetail_UserNotAssociatedWithCafe",
78: "EPurchaseResultDetail_AddressInvalid",
79: "EPurchaseResultDetail_CreditCardNumberInvalid",
80: "EPurchaseResultDetail_CannotShipToMilitaryPostOffice",
81: "EPurchaseResultDetail_BillingNameInvalidResemblesCreditCard",
82: "EPurchaseResultDetail_PaymentMethodTemporarilyUnavailable",
83: "EPurchaseResultDetail_PaymentMethodNotSupportedForProduct",
} }
func (e EPurchaseResultDetail) String() string { func (e EPurchaseResultDetail) String() string {
@@ -5275,7 +5330,8 @@ const (
EAppInfoSection_Store EAppInfoSection = 16 EAppInfoSection_Store EAppInfoSection = 16
EAppInfoSection_Localization EAppInfoSection = 17 EAppInfoSection_Localization EAppInfoSection = 17
EAppInfoSection_Broadcastgamedata EAppInfoSection = 18 EAppInfoSection_Broadcastgamedata EAppInfoSection = 18
EAppInfoSection_Max EAppInfoSection = 19 EAppInfoSection_Computed EAppInfoSection = 19
EAppInfoSection_Albummetadata EAppInfoSection = 20
) )
var EAppInfoSection_name = map[EAppInfoSection]string{ var EAppInfoSection_name = map[EAppInfoSection]string{
@@ -5298,7 +5354,8 @@ var EAppInfoSection_name = map[EAppInfoSection]string{
16: "EAppInfoSection_Store", 16: "EAppInfoSection_Store",
17: "EAppInfoSection_Localization", 17: "EAppInfoSection_Localization",
18: "EAppInfoSection_Broadcastgamedata", 18: "EAppInfoSection_Broadcastgamedata",
19: "EAppInfoSection_Max", 19: "EAppInfoSection_Computed",
20: "EAppInfoSection_Albummetadata",
} }
func (e EAppInfoSection) String() string { func (e EAppInfoSection) String() string {
@@ -5330,7 +5387,7 @@ const (
EContentDownloadSourceType_SLS EContentDownloadSourceType = 6 EContentDownloadSourceType_SLS EContentDownloadSourceType = 6
EContentDownloadSourceType_SteamCache EContentDownloadSourceType = 7 EContentDownloadSourceType_SteamCache EContentDownloadSourceType = 7
EContentDownloadSourceType_OpenCache EContentDownloadSourceType = 8 EContentDownloadSourceType_OpenCache EContentDownloadSourceType = 8
EContentDownloadSourceType_Max EContentDownloadSourceType = 9 EContentDownloadSourceType_LANCache EContentDownloadSourceType = 9
) )
var EContentDownloadSourceType_name = map[EContentDownloadSourceType]string{ var EContentDownloadSourceType_name = map[EContentDownloadSourceType]string{
@@ -5343,7 +5400,7 @@ var EContentDownloadSourceType_name = map[EContentDownloadSourceType]string{
6: "EContentDownloadSourceType_SLS", 6: "EContentDownloadSourceType_SLS",
7: "EContentDownloadSourceType_SteamCache", 7: "EContentDownloadSourceType_SteamCache",
8: "EContentDownloadSourceType_OpenCache", 8: "EContentDownloadSourceType_OpenCache",
9: "EContentDownloadSourceType_Max", 9: "EContentDownloadSourceType_LANCache",
} }
func (e EContentDownloadSourceType) String() string { func (e EContentDownloadSourceType) String() string {
@@ -5373,7 +5430,6 @@ const (
EPlatformType_OSX EPlatformType = 4 EPlatformType_OSX EPlatformType = 4
EPlatformType_PS3 EPlatformType = 5 EPlatformType_PS3 EPlatformType = 5
EPlatformType_Linux32 EPlatformType = 6 EPlatformType_Linux32 EPlatformType = 6
EPlatformType_Max EPlatformType = 7
) )
var EPlatformType_name = map[EPlatformType]string{ var EPlatformType_name = map[EPlatformType]string{
@@ -5384,7 +5440,6 @@ var EPlatformType_name = map[EPlatformType]string{
4: "EPlatformType_OSX", 4: "EPlatformType_OSX",
5: "EPlatformType_PS3", 5: "EPlatformType_PS3",
6: "EPlatformType_Linux32", 6: "EPlatformType_Linux32",
7: "EPlatformType_Max",
} }
func (e EPlatformType) String() string { func (e EPlatformType) String() string {
@@ -5462,6 +5517,7 @@ const (
EOSType_MacOS1012 EOSType = -85 EOSType_MacOS1012 EOSType = -85
EOSType_Macos1013 EOSType = -84 EOSType_Macos1013 EOSType = -84
EOSType_Macos1014 EOSType = -83 EOSType_Macos1014 EOSType = -83
EOSType_Macos1015 EOSType = -82
EOSType_MacOSMax EOSType = -1 EOSType_MacOSMax EOSType = -1
EOSType_LinuxUnknown EOSType = -203 EOSType_LinuxUnknown EOSType = -203
EOSType_Linux22 EOSType = -202 EOSType_Linux22 EOSType = -202
@@ -5501,7 +5557,6 @@ const (
EOSType_Windows10 EOSType = 16 EOSType_Windows10 EOSType = 16
EOSType_Win2016 EOSType = 17 EOSType_Win2016 EOSType = 17
EOSType_WinMAX EOSType = 18 EOSType_WinMAX EOSType = 18
EOSType_Max EOSType = 26
) )
var EOSType_name = map[EOSType]string{ var EOSType_name = map[EOSType]string{
@@ -5560,6 +5615,7 @@ var EOSType_name = map[EOSType]string{
-85: "EOSType_MacOS1012", -85: "EOSType_MacOS1012",
-84: "EOSType_Macos1013", -84: "EOSType_Macos1013",
-83: "EOSType_Macos1014", -83: "EOSType_Macos1014",
-82: "EOSType_Macos1015",
-203: "EOSType_LinuxUnknown", -203: "EOSType_LinuxUnknown",
-202: "EOSType_Linux22", -202: "EOSType_Linux22",
-201: "EOSType_Linux24", -201: "EOSType_Linux24",
@@ -5597,7 +5653,6 @@ var EOSType_name = map[EOSType]string{
16: "EOSType_Win10", 16: "EOSType_Win10",
17: "EOSType_Win2016", 17: "EOSType_Win2016",
18: "EOSType_WinMAX", 18: "EOSType_WinMAX",
26: "EOSType_Max",
} }
func (e EOSType) String() string { func (e EOSType) String() string {
@@ -5734,7 +5789,19 @@ const (
EServerType_TimeMachine EServerType = 111 EServerType_TimeMachine EServerType = 111
EServerType_VACDBMaster EServerType = 112 EServerType_VACDBMaster EServerType = 112
EServerType_ContentServerConfig EServerType = 113 EServerType_ContentServerConfig EServerType = 113
EServerType_Max EServerType = 114 EServerType_Minigame EServerType = 114
EServerType_MLTrain EServerType = 115
EServerType_VACTest EServerType = 116
EServerType_TaxService EServerType = 117
EServerType_MLInference EServerType = 118
EServerType_UGSAggregate EServerType = 119
EServerType_TURN EServerType = 120
EServerType_RemoteClient EServerType = 121
EServerType_BroadcastOrigin EServerType = 122
EServerType_BroadcastChannel EServerType = 123
EServerType_SteamAR EServerType = 124
EServerType_China EServerType = 125
EServerType_CrashDump EServerType = 126
) )
var EServerType_name = map[EServerType]string{ var EServerType_name = map[EServerType]string{
@@ -5856,7 +5923,19 @@ var EServerType_name = map[EServerType]string{
111: "EServerType_TimeMachine", 111: "EServerType_TimeMachine",
112: "EServerType_VACDBMaster", 112: "EServerType_VACDBMaster",
113: "EServerType_ContentServerConfig", 113: "EServerType_ContentServerConfig",
114: "EServerType_Max", 114: "EServerType_Minigame",
115: "EServerType_MLTrain",
116: "EServerType_VACTest",
117: "EServerType_TaxService",
118: "EServerType_MLInference",
119: "EServerType_UGSAggregate",
120: "EServerType_TURN",
121: "EServerType_RemoteClient",
122: "EServerType_BroadcastOrigin",
123: "EServerType_BroadcastChannel",
124: "EServerType_SteamAR",
125: "EServerType_China",
126: "EServerType_CrashDump",
} }
func (e EServerType) String() string { func (e EServerType) String() string {
@@ -6102,7 +6181,6 @@ const (
ECurrencyCode_QAR ECurrencyCode = 39 ECurrencyCode_QAR ECurrencyCode = 39
ECurrencyCode_CRC ECurrencyCode = 40 ECurrencyCode_CRC ECurrencyCode = 40
ECurrencyCode_UYU ECurrencyCode = 41 ECurrencyCode_UYU ECurrencyCode = 41
ECurrencyCode_Max ECurrencyCode = 42
) )
var ECurrencyCode_name = map[ECurrencyCode]string{ var ECurrencyCode_name = map[ECurrencyCode]string{
@@ -6147,7 +6225,6 @@ var ECurrencyCode_name = map[ECurrencyCode]string{
39: "ECurrencyCode_QAR", 39: "ECurrencyCode_QAR",
40: "ECurrencyCode_CRC", 40: "ECurrencyCode_CRC",
41: "ECurrencyCode_UYU", 41: "ECurrencyCode_UYU",
42: "ECurrencyCode_Max",
} }
func (e ECurrencyCode) String() string { func (e ECurrencyCode) String() string {
@@ -6302,7 +6379,6 @@ const (
EWorkshopFileType_SteamworksAccessInvite EWorkshopFileType = 13 EWorkshopFileType_SteamworksAccessInvite EWorkshopFileType = 13
EWorkshopFileType_SteamVideo EWorkshopFileType = 14 EWorkshopFileType_SteamVideo EWorkshopFileType = 14
EWorkshopFileType_GameManagedItem EWorkshopFileType = 15 EWorkshopFileType_GameManagedItem EWorkshopFileType = 15
EWorkshopFileType_Max EWorkshopFileType = 16
) )
var EWorkshopFileType_name = map[EWorkshopFileType]string{ var EWorkshopFileType_name = map[EWorkshopFileType]string{
@@ -6322,7 +6398,6 @@ var EWorkshopFileType_name = map[EWorkshopFileType]string{
13: "EWorkshopFileType_SteamworksAccessInvite", 13: "EWorkshopFileType_SteamworksAccessInvite",
14: "EWorkshopFileType_SteamVideo", 14: "EWorkshopFileType_SteamVideo",
15: "EWorkshopFileType_GameManagedItem", 15: "EWorkshopFileType_GameManagedItem",
16: "EWorkshopFileType_Max",
} }
func (e EWorkshopFileType) String() string { func (e EWorkshopFileType) String() string {
@@ -6548,7 +6623,6 @@ const (
ESystemIMType_GiftRevoked ESystemIMType = 7 ESystemIMType_GiftRevoked ESystemIMType = 7
ESystemIMType_SupportMessage ESystemIMType = 8 ESystemIMType_SupportMessage ESystemIMType = 8
ESystemIMType_SupportMessageClearAlert ESystemIMType = 9 ESystemIMType_SupportMessageClearAlert ESystemIMType = 9
ESystemIMType_Max ESystemIMType = 10
) )
var ESystemIMType_name = map[ESystemIMType]string{ var ESystemIMType_name = map[ESystemIMType]string{
@@ -6562,7 +6636,6 @@ var ESystemIMType_name = map[ESystemIMType]string{
7: "ESystemIMType_GiftRevoked", 7: "ESystemIMType_GiftRevoked",
8: "ESystemIMType_SupportMessage", 8: "ESystemIMType_SupportMessage",
9: "ESystemIMType_SupportMessageClearAlert", 9: "ESystemIMType_SupportMessageClearAlert",
10: "ESystemIMType_Max",
} }
func (e ESystemIMType) String() string { func (e ESystemIMType) String() string {
@@ -6623,7 +6696,7 @@ const (
ERemoteStoragePlatform_OSX ERemoteStoragePlatform = 2 ERemoteStoragePlatform_OSX ERemoteStoragePlatform = 2
ERemoteStoragePlatform_PS3 ERemoteStoragePlatform = 4 ERemoteStoragePlatform_PS3 ERemoteStoragePlatform = 4
ERemoteStoragePlatform_Linux ERemoteStoragePlatform = 8 ERemoteStoragePlatform_Linux ERemoteStoragePlatform = 8
ERemoteStoragePlatform_Reserved2 ERemoteStoragePlatform = 16 ERemoteStoragePlatform_Switch ERemoteStoragePlatform = 16
ERemoteStoragePlatform_Android ERemoteStoragePlatform = 32 ERemoteStoragePlatform_Android ERemoteStoragePlatform = 32
ERemoteStoragePlatform_IPhoneOS ERemoteStoragePlatform = 64 ERemoteStoragePlatform_IPhoneOS ERemoteStoragePlatform = 64
ERemoteStoragePlatform_All ERemoteStoragePlatform = -1 ERemoteStoragePlatform_All ERemoteStoragePlatform = -1
@@ -6635,7 +6708,7 @@ var ERemoteStoragePlatform_name = map[ERemoteStoragePlatform]string{
2: "ERemoteStoragePlatform_OSX", 2: "ERemoteStoragePlatform_OSX",
4: "ERemoteStoragePlatform_PS3", 4: "ERemoteStoragePlatform_PS3",
8: "ERemoteStoragePlatform_Linux", 8: "ERemoteStoragePlatform_Linux",
16: "ERemoteStoragePlatform_Reserved2", 16: "ERemoteStoragePlatform_Switch",
32: "ERemoteStoragePlatform_Android", 32: "ERemoteStoragePlatform_Android",
64: "ERemoteStoragePlatform_IPhoneOS", 64: "ERemoteStoragePlatform_IPhoneOS",
-1: "ERemoteStoragePlatform_All", -1: "ERemoteStoragePlatform_All",
@@ -6780,7 +6853,6 @@ const (
EClientStat_P2PGameConnections EClientStat = 2 EClientStat_P2PGameConnections EClientStat = 2
EClientStat_P2PVoiceConnections EClientStat = 3 EClientStat_P2PVoiceConnections EClientStat = 3
EClientStat_BytesDownloaded EClientStat = 4 EClientStat_BytesDownloaded EClientStat = 4
EClientStat_Max EClientStat = 5
) )
var EClientStat_name = map[EClientStat]string{ var EClientStat_name = map[EClientStat]string{
@@ -6789,7 +6861,6 @@ var EClientStat_name = map[EClientStat]string{
2: "EClientStat_P2PGameConnections", 2: "EClientStat_P2PGameConnections",
3: "EClientStat_P2PVoiceConnections", 3: "EClientStat_P2PVoiceConnections",
4: "EClientStat_BytesDownloaded", 4: "EClientStat_BytesDownloaded",
5: "EClientStat_Max",
} }
func (e EClientStat) String() string { func (e EClientStat) String() string {
@@ -7106,6 +7177,7 @@ type EPublishedFileInappropriateResult int32
const ( const (
EPublishedFileInappropriateResult_NotScanned EPublishedFileInappropriateResult = 0 EPublishedFileInappropriateResult_NotScanned EPublishedFileInappropriateResult = 0
EPublishedFileInappropriateResult_VeryUnlikely EPublishedFileInappropriateResult = 1 EPublishedFileInappropriateResult_VeryUnlikely EPublishedFileInappropriateResult = 1
EPublishedFileInappropriateResult_Unlikely EPublishedFileInappropriateResult = 30
EPublishedFileInappropriateResult_Possible EPublishedFileInappropriateResult = 50 EPublishedFileInappropriateResult_Possible EPublishedFileInappropriateResult = 50
EPublishedFileInappropriateResult_Likely EPublishedFileInappropriateResult = 75 EPublishedFileInappropriateResult_Likely EPublishedFileInappropriateResult = 75
EPublishedFileInappropriateResult_VeryLikely EPublishedFileInappropriateResult = 100 EPublishedFileInappropriateResult_VeryLikely EPublishedFileInappropriateResult = 100
@@ -7114,6 +7186,7 @@ const (
var EPublishedFileInappropriateResult_name = map[EPublishedFileInappropriateResult]string{ var EPublishedFileInappropriateResult_name = map[EPublishedFileInappropriateResult]string{
0: "EPublishedFileInappropriateResult_NotScanned", 0: "EPublishedFileInappropriateResult_NotScanned",
1: "EPublishedFileInappropriateResult_VeryUnlikely", 1: "EPublishedFileInappropriateResult_VeryUnlikely",
30: "EPublishedFileInappropriateResult_Unlikely",
50: "EPublishedFileInappropriateResult_Possible", 50: "EPublishedFileInappropriateResult_Possible",
75: "EPublishedFileInappropriateResult_Likely", 75: "EPublishedFileInappropriateResult_Likely",
100: "EPublishedFileInappropriateResult_VeryLikely", 100: "EPublishedFileInappropriateResult_VeryLikely",
@@ -7723,6 +7796,282 @@ func (e ETradeOfferConfirmationMethod) String() string {
return strings.Join(flags, " | ") return strings.Join(flags, " | ")
} }
type ELobbyType int32
const (
ELobbyType_Private ELobbyType = 0
ELobbyType_FriendsOnly ELobbyType = 1
ELobbyType_Public ELobbyType = 2
ELobbyType_Invisible ELobbyType = 3
ELobbyType_PrivateUnique ELobbyType = 4
)
var ELobbyType_name = map[ELobbyType]string{
0: "ELobbyType_Private",
1: "ELobbyType_FriendsOnly",
2: "ELobbyType_Public",
3: "ELobbyType_Invisible",
4: "ELobbyType_PrivateUnique",
}
func (e ELobbyType) String() string {
if s, ok := ELobbyType_name[e]; ok {
return s
}
var flags []string
for k, v := range ELobbyType_name {
if e&k != 0 {
flags = append(flags, v)
}
}
if len(flags) == 0 {
return fmt.Sprintf("%d", e)
}
sort.Strings(flags)
return strings.Join(flags, " | ")
}
type ELobbyFilterType int32
const (
ELobbyFilterType_String ELobbyFilterType = 0
ELobbyFilterType_Numerical ELobbyFilterType = 1
ELobbyFilterType_SlotsAvailable ELobbyFilterType = 2
ELobbyFilterType_NearValue ELobbyFilterType = 3
ELobbyFilterType_Distance ELobbyFilterType = 4
)
var ELobbyFilterType_name = map[ELobbyFilterType]string{
0: "ELobbyFilterType_String",
1: "ELobbyFilterType_Numerical",
2: "ELobbyFilterType_SlotsAvailable",
3: "ELobbyFilterType_NearValue",
4: "ELobbyFilterType_Distance",
}
func (e ELobbyFilterType) String() string {
if s, ok := ELobbyFilterType_name[e]; ok {
return s
}
var flags []string
for k, v := range ELobbyFilterType_name {
if e&k != 0 {
flags = append(flags, v)
}
}
if len(flags) == 0 {
return fmt.Sprintf("%d", e)
}
sort.Strings(flags)
return strings.Join(flags, " | ")
}
type ELobbyComparison int32
const (
ELobbyComparison_EqualToOrLessThan ELobbyComparison = -2
ELobbyComparison_LessThan ELobbyComparison = -1
ELobbyComparison_Equal ELobbyComparison = 0
ELobbyComparison_GreaterThan ELobbyComparison = 1
ELobbyComparison_EqualToOrGreaterThan ELobbyComparison = 2
ELobbyComparison_NotEqual ELobbyComparison = 3
)
var ELobbyComparison_name = map[ELobbyComparison]string{
-2: "ELobbyComparison_EqualToOrLessThan",
-1: "ELobbyComparison_LessThan",
0: "ELobbyComparison_Equal",
1: "ELobbyComparison_GreaterThan",
2: "ELobbyComparison_EqualToOrGreaterThan",
3: "ELobbyComparison_NotEqual",
}
func (e ELobbyComparison) String() string {
if s, ok := ELobbyComparison_name[e]; ok {
return s
}
var flags []string
for k, v := range ELobbyComparison_name {
if e&k != 0 {
flags = append(flags, v)
}
}
if len(flags) == 0 {
return fmt.Sprintf("%d", e)
}
sort.Strings(flags)
return strings.Join(flags, " | ")
}
type ELobbyDistanceFilter int32
const (
ELobbyDistanceFilter_Close ELobbyDistanceFilter = 0
ELobbyDistanceFilter_Default ELobbyDistanceFilter = 1
ELobbyDistanceFilter_Far ELobbyDistanceFilter = 2
ELobbyDistanceFilter_Worldwide ELobbyDistanceFilter = 3
)
var ELobbyDistanceFilter_name = map[ELobbyDistanceFilter]string{
0: "ELobbyDistanceFilter_Close",
1: "ELobbyDistanceFilter_Default",
2: "ELobbyDistanceFilter_Far",
3: "ELobbyDistanceFilter_Worldwide",
}
func (e ELobbyDistanceFilter) String() string {
if s, ok := ELobbyDistanceFilter_name[e]; ok {
return s
}
var flags []string
for k, v := range ELobbyDistanceFilter_name {
if e&k != 0 {
flags = append(flags, v)
}
}
if len(flags) == 0 {
return fmt.Sprintf("%d", e)
}
sort.Strings(flags)
return strings.Join(flags, " | ")
}
type ESteamIPv6ConnectivityProtocol int32
const (
ESteamIPv6ConnectivityProtocol_Invalid ESteamIPv6ConnectivityProtocol = 0
ESteamIPv6ConnectivityProtocol_Http ESteamIPv6ConnectivityProtocol = 1
ESteamIPv6ConnectivityProtocol_Udp ESteamIPv6ConnectivityProtocol = 2
)
var ESteamIPv6ConnectivityProtocol_name = map[ESteamIPv6ConnectivityProtocol]string{
0: "ESteamIPv6ConnectivityProtocol_Invalid",
1: "ESteamIPv6ConnectivityProtocol_Http",
2: "ESteamIPv6ConnectivityProtocol_Udp",
}
func (e ESteamIPv6ConnectivityProtocol) String() string {
if s, ok := ESteamIPv6ConnectivityProtocol_name[e]; ok {
return s
}
var flags []string
for k, v := range ESteamIPv6ConnectivityProtocol_name {
if e&k != 0 {
flags = append(flags, v)
}
}
if len(flags) == 0 {
return fmt.Sprintf("%d", e)
}
sort.Strings(flags)
return strings.Join(flags, " | ")
}
type ESteamIPv6ConnectivityState int32
const (
ESteamIPv6ConnectivityState_Unknown ESteamIPv6ConnectivityState = 0
ESteamIPv6ConnectivityState_Good ESteamIPv6ConnectivityState = 1
ESteamIPv6ConnectivityState_Bad ESteamIPv6ConnectivityState = 2
)
var ESteamIPv6ConnectivityState_name = map[ESteamIPv6ConnectivityState]string{
0: "ESteamIPv6ConnectivityState_Unknown",
1: "ESteamIPv6ConnectivityState_Good",
2: "ESteamIPv6ConnectivityState_Bad",
}
func (e ESteamIPv6ConnectivityState) String() string {
if s, ok := ESteamIPv6ConnectivityState_name[e]; ok {
return s
}
var flags []string
for k, v := range ESteamIPv6ConnectivityState_name {
if e&k != 0 {
flags = append(flags, v)
}
}
if len(flags) == 0 {
return fmt.Sprintf("%d", e)
}
sort.Strings(flags)
return strings.Join(flags, " | ")
}
type ESteamRealm int32
const (
ESteamRealm_Unknown ESteamRealm = 0
ESteamRealm_SteamGlobal ESteamRealm = 1
ESteamRealm_SteamChina ESteamRealm = 2
)
var ESteamRealm_name = map[ESteamRealm]string{
0: "ESteamRealm_Unknown",
1: "ESteamRealm_SteamGlobal",
2: "ESteamRealm_SteamChina",
}
func (e ESteamRealm) String() string {
if s, ok := ESteamRealm_name[e]; ok {
return s
}
var flags []string
for k, v := range ESteamRealm_name {
if e&k != 0 {
flags = append(flags, v)
}
}
if len(flags) == 0 {
return fmt.Sprintf("%d", e)
}
sort.Strings(flags)
return strings.Join(flags, " | ")
}
type ELauncherType int32
const (
ELauncherType_Default ELauncherType = 0
ELauncherType_PerfectWorld ELauncherType = 1
ELauncherType_Nexon ELauncherType = 2
ELauncherType_CmdLine ELauncherType = 3
ELauncherType_CSGO ELauncherType = 4
ELauncherType_ClientUI ELauncherType = 5
ELauncherType_Headless ELauncherType = 6
ELauncherType_SteamChina ELauncherType = 7
ELauncherType_SingleApp ELauncherType = 8
)
var ELauncherType_name = map[ELauncherType]string{
0: "ELauncherType_Default",
1: "ELauncherType_PerfectWorld",
2: "ELauncherType_Nexon",
3: "ELauncherType_CmdLine",
4: "ELauncherType_CSGO",
5: "ELauncherType_ClientUI",
6: "ELauncherType_Headless",
7: "ELauncherType_SteamChina",
8: "ELauncherType_SingleApp",
}
func (e ELauncherType) String() string {
if s, ok := ELauncherType_name[e]; ok {
return s
}
var flags []string
for k, v := range ELauncherType_name {
if e&k != 0 {
flags = append(flags, v)
}
}
if len(flags) == 0 {
return fmt.Sprintf("%d", e)
}
sort.Strings(flags)
return strings.Join(flags, " | ")
}
type EUdpPacketType uint8 type EUdpPacketType uint8
const ( const (
-1
View File
@@ -364,7 +364,6 @@ func (s *Social) handlePersonaState(packet *Packet) {
ClanRank: friend.GetClanRank(), ClanRank: friend.GetClanRank(),
ClanTag: friend.GetClanTag(), ClanTag: friend.GetClanTag(),
OnlineSessionInstances: friend.GetOnlineSessionInstances(), OnlineSessionInstances: friend.GetOnlineSessionInstances(),
PublishedSessionId: friend.GetPublishedInstanceId(),
PersonaSetByUser: friend.GetPersonaSetByUser(), PersonaSetByUser: friend.GetPersonaSetByUser(),
}) })
} }
-1
View File
@@ -48,7 +48,6 @@ type PersonaStateEvent struct {
ClanRank uint32 ClanRank uint32
ClanTag string ClanTag string
OnlineSessionInstances uint32 OnlineSessionInstances uint32
PublishedSessionId uint32
PersonaSetByUser bool PersonaSetByUser bool
} }
+8
View File
@@ -70,6 +70,14 @@ func (myHandler) HandleContactMessage(message whatsapp.ContactMessage) {
fmt.Println(message) fmt.Println(message)
} }
func (myHandler) HandleBatteryMessage(msg whatsapp.BatteryMessage) {
fmt.Println(message)
}
func (myHandler) HandleNewContact(contact whatsapp.Contact) {
fmt.Println(contact)
}
wac.AddHandler(myHandler{}) wac.AddHandler(myHandler{})
``` ```
The message handlers are all optional, you don't need to implement anything but the error handler to implement the interface. The ImageMessage, VideoMessage, AudioMessage and DocumentMessage provide a Download function to get the media data. The message handlers are all optional, you don't need to implement anything but the error handler to implement the interface. The ImageMessage, VideoMessage, AudioMessage and DocumentMessage provide a Download function to get the media data.
File diff suppressed because it is too large Load Diff
+333 -69
View File
@@ -69,18 +69,46 @@ message InteractiveAnnotation {
} }
} }
message DeviceListMetadata {
optional bytes senderKeyHash = 1;
optional uint64 senderTimestamp = 2;
optional bytes recipientKeyHash = 8;
optional uint64 recipientTimestamp = 9;
}
message MessageContextInfo {
optional DeviceListMetadata deviceListMetadata = 1;
}
message AdReplyInfo { message AdReplyInfo {
optional string advertiserName = 1; optional string advertiserName = 1;
enum AD_REPLY_INFO_MEDIATYPE { enum AdReplyInfoMediaType {
NONE = 0; NONE = 0;
IMAGE = 1; IMAGE = 1;
VIDEO = 2; VIDEO = 2;
} }
optional AD_REPLY_INFO_MEDIATYPE mediaType = 2; optional AdReplyInfoMediaType mediaType = 2;
optional bytes jpegThumbnail = 16; optional bytes jpegThumbnail = 16;
optional string caption = 17; optional string caption = 17;
} }
message ExternalAdReplyInfo {
optional string title = 1;
optional string body = 2;
enum ExternalAdReplyInfoMediaType {
NONE = 0;
IMAGE = 1;
VIDEO = 2;
}
optional ExternalAdReplyInfoMediaType mediaType = 3;
optional string thumbnailUrl = 4;
optional string mediaUrl = 5;
optional bytes thumbnail = 6;
optional string sourceType = 7;
optional string sourceId = 8;
optional string sourceUrl = 9;
}
message ContextInfo { message ContextInfo {
optional string stanzaId = 1; optional string stanzaId = 1;
optional string participant = 2; optional string participant = 2;
@@ -96,6 +124,8 @@ message ContextInfo {
optional MessageKey placeholderKey = 24; optional MessageKey placeholderKey = 24;
optional uint32 expiration = 25; optional uint32 expiration = 25;
optional int64 ephemeralSettingTimestamp = 26; optional int64 ephemeralSettingTimestamp = 26;
optional bytes ephemeralSharedSecret = 27;
optional ExternalAdReplyInfo externalAdReply = 28;
} }
message SenderKeyDistributionMessage { message SenderKeyDistributionMessage {
@@ -125,6 +155,24 @@ message ImageMessage {
repeated uint32 scanLengths = 22; repeated uint32 scanLengths = 22;
optional bytes midQualityFileSha256 = 23; optional bytes midQualityFileSha256 = 23;
optional bytes midQualityFileEncSha256 = 24; optional bytes midQualityFileEncSha256 = 24;
optional bool viewOnce = 25;
}
message InvoiceMessage {
optional string note = 1;
optional string token = 2;
enum InvoiceMessageAttachmentType {
IMAGE = 0;
PDF = 1;
}
optional InvoiceMessageAttachmentType attachmentType = 3;
optional string attachmentMimetype = 4;
optional bytes attachmentMediaKey = 5;
optional int64 attachmentMediaKeyTimestamp = 6;
optional bytes attachmentFileSha256 = 7;
optional bytes attachmentFileEncSha256 = 8;
optional string attachmentDirectPath = 9;
optional bytes attachmentJpegThumbnail = 10;
} }
message ContactMessage { message ContactMessage {
@@ -156,7 +204,7 @@ message ExtendedTextMessage {
optional string title = 6; optional string title = 6;
optional fixed32 textArgb = 7; optional fixed32 textArgb = 7;
optional fixed32 backgroundArgb = 8; optional fixed32 backgroundArgb = 8;
enum EXTENDED_TEXT_MESSAGE_FONTTYPE { enum ExtendedTextMessageFontType {
SANS_SERIF = 0; SANS_SERIF = 0;
SERIF = 1; SERIF = 1;
NORICAN_REGULAR = 2; NORICAN_REGULAR = 2;
@@ -164,12 +212,12 @@ message ExtendedTextMessage {
BEBASNEUE_REGULAR = 4; BEBASNEUE_REGULAR = 4;
OSWALD_HEAVY = 5; OSWALD_HEAVY = 5;
} }
optional EXTENDED_TEXT_MESSAGE_FONTTYPE font = 9; optional ExtendedTextMessageFontType font = 9;
enum EXTENDED_TEXT_MESSAGE_PREVIEWTYPE { enum ExtendedTextMessagePreviewType {
NONE = 0; NONE = 0;
VIDEO = 1; VIDEO = 1;
} }
optional EXTENDED_TEXT_MESSAGE_PREVIEWTYPE previewType = 10; optional ExtendedTextMessagePreviewType previewType = 10;
optional bytes jpegThumbnail = 16; optional bytes jpegThumbnail = 16;
optional ContextInfo contextInfo = 17; optional ContextInfo contextInfo = 17;
optional bool doNotPlayInline = 18; optional bool doNotPlayInline = 18;
@@ -187,8 +235,14 @@ message DocumentMessage {
optional bytes fileEncSha256 = 9; optional bytes fileEncSha256 = 9;
optional string directPath = 10; optional string directPath = 10;
optional int64 mediaKeyTimestamp = 11; optional int64 mediaKeyTimestamp = 11;
optional bool contactVcard = 12;
optional string thumbnailDirectPath = 13;
optional bytes thumbnailSha256 = 14;
optional bytes thumbnailEncSha256 = 15;
optional bytes jpegThumbnail = 16; optional bytes jpegThumbnail = 16;
optional ContextInfo contextInfo = 17; optional ContextInfo contextInfo = 17;
optional uint32 thumbnailHeight = 18;
optional uint32 thumbnailWidth = 19;
} }
message AudioMessage { message AudioMessage {
@@ -224,12 +278,13 @@ message VideoMessage {
optional bytes jpegThumbnail = 16; optional bytes jpegThumbnail = 16;
optional ContextInfo contextInfo = 17; optional ContextInfo contextInfo = 17;
optional bytes streamingSidecar = 18; optional bytes streamingSidecar = 18;
enum VIDEO_MESSAGE_ATTRIBUTION { enum VideoMessageAttribution {
NONE = 0; NONE = 0;
GIPHY = 1; GIPHY = 1;
TENOR = 2; TENOR = 2;
} }
optional VIDEO_MESSAGE_ATTRIBUTION gifAttribution = 19; optional VideoMessageAttribution gifAttribution = 19;
optional bool viewOnce = 20;
} }
message Call { message Call {
@@ -243,16 +298,23 @@ message Chat {
message ProtocolMessage { message ProtocolMessage {
optional MessageKey key = 1; optional MessageKey key = 1;
enum PROTOCOL_MESSAGE_TYPE { enum ProtocolMessageType {
REVOKE = 0; REVOKE = 0;
EPHEMERAL_SETTING = 3; EPHEMERAL_SETTING = 3;
EPHEMERAL_SYNC_RESPONSE = 4; EPHEMERAL_SYNC_RESPONSE = 4;
HISTORY_SYNC_NOTIFICATION = 5; HISTORY_SYNC_NOTIFICATION = 5;
APP_STATE_SYNC_KEY_SHARE = 6;
APP_STATE_SYNC_KEY_REQUEST = 7;
MSG_FANOUT_BACKFILL_REQUEST = 8;
INITIAL_SECURITY_NOTIFICATION_SETTING_SYNC = 9;
} }
optional PROTOCOL_MESSAGE_TYPE type = 2; optional ProtocolMessageType type = 2;
optional uint32 ephemeralExpiration = 4; optional uint32 ephemeralExpiration = 4;
optional int64 ephemeralSettingTimestamp = 5; optional int64 ephemeralSettingTimestamp = 5;
optional HistorySyncNotification historySyncNotification = 6; optional HistorySyncNotification historySyncNotification = 6;
optional AppStateSyncKeyShare appStateSyncKeyShare = 7;
optional AppStateSyncKeyRequest appStateSyncKeyRequest = 8;
optional InitialSecurityNotificationSettingSync initialSecurityNotificationSettingSync = 9;
} }
message HistorySyncNotification { message HistorySyncNotification {
@@ -261,14 +323,49 @@ message HistorySyncNotification {
optional bytes mediaKey = 3; optional bytes mediaKey = 3;
optional bytes fileEncSha256 = 4; optional bytes fileEncSha256 = 4;
optional string directPath = 5; optional string directPath = 5;
enum HISTORY_SYNC_NOTIFICATION_HISTORYSYNCTYPE { enum HistorySyncNotificationHistorySyncType {
INITIAL_BOOTSTRAP = 0; INITIAL_BOOTSTRAP = 0;
INITIAL_STATUS_V3 = 1; INITIAL_STATUS_V3 = 1;
FULL = 2; FULL = 2;
RECENT = 3; RECENT = 3;
PUSH_NAME = 4;
} }
optional HISTORY_SYNC_NOTIFICATION_HISTORYSYNCTYPE syncType = 6; optional HistorySyncNotificationHistorySyncType syncType = 6;
optional uint32 chunkOrder = 7; optional uint32 chunkOrder = 7;
optional string originalMessageId = 8;
}
message AppStateSyncKey {
optional AppStateSyncKeyId keyId = 1;
optional AppStateSyncKeyData keyData = 2;
}
message AppStateSyncKeyId {
optional bytes keyId = 1;
}
message AppStateSyncKeyFingerprint {
optional uint32 rawId = 1;
optional uint32 currentIndex = 2;
repeated uint32 deviceIndexes = 3 [packed=true];
}
message AppStateSyncKeyData {
optional bytes keyData = 1;
optional AppStateSyncKeyFingerprint fingerprint = 2;
optional int64 timestamp = 3;
}
message AppStateSyncKeyShare {
repeated AppStateSyncKey keys = 1;
}
message AppStateSyncKeyRequest {
repeated AppStateSyncKeyId keyIds = 1;
}
message InitialSecurityNotificationSettingSync {
optional bool securityNotificationEnabled = 1;
} }
message ContactsArrayMessage { message ContactsArrayMessage {
@@ -283,7 +380,7 @@ message HSMCurrency {
} }
message HSMDateTimeComponent { message HSMDateTimeComponent {
enum HSM_DATE_TIME_COMPONENT_DAYOFWEEKTYPE { enum HSMDateTimeComponentDayOfWeekType {
MONDAY = 1; MONDAY = 1;
TUESDAY = 2; TUESDAY = 2;
WEDNESDAY = 3; WEDNESDAY = 3;
@@ -292,17 +389,17 @@ message HSMDateTimeComponent {
SATURDAY = 6; SATURDAY = 6;
SUNDAY = 7; SUNDAY = 7;
} }
optional HSM_DATE_TIME_COMPONENT_DAYOFWEEKTYPE dayOfWeek = 1; optional HSMDateTimeComponentDayOfWeekType dayOfWeek = 1;
optional uint32 year = 2; optional uint32 year = 2;
optional uint32 month = 3; optional uint32 month = 3;
optional uint32 dayOfMonth = 4; optional uint32 dayOfMonth = 4;
optional uint32 hour = 5; optional uint32 hour = 5;
optional uint32 minute = 6; optional uint32 minute = 6;
enum HSM_DATE_TIME_COMPONENT_CALENDARTYPE { enum HSMDateTimeComponentCalendarType {
GREGORIAN = 1; GREGORIAN = 1;
SOLAR_HIJRI = 2; SOLAR_HIJRI = 2;
} }
optional HSM_DATE_TIME_COMPONENT_CALENDARTYPE calendar = 7; optional HSMDateTimeComponentCalendarType calendar = 7;
} }
message HSMDateTimeUnixEpoch { message HSMDateTimeUnixEpoch {
@@ -347,6 +444,13 @@ message RequestPaymentMessage {
optional uint64 amount1000 = 2; optional uint64 amount1000 = 2;
optional string requestFrom = 3; optional string requestFrom = 3;
optional int64 expiryTimestamp = 5; optional int64 expiryTimestamp = 5;
optional PaymentMoney amount = 6;
}
message PaymentMoney {
optional int64 value = 1;
optional uint32 offset = 2;
optional string currencyCode = 3;
} }
message DeclinePaymentRequestMessage { message DeclinePaymentRequestMessage {
@@ -457,6 +561,64 @@ message ProductMessage {
optional ContextInfo contextInfo = 17; optional ContextInfo contextInfo = 17;
} }
message OrderMessage {
optional string orderId = 1;
optional bytes thumbnail = 2;
optional int32 itemCount = 3;
enum OrderMessageOrderStatus {
INQUIRY = 1;
}
optional OrderMessageOrderStatus status = 4;
enum OrderMessageOrderSurface {
CATALOG = 1;
}
optional OrderMessageOrderSurface surface = 5;
optional string message = 6;
optional string orderTitle = 7;
optional string sellerJid = 8;
optional string token = 9;
optional ContextInfo contextInfo = 17;
}
message Row {
optional string title = 1;
optional string description = 2;
optional string rowId = 3;
}
message Section {
optional string title = 1;
repeated Row rows = 2;
}
message ListMessage {
optional string title = 1;
optional string description = 2;
optional string buttonText = 3;
enum ListMessageListType {
UNKNOWN = 0;
SINGLE_SELECT = 1;
}
optional ListMessageListType listType = 4;
repeated Section sections = 5;
}
message SingleSelectReply {
optional string selectedRowId = 1;
}
message ListResponseMessage {
optional string title = 1;
enum ListResponseMessageListType {
UNKNOWN = 0;
SINGLE_SELECT = 1;
}
optional ListResponseMessageListType listType = 2;
optional SingleSelectReply singleSelectReply = 3;
optional ContextInfo contextInfo = 4;
optional string description = 5;
}
message GroupInviteMessage { message GroupInviteMessage {
optional string groupJid = 1; optional string groupJid = 1;
optional string inviteCode = 2; optional string inviteCode = 2;
@@ -467,13 +629,50 @@ message GroupInviteMessage {
optional ContextInfo contextInfo = 7; optional ContextInfo contextInfo = 7;
} }
message EphemeralSetting {
optional string chatJid = 1;
optional uint32 ephemeralExpiration = 2;
optional int64 ephemeralSettingTimestamp = 3;
}
message DeviceSentMessage { message DeviceSentMessage {
optional string destinationJid = 1; optional string destinationJid = 1;
optional Message message = 2; optional Message message = 2;
optional string phash = 3;
repeated EphemeralSetting broadcastEphemeralSettings = 4;
} }
message DeviceSyncMessage { message FutureProofMessage {
optional bytes serializedXmlBytes = 1; optional Message message = 1;
}
message ButtonText {
optional string displayText = 1;
}
message Button {
optional string buttonId = 1;
optional ButtonText buttonText = 2;
}
message ButtonsMessage {
optional string contentText = 6;
optional string footerText = 7;
optional ContextInfo contextInfo = 8;
repeated Button buttons = 9;
oneof title {
string titleText = 1;
DocumentMessage documentMessage = 2;
ImageMessage imageMessage = 3;
VideoMessage videoMessage = 4;
LocationMessage locationMessage = 5;
}
}
message ButtonsResponseMessage {
optional string selectedButtonId = 1;
optional string selectedDisplayText = 2;
optional ContextInfo contextInfo = 3;
} }
message Message { message Message {
@@ -503,7 +702,15 @@ message Message {
optional TemplateButtonReplyMessage templateButtonReplyMessage = 29; optional TemplateButtonReplyMessage templateButtonReplyMessage = 29;
optional ProductMessage productMessage = 30; optional ProductMessage productMessage = 30;
optional DeviceSentMessage deviceSentMessage = 31; optional DeviceSentMessage deviceSentMessage = 31;
optional DeviceSyncMessage deviceSyncMessage = 32; optional MessageContextInfo messageContextInfo = 35;
optional ListMessage listMessage = 36;
optional FutureProofMessage viewOnceMessage = 37;
optional OrderMessage orderMessage = 38;
optional ListResponseMessage listResponseMessage = 39;
optional FutureProofMessage ephemeralMessage = 40;
optional InvoiceMessage invoiceMessage = 41;
optional ButtonsMessage buttonsMessage = 42;
optional ButtonsResponseMessage buttonsResponseMessage = 43;
} }
message MessageKey { message MessageKey {
@@ -514,51 +721,52 @@ message MessageKey {
} }
message WebFeatures { message WebFeatures {
enum WEB_FEATURES_FLAG { enum WebFeaturesFlag {
NOT_STARTED = 0; NOT_STARTED = 0;
FORCE_UPGRADE = 1; FORCE_UPGRADE = 1;
DEVELOPMENT = 2; DEVELOPMENT = 2;
PRODUCTION = 3; PRODUCTION = 3;
} }
optional WEB_FEATURES_FLAG labelsDisplay = 1; optional WebFeaturesFlag labelsDisplay = 1;
optional WEB_FEATURES_FLAG voipIndividualOutgoing = 2; optional WebFeaturesFlag voipIndividualOutgoing = 2;
optional WEB_FEATURES_FLAG groupsV3 = 3; optional WebFeaturesFlag groupsV3 = 3;
optional WEB_FEATURES_FLAG groupsV3Create = 4; optional WebFeaturesFlag groupsV3Create = 4;
optional WEB_FEATURES_FLAG changeNumberV2 = 5; optional WebFeaturesFlag changeNumberV2 = 5;
optional WEB_FEATURES_FLAG queryStatusV3Thumbnail = 6; optional WebFeaturesFlag queryStatusV3Thumbnail = 6;
optional WEB_FEATURES_FLAG liveLocations = 7; optional WebFeaturesFlag liveLocations = 7;
optional WEB_FEATURES_FLAG queryVname = 8; optional WebFeaturesFlag queryVname = 8;
optional WEB_FEATURES_FLAG voipIndividualIncoming = 9; optional WebFeaturesFlag voipIndividualIncoming = 9;
optional WEB_FEATURES_FLAG quickRepliesQuery = 10; optional WebFeaturesFlag quickRepliesQuery = 10;
optional WEB_FEATURES_FLAG payments = 11; optional WebFeaturesFlag payments = 11;
optional WEB_FEATURES_FLAG stickerPackQuery = 12; optional WebFeaturesFlag stickerPackQuery = 12;
optional WEB_FEATURES_FLAG liveLocationsFinal = 13; optional WebFeaturesFlag liveLocationsFinal = 13;
optional WEB_FEATURES_FLAG labelsEdit = 14; optional WebFeaturesFlag labelsEdit = 14;
optional WEB_FEATURES_FLAG mediaUpload = 15; optional WebFeaturesFlag mediaUpload = 15;
optional WEB_FEATURES_FLAG mediaUploadRichQuickReplies = 18; optional WebFeaturesFlag mediaUploadRichQuickReplies = 18;
optional WEB_FEATURES_FLAG vnameV2 = 19; optional WebFeaturesFlag vnameV2 = 19;
optional WEB_FEATURES_FLAG videoPlaybackUrl = 20; optional WebFeaturesFlag videoPlaybackUrl = 20;
optional WEB_FEATURES_FLAG statusRanking = 21; optional WebFeaturesFlag statusRanking = 21;
optional WEB_FEATURES_FLAG voipIndividualVideo = 22; optional WebFeaturesFlag voipIndividualVideo = 22;
optional WEB_FEATURES_FLAG thirdPartyStickers = 23; optional WebFeaturesFlag thirdPartyStickers = 23;
optional WEB_FEATURES_FLAG frequentlyForwardedSetting = 24; optional WebFeaturesFlag frequentlyForwardedSetting = 24;
optional WEB_FEATURES_FLAG groupsV4JoinPermission = 25; optional WebFeaturesFlag groupsV4JoinPermission = 25;
optional WEB_FEATURES_FLAG recentStickers = 26; optional WebFeaturesFlag recentStickers = 26;
optional WEB_FEATURES_FLAG catalog = 27; optional WebFeaturesFlag catalog = 27;
optional WEB_FEATURES_FLAG starredStickers = 28; optional WebFeaturesFlag starredStickers = 28;
optional WEB_FEATURES_FLAG voipGroupCall = 29; optional WebFeaturesFlag voipGroupCall = 29;
optional WEB_FEATURES_FLAG templateMessage = 30; optional WebFeaturesFlag templateMessage = 30;
optional WEB_FEATURES_FLAG templateMessageInteractivity = 31; optional WebFeaturesFlag templateMessageInteractivity = 31;
optional WEB_FEATURES_FLAG ephemeralMessages = 32; optional WebFeaturesFlag ephemeralMessages = 32;
optional WEB_FEATURES_FLAG e2ENotificationSync = 33; optional WebFeaturesFlag e2ENotificationSync = 33;
optional WEB_FEATURES_FLAG recentStickersV2 = 34; optional WebFeaturesFlag recentStickersV2 = 34;
} optional WebFeaturesFlag syncdRelease1 = 35;
optional WebFeaturesFlag recentStickersV3 = 36;
message TabletNotificationsInfo { optional WebFeaturesFlag userNotice = 37;
optional uint64 timestamp = 2; optional WebFeaturesFlag syncdRelease11 = 38;
optional uint32 unreadChats = 3; optional WebFeaturesFlag support = 39;
optional uint32 notifyMessageCount = 4; optional WebFeaturesFlag groupUiiCleanup = 40;
repeated NotificationMessageInfo notifyMessage = 5; optional WebFeaturesFlag groupDogfoodingInternalOnly = 41;
optional WebFeaturesFlag settingsSync = 42;
} }
message NotificationMessageInfo { message NotificationMessageInfo {
@@ -576,14 +784,14 @@ message WebNotificationsInfo {
} }
message PaymentInfo { message PaymentInfo {
enum PAYMENT_INFO_CURRENCY { enum PaymentInfoCurrency {
UNKNOWN_CURRENCY = 0; UNKNOWN_CURRENCY = 0;
INR = 1; INR = 1;
} }
optional PAYMENT_INFO_CURRENCY currencyDeprecated = 1; optional PaymentInfoCurrency currencyDeprecated = 1;
optional uint64 amount1000 = 2; optional uint64 amount1000 = 2;
optional string receiverJid = 3; optional string receiverJid = 3;
enum PAYMENT_INFO_STATUS { enum PaymentInfoStatus {
UNKNOWN_STATUS = 0; UNKNOWN_STATUS = 0;
PROCESSING = 1; PROCESSING = 1;
SENT = 2; SENT = 2;
@@ -597,13 +805,13 @@ message PaymentInfo {
WAITING_FOR_PAYER = 10; WAITING_FOR_PAYER = 10;
WAITING = 11; WAITING = 11;
} }
optional PAYMENT_INFO_STATUS status = 4; optional PaymentInfoStatus status = 4;
optional uint64 transactionTimestamp = 5; optional uint64 transactionTimestamp = 5;
optional MessageKey requestMessageKey = 6; optional MessageKey requestMessageKey = 6;
optional uint64 expiryTimestamp = 7; optional uint64 expiryTimestamp = 7;
optional bool futureproofed = 8; optional bool futureproofed = 8;
optional string currency = 9; optional string currency = 9;
enum PAYMENT_INFO_TXNSTATUS { enum PaymentInfoTxnStatus {
UNKNOWN = 0; UNKNOWN = 0;
PENDING_SETUP = 1; PENDING_SETUP = 1;
PENDING_RECEIVER_SETUP = 2; PENDING_RECEIVER_SETUP = 2;
@@ -633,14 +841,14 @@ message PaymentInfo {
COLLECT_CANCELED = 26; COLLECT_CANCELED = 26;
COLLECT_CANCELLING = 27; COLLECT_CANCELLING = 27;
} }
optional PAYMENT_INFO_TXNSTATUS txnStatus = 10; optional PaymentInfoTxnStatus txnStatus = 10;
} }
message WebMessageInfo { message WebMessageInfo {
required MessageKey key = 1; required MessageKey key = 1;
optional Message message = 2; optional Message message = 2;
optional uint64 messageTimestamp = 3; optional uint64 messageTimestamp = 3;
enum WEB_MESSAGE_INFO_STATUS { enum WebMessageInfoStatus {
ERROR = 0; ERROR = 0;
PENDING = 1; PENDING = 1;
SERVER_ACK = 2; SERVER_ACK = 2;
@@ -648,7 +856,7 @@ message WebMessageInfo {
READ = 4; READ = 4;
PLAYED = 5; PLAYED = 5;
} }
optional WEB_MESSAGE_INFO_STATUS status = 4; optional WebMessageInfoStatus status = 4;
optional string participant = 5; optional string participant = 5;
optional bool ignore = 16; optional bool ignore = 16;
optional bool starred = 17; optional bool starred = 17;
@@ -658,7 +866,7 @@ message WebMessageInfo {
optional bool multicast = 21; optional bool multicast = 21;
optional bool urlText = 22; optional bool urlText = 22;
optional bool urlNumber = 23; optional bool urlNumber = 23;
enum WEB_MESSAGE_INFO_STUBTYPE { enum WebMessageInfoStubType {
UNKNOWN = 0; UNKNOWN = 0;
REVOKE = 1; REVOKE = 1;
CIPHERTEXT = 2; CIPHERTEXT = 2;
@@ -732,8 +940,54 @@ message WebMessageInfo {
GROUP_V4_ADD_INVITE_SENT = 70; GROUP_V4_ADD_INVITE_SENT = 70;
GROUP_PARTICIPANT_ADD_REQUEST_JOIN = 71; GROUP_PARTICIPANT_ADD_REQUEST_JOIN = 71;
CHANGE_EPHEMERAL_SETTING = 72; CHANGE_EPHEMERAL_SETTING = 72;
E2E_DEVICE_CHANGED = 73;
VIEWED_ONCE = 74;
E2E_ENCRYPTED_NOW = 75;
BLUE_MSG_BSP_FB_TO_BSP_PREMISE = 76;
BLUE_MSG_BSP_FB_TO_SELF_FB = 77;
BLUE_MSG_BSP_FB_TO_SELF_PREMISE = 78;
BLUE_MSG_BSP_FB_UNVERIFIED = 79;
BLUE_MSG_BSP_FB_UNVERIFIED_TO_SELF_PREMISE_VERIFIED = 80;
BLUE_MSG_BSP_FB_VERIFIED = 81;
BLUE_MSG_BSP_FB_VERIFIED_TO_SELF_PREMISE_UNVERIFIED = 82;
BLUE_MSG_BSP_PREMISE_TO_SELF_PREMISE = 83;
BLUE_MSG_BSP_PREMISE_UNVERIFIED = 84;
BLUE_MSG_BSP_PREMISE_UNVERIFIED_TO_SELF_PREMISE_VERIFIED = 85;
BLUE_MSG_BSP_PREMISE_VERIFIED = 86;
BLUE_MSG_BSP_PREMISE_VERIFIED_TO_SELF_PREMISE_UNVERIFIED = 87;
BLUE_MSG_CONSUMER_TO_BSP_FB_UNVERIFIED = 88;
BLUE_MSG_CONSUMER_TO_BSP_PREMISE_UNVERIFIED = 89;
BLUE_MSG_CONSUMER_TO_SELF_FB_UNVERIFIED = 90;
BLUE_MSG_CONSUMER_TO_SELF_PREMISE_UNVERIFIED = 91;
BLUE_MSG_SELF_FB_TO_BSP_PREMISE = 92;
BLUE_MSG_SELF_FB_TO_SELF_PREMISE = 93;
BLUE_MSG_SELF_FB_UNVERIFIED = 94;
BLUE_MSG_SELF_FB_UNVERIFIED_TO_SELF_PREMISE_VERIFIED = 95;
BLUE_MSG_SELF_FB_VERIFIED = 96;
BLUE_MSG_SELF_FB_VERIFIED_TO_SELF_PREMISE_UNVERIFIED = 97;
BLUE_MSG_SELF_PREMISE_TO_BSP_PREMISE = 98;
BLUE_MSG_SELF_PREMISE_UNVERIFIED = 99;
BLUE_MSG_SELF_PREMISE_VERIFIED = 100;
BLUE_MSG_TO_BSP_FB = 101;
BLUE_MSG_TO_CONSUMER = 102;
BLUE_MSG_TO_SELF_FB = 103;
BLUE_MSG_UNVERIFIED_TO_BSP_FB_VERIFIED = 104;
BLUE_MSG_UNVERIFIED_TO_BSP_PREMISE_VERIFIED = 105;
BLUE_MSG_UNVERIFIED_TO_SELF_FB_VERIFIED = 106;
BLUE_MSG_UNVERIFIED_TO_VERIFIED = 107;
BLUE_MSG_VERIFIED_TO_BSP_FB_UNVERIFIED = 108;
BLUE_MSG_VERIFIED_TO_BSP_PREMISE_UNVERIFIED = 109;
BLUE_MSG_VERIFIED_TO_SELF_FB_UNVERIFIED = 110;
BLUE_MSG_VERIFIED_TO_UNVERIFIED = 111;
BLUE_MSG_BSP_FB_UNVERIFIED_TO_BSP_PREMISE_VERIFIED = 112;
BLUE_MSG_BSP_FB_UNVERIFIED_TO_SELF_FB_VERIFIED = 113;
BLUE_MSG_BSP_FB_VERIFIED_TO_BSP_PREMISE_UNVERIFIED = 114;
BLUE_MSG_BSP_FB_VERIFIED_TO_SELF_FB_UNVERIFIED = 115;
BLUE_MSG_SELF_FB_UNVERIFIED_TO_BSP_PREMISE_VERIFIED = 116;
BLUE_MSG_SELF_FB_VERIFIED_TO_BSP_PREMISE_UNVERIFIED = 117;
E2E_IDENTITY_UNAVAILABLE = 118;
} }
optional WEB_MESSAGE_INFO_STUBTYPE messageStubType = 24; optional WebMessageInfoStubType messageStubType = 24;
optional bool clearMedia = 25; optional bool clearMedia = 25;
repeated string messageStubParameters = 26; repeated string messageStubParameters = 26;
optional uint32 duration = 27; optional uint32 duration = 27;
@@ -743,5 +997,15 @@ message WebMessageInfo {
optional PaymentInfo quotedPaymentInfo = 31; optional PaymentInfo quotedPaymentInfo = 31;
optional uint64 ephemeralStartTimestamp = 32; optional uint64 ephemeralStartTimestamp = 32;
optional uint32 ephemeralDuration = 33; optional uint32 ephemeralDuration = 33;
optional bool ephemeralOffToOn = 34;
optional bool ephemeralOutOfSync = 35;
enum WebMessageInfoBizPrivacyStatus {
E2EE = 0;
FB = 2;
BSP = 1;
BSP_AND_FB = 3;
}
optional WebMessageInfoBizPrivacyStatus bizPrivacyStatus = 36;
optional string verifiedBizName = 37;
} }
+4 -1
View File
@@ -24,7 +24,10 @@ var SingleByteTokens = [...]string{"", "", "", "200", "400", "404", "500", "501"
"invite", "gif", "vcard", "frequent", "privacy", "blacklist", "whitelist", "invite", "gif", "vcard", "frequent", "privacy", "blacklist", "whitelist",
"verify", "location", "document", "elapsed", "revoke_invite", "expiration", "verify", "location", "document", "elapsed", "revoke_invite", "expiration",
"unsubscribe", "disable", "vname", "old_jid", "new_jid", "announcement", "unsubscribe", "disable", "vname", "old_jid", "new_jid", "announcement",
"locked", "prop", "label", "color", "call", "offer", "call-id"} "locked", "prop", "label", "color", "call", "offer", "call-id",
"quick_reply", "sticker", "pay_t", "accept", "reject", "sticker_pack",
"invalid", "canceled", "missed", "connected", "result", "audio",
"video", "recent"}
var doubleByteTokens = [...]string{} var doubleByteTokens = [...]string{}
+87 -27
View File
@@ -2,6 +2,7 @@
package whatsapp package whatsapp
import ( import (
"fmt"
"math/rand" "math/rand"
"net/http" "net/http"
"net/url" "net/url"
@@ -9,7 +10,6 @@ import (
"time" "time"
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/pkg/errors"
) )
type metric byte type metric byte
@@ -88,6 +88,8 @@ type Conn struct {
Store *Store Store *Store
ServerLastSeen time.Time ServerLastSeen time.Time
timeTag string // last 3 digits obtained after a successful login takeover
longClientName string longClientName string
shortClientName string shortClientName string
clientVersion string clientVersion string
@@ -114,31 +116,59 @@ Creates a new connection with a given timeout. The websocket connection to the W
The goroutine for handling incoming messages is started The goroutine for handling incoming messages is started
*/ */
func NewConn(timeout time.Duration) (*Conn, error) { func NewConn(timeout time.Duration) (*Conn, error) {
wac := &Conn{ return NewConnWithOptions(&Options{
handler: make([]Handler, 0), Timeout: timeout,
msgCount: 0, })
msgTimeout: timeout,
Store: newStore(),
longClientName: "github.com/rhymen/go-whatsapp",
shortClientName: "go-whatsapp",
clientVersion: "0.1.0",
}
return wac, wac.connect()
} }
// NewConnWithProxy Create a new connect with a given timeout and a http proxy. // NewConnWithProxy Create a new connect with a given timeout and a http proxy.
func NewConnWithProxy(timeout time.Duration, proxy func(*http.Request) (*url.URL, error)) (*Conn, error) { func NewConnWithProxy(timeout time.Duration, proxy func(*http.Request) (*url.URL, error)) (*Conn, error) {
return NewConnWithOptions(&Options{
Timeout: timeout,
Proxy: proxy,
})
}
// NewConnWithOptions Create a new connect with a given options.
type Options struct {
Proxy func(*http.Request) (*url.URL, error)
Timeout time.Duration
Handler []Handler
ShortClientName string
LongClientName string
ClientVersion string
Store *Store
}
func NewConnWithOptions(opt *Options) (*Conn, error) {
if opt == nil {
return nil, ErrOptionsNotProvided
}
wac := &Conn{ wac := &Conn{
handler: make([]Handler, 0), handler: make([]Handler, 0),
msgCount: 0, msgCount: 0,
msgTimeout: timeout, msgTimeout: opt.Timeout,
Store: newStore(), Store: newStore(),
longClientName: "github.com/Rhymen/go-whatsapp",
longClientName: "github.com/rhymen/go-whatsapp",
shortClientName: "go-whatsapp", shortClientName: "go-whatsapp",
clientVersion: "0.1.0", clientVersion: "0.1.0",
Proxy: proxy, }
if opt.Handler != nil {
wac.handler = opt.Handler
}
if opt.Store != nil {
wac.Store = opt.Store
}
if opt.Proxy != nil {
wac.Proxy = opt.Proxy
}
if len(opt.ShortClientName) != 0 {
wac.shortClientName = opt.ShortClientName
}
if len(opt.LongClientName) != 0 {
wac.longClientName = opt.LongClientName
}
if len(opt.ClientVersion) != 0 {
wac.clientVersion = opt.ClientVersion
} }
return wac, wac.connect() return wac, wac.connect()
} }
@@ -156,8 +186,8 @@ func (wac *Conn) connect() (err error) {
}() }()
dialer := &websocket.Dialer{ dialer := &websocket.Dialer{
ReadBufferSize: 25 * 1024 * 1024, ReadBufferSize: 0,
WriteBufferSize: 10 * 1024 * 1024, WriteBufferSize: 0,
HandshakeTimeout: wac.msgTimeout, HandshakeTimeout: wac.msgTimeout,
Proxy: wac.Proxy, Proxy: wac.Proxy,
} }
@@ -165,7 +195,7 @@ func (wac *Conn) connect() (err error) {
headers := http.Header{"Origin": []string{"https://web.whatsapp.com"}} headers := http.Header{"Origin": []string{"https://web.whatsapp.com"}}
wsConn, _, err := dialer.Dial("wss://web.whatsapp.com/ws", headers) wsConn, _, err := dialer.Dial("wss://web.whatsapp.com/ws", headers)
if err != nil { if err != nil {
return errors.Wrap(err, "couldn't dial whatsapp web websocket") return fmt.Errorf("couldn't dial whatsapp web websocket: %w", err)
} }
wsConn.SetCloseHandler(func(code int, text string) error { wsConn.SetCloseHandler(func(code int, text string) error {
@@ -191,7 +221,7 @@ func (wac *Conn) connect() (err error) {
wac.wg = &sync.WaitGroup{} wac.wg = &sync.WaitGroup{}
wac.wg.Add(2) wac.wg.Add(2)
go wac.readPump() go wac.readPump()
go wac.keepAlive(20000, 60000) go wac.keepAlive(20000, 55000)
wac.loggedIn = false wac.loggedIn = false
return nil return nil
@@ -207,7 +237,10 @@ func (wac *Conn) Disconnect() (Session, error) {
close(wac.ws.close) //signal close close(wac.ws.close) //signal close
wac.wg.Wait() //wait for close wac.wg.Wait() //wait for close
err := wac.ws.conn.Close() var err error
if wac.ws != nil && wac.ws.conn != nil {
err = wac.ws.conn.Close()
}
wac.ws = nil wac.ws = nil
if wac.session == nil { if wac.session == nil {
@@ -216,17 +249,20 @@ func (wac *Conn) Disconnect() (Session, error) {
return *wac.session, err return *wac.session, err
} }
func (wac *Conn) AdminTest() (bool, error) { func (wac *Conn) IsLoginInProgress() bool {
return wac.sessionLock == 1
}
func (wac *Conn) AdminTest() error {
if !wac.connected { if !wac.connected {
return false, ErrNotConnected return ErrNotConnected
} }
if !wac.loggedIn { if !wac.loggedIn {
return false, ErrInvalidSession return ErrInvalidSession
} }
result, err := wac.sendAdminTest() return wac.sendAdminTest()
return result, err
} }
func (wac *Conn) keepAlive(minIntervalMs int, maxIntervalMs int) { func (wac *Conn) keepAlive(minIntervalMs int, maxIntervalMs int) {
@@ -235,7 +271,7 @@ func (wac *Conn) keepAlive(minIntervalMs int, maxIntervalMs int) {
for { for {
err := wac.sendKeepAlive() err := wac.sendKeepAlive()
if err != nil { if err != nil {
wac.handle(errors.Wrap(err, "keepAlive failed")) wac.handle(fmt.Errorf("keepAlive failed: %w", err))
//TODO: Consequences? //TODO: Consequences?
} }
interval := rand.Intn(maxIntervalMs-minIntervalMs) + minIntervalMs interval := rand.Intn(maxIntervalMs-minIntervalMs) + minIntervalMs
@@ -246,3 +282,27 @@ func (wac *Conn) keepAlive(minIntervalMs int, maxIntervalMs int) {
} }
} }
} }
// IsConnected returns whether the server connection is established or not
func (wac *Conn) IsConnected() bool {
return wac.connected
}
// GetConnected returns whether the server connection is established or not
//
// Deprecated: function name is not go idiomatic, use IsConnected instead
func (wac *Conn) GetConnected() bool {
return wac.connected
}
//IsLoggedIn returns whether the you are logged in or not
func (wac *Conn) IsLoggedIn() bool {
return wac.loggedIn
}
// GetLoggedIn returns whether the you are logged in or not
//
// Deprecated: function name is not go idiomatic, use IsLoggedIn instead.
func (wac *Conn) GetLoggedIn() bool {
return wac.loggedIn
}
+23 -10
View File
@@ -39,20 +39,20 @@ func (wac *Conn) Search(search string, count, page int) (*binary.Node, error) {
return wac.query("search", "", "", "", "", search, count, page) return wac.query("search", "", "", "", "", search, count, page)
} }
func (wac *Conn) LoadMessages(jid, messageId string, count int) (*binary.Node, error) { func (wac *Conn) LoadMessages(jid string, count int) (*binary.Node, error) {
return wac.query("message", jid, "", "before", "true", "", count, 0) return wac.query("message", jid, "", "before", "true", "", count, 0)
} }
func (wac *Conn) LoadMessagesBefore(jid, messageId string, count int) (*binary.Node, error) { func (wac *Conn) LoadMessagesBefore(jid, messageId string, fromMe bool, count int) (*binary.Node, error) {
return wac.query("message", jid, messageId, "before", "true", "", count, 0) return wac.query("message", jid, messageId, "before", strconv.FormatBool(fromMe), "", count, 0)
} }
func (wac *Conn) LoadMessagesAfter(jid, messageId string, count int) (*binary.Node, error) { func (wac *Conn) LoadMessagesAfter(jid, messageId string, fromMe bool, count int) (*binary.Node, error) {
return wac.query("message", jid, messageId, "after", "true", "", count, 0) return wac.query("message", jid, messageId, "after", strconv.FormatBool(fromMe), "", count, 0)
} }
func (wac *Conn) LoadMediaInfo(jid, messageId, owner string) (*binary.Node, error) { func (wac *Conn) LoadMediaInfo(jid, messageId string, fromMe bool) (*binary.Node, error) {
return wac.query("media", jid, messageId, "", owner, "", 0, 0) return wac.query("media", jid, messageId, "", strconv.FormatBool(fromMe), "", 0, 0)
} }
func (wac *Conn) Presence(jid string, presence Presence) (<-chan string, error) { func (wac *Conn) Presence(jid string, presence Presence) (<-chan string, error) {
@@ -96,11 +96,19 @@ func (wac *Conn) Emoji() (*binary.Node, error) {
} }
func (wac *Conn) Contacts() (*binary.Node, error) { func (wac *Conn) Contacts() (*binary.Node, error) {
return wac.query("contacts", "", "", "", "", "", 0, 0) node, err := wac.query("contacts", "", "", "", "", "", 0, 0)
if node != nil && node.Description == "response" && node.Attributes["type"] == "contacts" {
wac.updateContacts(node.Content)
}
return node, err
} }
func (wac *Conn) Chats() (*binary.Node, error) { func (wac *Conn) Chats() (*binary.Node, error) {
return wac.query("chat", "", "", "", "", "", 0, 0) node, err := wac.query("chat", "", "", "", "", "", 0, 0)
if node != nil && node.Description == "response" && node.Attributes["type"] == "chat" {
wac.updateChats(node.Content)
}
return node, err
} }
func (wac *Conn) Read(jid, id string) (<-chan string, error) { func (wac *Conn) Read(jid, id string) (<-chan string, error) {
@@ -177,13 +185,18 @@ func (wac *Conn) query(t, jid, messageId, kind, owner, search string, count, pag
return nil, err return nil, err
} }
msg, err := wac.decryptBinaryMessage([]byte(<-ch)) select {
case response := <-ch:
msg, err := wac.decryptBinaryMessage([]byte(response))
if err != nil { if err != nil {
return nil, err return nil, err
} }
//TODO: use parseProtoMessage //TODO: use parseProtoMessage
return msg, nil return msg, nil
case <-time.After(3 * time.Minute):
return nil, ErrQueryTimeout
}
} }
func (wac *Conn) setGroup(t, jid, subject string, participants []string) (<-chan string, error) { func (wac *Conn) setGroup(t, jid, subject string, participants []string) (<-chan string, error) {
+52 -1
View File
@@ -1,8 +1,9 @@
package whatsapp package whatsapp
import ( import (
"encoding/json"
"errors"
"fmt" "fmt"
"github.com/pkg/errors"
) )
var ( var (
@@ -20,6 +21,28 @@ var (
ErrServerRespondedWith404 = errors.New("server responded with status 404") ErrServerRespondedWith404 = errors.New("server responded with status 404")
ErrMediaDownloadFailedWith404 = errors.New("download failed with status code 404") ErrMediaDownloadFailedWith404 = errors.New("download failed with status code 404")
ErrMediaDownloadFailedWith410 = errors.New("download failed with status code 410") ErrMediaDownloadFailedWith410 = errors.New("download failed with status code 410")
ErrLoginTimedOut = errors.New("login timed out")
ErrQueryTimeout = errors.New("query timed out")
ErrBadRequest = errors.New("400 (bad request)")
ErrUnpaired = errors.New("401 (unpaired from phone)")
ErrAccessDenied = errors.New("403 (access denied)")
ErrLoggedIn = errors.New("405 (already logged in)")
ErrReplaced = errors.New("409 (logged in from another location)")
ErrNoURLPresent = errors.New("no url present")
ErrFileLengthMismatch = errors.New("file length does not match")
ErrInvalidHashLength = errors.New("hash too short")
ErrTooShortFile = errors.New("file too short")
ErrInvalidMediaHMAC = errors.New("invalid media hmac")
ErrCantGetInviteLink = errors.New("you don't have the permission to view the invite link")
ErrJoinUnauthorized = errors.New("you're not allowed to join that group")
ErrInvalidWebsocket = errors.New("invalid websocket")
ErrMessageTypeNotImplemented = errors.New("message type not implemented")
ErrOptionsNotProvided = errors.New("new conn options not provided")
) )
type ErrConnectionFailed struct { type ErrConnectionFailed struct {
@@ -38,3 +61,31 @@ type ErrConnectionClosed struct {
func (e *ErrConnectionClosed) Error() string { func (e *ErrConnectionClosed) Error() string {
return fmt.Sprintf("server closed connection,code: %d,text: %s", e.Code, e.Text) return fmt.Sprintf("server closed connection,code: %d,text: %s", e.Code, e.Text)
} }
type StatusResponseFields struct {
// The response status code. This is always expected to be present.
Status int `json:"status"`
// Some error messages include a "tos" value. If it's higher than 0, it
// might mean the user has been banned for breaking the terms of service.
TermsOfService int `json:"tos,omitempty"`
// This is a timestamp that's at least present in message send responses.
Timestamp int64 `json:"t,omitempty"`
}
type StatusResponse struct {
StatusResponseFields
RequestType string `json:"-"`
Extra map[string]interface{} `json:"-"`
}
func (sr *StatusResponse) UnmarshalJSON(data []byte) error {
err := json.Unmarshal(data, &sr.Extra)
if err != nil {
return err
}
return json.Unmarshal(data, &sr.StatusResponseFields)
}
func (sr StatusResponse) Error() string {
return fmt.Sprintf("%s responded with %d", sr.RequestType, sr.Status)
}
+7 -11
View File
@@ -1,14 +1,10 @@
module github.com/Rhymen/go-whatsapp module github.com/Rhymen/go-whatsapp
require ( go 1.11
github.com/Rhymen/go-whatsapp/examples/echo v0.0.0-20190325075644-cc2581bbf24d // indirect
github.com/Rhymen/go-whatsapp/examples/restoreSession v0.0.0-20190325075644-cc2581bbf24d // indirect
github.com/Rhymen/go-whatsapp/examples/sendImage v0.0.0-20190325075644-cc2581bbf24d // indirect
github.com/Rhymen/go-whatsapp/examples/sendTextMessages v0.0.0-20190325075644-cc2581bbf24d // indirect
github.com/golang/protobuf v1.3.0
github.com/gorilla/websocket v1.4.1
github.com/pkg/errors v0.8.1
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
)
go 1.13 require (
github.com/golang/protobuf v1.4.2
github.com/gorilla/websocket v1.4.2
golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9
google.golang.org/protobuf v1.24.0
)
+66 -32
View File
@@ -1,36 +1,70 @@
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f h1:2dk3eOnYllh+wUOuDhOoC2vUVoJF/5z478ryJ+wzEII= 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/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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/Rhymen/go-whatsapp/examples/echo v0.0.0-20190325075644-cc2581bbf24d h1:m3wkrunHupL9XzzM+JZu1pgoDV1d9LFtD0gedNTHVDU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/Rhymen/go-whatsapp/examples/echo v0.0.0-20190325075644-cc2581bbf24d/go.mod h1:zgCiQtBtZ4P4gFWvwl9aashsdwOcbb/EHOGRmSzM8ME= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/Rhymen/go-whatsapp/examples/restoreSession v0.0.0-20190325075644-cc2581bbf24d h1:muQlzqfZxjptOBjPdv+UoxVMr8Y1rPx7VMGPJIAFc5w= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/Rhymen/go-whatsapp/examples/restoreSession v0.0.0-20190325075644-cc2581bbf24d/go.mod h1:5sCUSpG616ZoSJhlt9iBNI/KXBqrVLcNUJqg7J9+8pU= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/Rhymen/go-whatsapp/examples/sendImage v0.0.0-20190325075644-cc2581bbf24d h1:xP//3V77YvHd1cj2Z3ttuQWAvs5WmIwBbjKe/t0g/tM= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
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 h1:IRmRE0SPMByczwE2dhnTcVojje3w2TCSKwFrboLUbDg=
github.com/Rhymen/go-whatsapp/examples/sendTextMessages v0.0.0-20190325075644-cc2581bbf24d/go.mod h1:suwzklatySS3Q0+NCxCDh5hYfgXdQUWU1DNcxwAxStM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 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.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/mattn/go-isatty v0.0.5 h1:tHXDdz1cpzGaovsTB+TVB8q90WEokoVmfMqoVcrLUgw= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9 h1:lpEzuenPuO1XNTeikEmvqYFcU37GVLl8SRNblzyvGBE= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9/go.mod h1:PLPIyL7ikehBD1OAjmKKiOEhbvWyHGaNDjquXMcYABo= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9 h1:vEg9joUBmeBcK9iSJftGNf3coIG4HqZElCPehJsfAYM=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= 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-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-20180314180146-1d60e4601c6f/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-20181108010431-42b317875d0f/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-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
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-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/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.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA=
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
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=
+78 -4
View File
@@ -3,7 +3,10 @@ package whatsapp
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"strconv"
"time" "time"
"github.com/Rhymen/go-whatsapp/binary"
) )
func (wac *Conn) GetGroupMetaData(jid string) (<-chan string, error) { func (wac *Conn) GetGroupMetaData(jid string) (<-chan string, error) {
@@ -57,8 +60,11 @@ func (wac *Conn) GroupInviteLink(jid string) (string, error) {
return "", fmt.Errorf("request timed out") return "", fmt.Errorf("request timed out")
} }
if int(response["status"].(float64)) != 200 { status := int(response["status"].(float64))
return "", fmt.Errorf("request responded with %d", response["status"]) if status == 401 {
return "", ErrCantGetInviteLink
} else if status != 200 {
return "", fmt.Errorf("request responded with %d", status)
} }
return response["code"].(string), nil return response["code"].(string), nil
@@ -82,9 +88,77 @@ func (wac *Conn) GroupAcceptInviteCode(code string) (jid string, err error) {
return "", fmt.Errorf("request timed out") return "", fmt.Errorf("request timed out")
} }
if int(response["status"].(float64)) != 200 { status := int(response["status"].(float64))
return "", fmt.Errorf("request responded with %d", response["status"])
if status == 401 {
return "", ErrJoinUnauthorized
} else if status != 200 {
return "", fmt.Errorf("request responded with %d", status)
} }
return response["gid"].(string), nil return response["gid"].(string), nil
} }
type descriptionID struct {
DescID string `json:"descId"`
}
func (wac *Conn) getDescriptionID(jid string) (string, error) {
data, err := wac.GetGroupMetaData(jid)
if err != nil {
return "none", err
}
var oldData descriptionID
err = json.Unmarshal([]byte(<-data), &oldData)
if err != nil {
return "none", err
}
if oldData.DescID == "" {
return "none", nil
}
return oldData.DescID, nil
}
func (wac *Conn) UpdateGroupDescription(jid, description string) (<-chan string, error) {
prevID, err := wac.getDescriptionID(jid)
if err != nil {
return nil, err
}
newData := map[string]string{
"prev": prevID,
}
var desc interface{} = description
if description == "" {
newData["delete"] = "true"
desc = nil
} else {
newData["id"] = fmt.Sprintf("%d-%d", time.Now().Unix(), wac.msgCount*19)
}
tag := fmt.Sprintf("%d.--%d", time.Now().Unix(), wac.msgCount*19)
n := binary.Node{
Description: "action",
Attributes: map[string]string{
"type": "set",
"epoch": strconv.Itoa(wac.msgCount),
},
Content: []interface{}{
binary.Node{
Description: "group",
Attributes: map[string]string{
"id": tag,
"jid": jid,
"type": "description",
"author": wac.Info.Wid,
},
Content: []binary.Node{
{
Description: "description",
Attributes: newData,
Content: desc,
},
},
},
},
}
return wac.writeBinary(n, group, 136, tag)
}
+112
View File
@@ -117,6 +117,12 @@ type RawMessageHandler interface {
HandleRawMessage(message *proto.WebMessageInfo) HandleRawMessage(message *proto.WebMessageInfo)
} }
// The UnknownBinaryHandler interface needs to be implemented to receive unhandled binary messages.
type UnknownBinaryHandler interface {
Handler
HandleUnknownBinaryNode(message *binary.Node)
}
/** /**
The ContactListHandler interface needs to be implemented to applky custom actions to contact lists dispatched by the dispatcher. The ContactListHandler interface needs to be implemented to applky custom actions to contact lists dispatched by the dispatcher.
*/ */
@@ -133,6 +139,32 @@ type ChatListHandler interface {
HandleChatList(contacts []Chat) HandleChatList(contacts []Chat)
} }
/**
The BatteryMessageHandler interface needs to be implemented to receive percentage the device connected dispatched by the dispatcher.
*/
type BatteryMessageHandler interface {
Handler
HandleBatteryMessage(battery BatteryMessage)
}
type ReadMessageHandler interface {
Handler
HandleReadMessage(read ReadMessage)
}
type ReceivedMessageHandler interface {
Handler
HandleReceivedMessage(received ReceivedMessage)
}
/**
The NewContactHandler interface needs to be implemented to receive the contact's name for the first time.
*/
type NewContactHandler interface {
Handler
HandleNewContact(contact Contact)
}
/* /*
AddHandler adds an handler to the list of handler that receive dispatched messages. AddHandler adds an handler to the list of handler that receive dispatched messages.
The provided handler must at least implement the Handler interface. Additionally implemented The provided handler must at least implement the Handler interface. Additionally implemented
@@ -170,6 +202,19 @@ func (wac *Conn) shouldCallSynchronously(handler Handler) bool {
} }
func (wac *Conn) handle(message interface{}) { func (wac *Conn) handle(message interface{}) {
defer func() {
if errIfc := recover(); errIfc != nil {
if err, ok := errIfc.(error); ok {
wac.unsafeHandle(fmt.Errorf("panic in WhatsApp handler: %w", err))
} else {
wac.unsafeHandle(fmt.Errorf("panic in WhatsApp handler: %v", errIfc))
}
}
}()
wac.unsafeHandle(message)
}
func (wac *Conn) unsafeHandle(message interface{}) {
wac.handleWithCustomHandlers(message, wac.handler) wac.handleWithCustomHandlers(message, wac.handler)
} }
@@ -286,6 +331,50 @@ func (wac *Conn) handleWithCustomHandlers(message interface{}, handlers []Handle
} }
} }
case BatteryMessage:
for _, h := range handlers {
if x, ok := h.(BatteryMessageHandler); ok {
if wac.shouldCallSynchronously(h) {
x.HandleBatteryMessage(m)
} else {
go x.HandleBatteryMessage(m)
}
}
}
case Contact:
for _, h := range handlers {
if x, ok := h.(NewContactHandler); ok {
if wac.shouldCallSynchronously(h) {
x.HandleNewContact(m)
} else {
go x.HandleNewContact(m)
}
}
}
case ReadMessage:
for _, h := range handlers {
if x, ok := h.(ReadMessageHandler); ok {
if wac.shouldCallSynchronously(h) {
x.HandleReadMessage(m)
} else {
go x.HandleReadMessage(m)
}
}
}
case ReceivedMessage:
for _, h := range handlers {
if x, ok := h.(ReceivedMessageHandler); ok {
if wac.shouldCallSynchronously(h) {
x.HandleReceivedMessage(m)
} else {
go x.HandleReceivedMessage(m)
}
}
}
case *proto.WebMessageInfo: case *proto.WebMessageInfo:
for _, h := range handlers { for _, h := range handlers {
if x, ok := h.(RawMessageHandler); ok { if x, ok := h.(RawMessageHandler); ok {
@@ -296,6 +385,17 @@ func (wac *Conn) handleWithCustomHandlers(message interface{}, handlers []Handle
} }
} }
} }
case *binary.Node:
for _, h := range handlers {
if x, ok := h.(UnknownBinaryHandler); ok {
if wac.shouldCallSynchronously(h) {
x.HandleUnknownBinaryNode(m)
} else {
go x.HandleUnknownBinaryNode(m)
}
}
}
} }
} }
@@ -378,14 +478,26 @@ func (wac *Conn) dispatch(msg interface{}) {
wac.handle(v) wac.handle(v)
wac.handle(ParseProtoMessage(v)) wac.handle(ParseProtoMessage(v))
} }
if v, ok := con[a].(binary.Node); ok {
wac.handle(ParseNodeMessage(v))
} }
} }
} else if con, ok := message.Content.([]binary.Node); ok {
for a := range con {
wac.handle(ParseNodeMessage(con[a]))
}
} else {
wac.handle(message)
}
} else if message.Description == "response" && message.Attributes["type"] == "contacts" { } else if message.Description == "response" && message.Attributes["type"] == "contacts" {
wac.updateContacts(message.Content) wac.updateContacts(message.Content)
wac.handleContacts(message.Content) wac.handleContacts(message.Content)
} else if message.Description == "response" && message.Attributes["type"] == "chat" { } else if message.Description == "response" && message.Attributes["type"] == "chat" {
wac.updateChats(message.Content) wac.updateChats(message.Content)
wac.handleChats(message.Content) wac.handleChats(message.Content)
} else {
wac.handle(message)
} }
case error: case error:
wac.handle(message) wac.handle(message)
+30 -14
View File
@@ -10,6 +10,7 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"net"
"net/http" "net/http"
"net/url" "net/url"
"time" "time"
@@ -20,7 +21,7 @@ import (
func Download(url string, mediaKey []byte, appInfo MediaType, fileLength int) ([]byte, error) { func Download(url string, mediaKey []byte, appInfo MediaType, fileLength int) ([]byte, error) {
if url == "" { if url == "" {
return nil, fmt.Errorf("no url present") return nil, ErrNoURLPresent
} }
file, mac, err := downloadMedia(url) file, mac, err := downloadMedia(url)
if err != nil { if err != nil {
@@ -38,7 +39,7 @@ func Download(url string, mediaKey []byte, appInfo MediaType, fileLength int) ([
return nil, err return nil, err
} }
if len(data) != fileLength { if len(data) != fileLength {
return nil, fmt.Errorf("file length does not match") return nil, ErrFileLengthMismatch
} }
return data, nil return data, nil
} }
@@ -50,10 +51,10 @@ func validateMedia(iv []byte, file []byte, macKey []byte, mac []byte) error {
return err return err
} }
if n < 10 { if n < 10 {
return fmt.Errorf("hash to short") return ErrInvalidHashLength
} }
if !hmac.Equal(h.Sum(nil)[:10], mac) { if !hmac.Equal(h.Sum(nil)[:10], mac) {
return fmt.Errorf("invalid media hmac") return ErrInvalidMediaHMAC
} }
return nil return nil
} }
@@ -71,18 +72,18 @@ func downloadMedia(url string) (file []byte, mac []byte, err error) {
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
if resp.StatusCode != 200 { defer resp.Body.Close()
if resp.StatusCode == 404 { if resp.StatusCode != http.StatusOK {
if resp.StatusCode == http.StatusNotFound {
return nil, nil, ErrMediaDownloadFailedWith404 return nil, nil, ErrMediaDownloadFailedWith404
} }
if resp.StatusCode == 410 { if resp.StatusCode == http.StatusGone {
return nil, nil, ErrMediaDownloadFailedWith410 return nil, nil, ErrMediaDownloadFailedWith410
} }
return nil, nil, fmt.Errorf("download failed with status code %d", resp.StatusCode) return nil, nil, fmt.Errorf("download failed with status code %d", resp.StatusCode)
} }
defer resp.Body.Close()
if resp.ContentLength <= 10 { if resp.ContentLength <= 10 {
return nil, nil, fmt.Errorf("file to short") return nil, nil, ErrTooShortFile
} }
data, err := ioutil.ReadAll(resp.Body) data, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
@@ -100,7 +101,10 @@ type MediaConn struct {
TTL int `json:"ttl"` TTL int `json:"ttl"`
Hosts []struct { Hosts []struct {
Hostname string `json:"hostname"` Hostname string `json:"hostname"`
IPs []string `json:"ips"` IPs []struct {
IP4 net.IP `json:"ip4"`
IP6 net.IP `json:"ip6"`
} `json:"ips"`
} `json:"hosts"` } `json:"hosts"`
} `json:"media_conn"` } `json:"media_conn"`
} }
@@ -122,11 +126,17 @@ func (wac *Conn) queryMediaConn() (hostname, auth string, ttl int, err error) {
return "", "", 0, fmt.Errorf("query media conn timed out") return "", "", 0, fmt.Errorf("query media conn timed out")
} }
if resp.Status != 200 { if resp.Status != http.StatusOK {
return "", "", 0, fmt.Errorf("query media conn responded with %d", resp.Status) return "", "", 0, fmt.Errorf("query media conn responded with %d", resp.Status)
} }
return resp.MediaConn.Hosts[0].Hostname, resp.MediaConn.Auth, resp.MediaConn.TTL, nil for _, h := range resp.MediaConn.Hosts {
if h.Hostname != "" {
return h.Hostname, resp.MediaConn.Auth, resp.MediaConn.TTL, nil
}
}
return "", "", 0, fmt.Errorf("query media conn responded with no host")
} }
var mediaTypeMap = map[MediaType]string{ var mediaTypeMap = map[MediaType]string{
@@ -170,6 +180,10 @@ func (wac *Conn) Upload(reader io.Reader, appInfo MediaType) (downloadURL string
fileEncSha256 = sha.Sum(nil) fileEncSha256 = sha.Sum(nil)
hostname, auth, _, err := wac.queryMediaConn() hostname, auth, _, err := wac.queryMediaConn()
if err != nil {
return "", nil, nil, nil, 0, err
}
token := base64.URLEncoding.EncodeToString(fileEncSha256) token := base64.URLEncoding.EncodeToString(fileEncSha256)
q := url.Values{ q := url.Values{
"auth": []string{auth}, "auth": []string{auth},
@@ -185,7 +199,7 @@ func (wac *Conn) Upload(reader io.Reader, appInfo MediaType) (downloadURL string
body := bytes.NewReader(append(enc, mac...)) body := bytes.NewReader(append(enc, mac...))
req, err := http.NewRequest("POST", uploadURL.String(), body) req, err := http.NewRequest(http.MethodPost, uploadURL.String(), body)
if err != nil { if err != nil {
return "", nil, nil, nil, 0, err return "", nil, nil, nil, 0, err
} }
@@ -205,7 +219,9 @@ func (wac *Conn) Upload(reader io.Reader, appInfo MediaType) (downloadURL string
} }
var jsonRes map[string]string var jsonRes map[string]string
json.NewDecoder(res.Body).Decode(&jsonRes) if err := json.NewDecoder(res.Body).Decode(&jsonRes); err != nil {
return "", nil, nil, nil, 0, err
}
return jsonRes["url"], mediaKey, fileEncSha256, fileSha256, fileLength, nil return jsonRes["url"], mediaKey, fileEncSha256, fileSha256, fileLength, nil
} }
+199 -15
View File
@@ -12,6 +12,7 @@ import (
"github.com/Rhymen/go-whatsapp/binary" "github.com/Rhymen/go-whatsapp/binary"
"github.com/Rhymen/go-whatsapp/binary/proto" "github.com/Rhymen/go-whatsapp/binary/proto"
"github.com/davecgh/go-spew/spew"
) )
type MediaType string type MediaType string
@@ -23,6 +24,23 @@ const (
MediaDocument MediaType = "WhatsApp Document Keys" MediaDocument MediaType = "WhatsApp Document Keys"
) )
func (wac *Conn) SendRaw(msg *proto.WebMessageInfo, output chan<- error) {
ch, err := wac.sendProto(msg)
if err != nil {
output <- fmt.Errorf("could not send proto: %w", err)
return
}
response := <-ch
resp := StatusResponse{RequestType: "message sending"}
if err = json.Unmarshal([]byte(response), &resp); err != nil {
output <- fmt.Errorf("error decoding sending response: %w", err)
} else if resp.Status != 200 {
output <- resp
} else {
output <- nil
}
}
func (wac *Conn) Send(msg interface{}) (string, error) { func (wac *Conn) Send(msg interface{}) (string, error) {
var msgProto *proto.WebMessageInfo var msgProto *proto.WebMessageInfo
@@ -76,21 +94,16 @@ func (wac *Conn) Send(msg interface{}) (string, error) {
select { select {
case response := <-ch: case response := <-ch:
var resp map[string]interface{} resp := StatusResponse{RequestType: "message sending"}
if err = json.Unmarshal([]byte(response), &resp); err != nil { if err = json.Unmarshal([]byte(response), &resp); err != nil {
return "ERROR", fmt.Errorf("error decoding sending response: %v\n", err) return "ERROR", fmt.Errorf("error decoding sending response: %v\n", err)
} else if resp.Status != 200 {
return "ERROR", resp
} }
if int(resp["status"].(float64)) != 200 {
return "ERROR", fmt.Errorf("message sending responded with %d", resp["status"])
}
if int(resp["status"].(float64)) == 200 {
return getMessageInfo(msgProto).Id, nil return getMessageInfo(msgProto).Id, nil
}
case <-time.After(wac.msgTimeout): case <-time.After(wac.msgTimeout):
return "ERROR", fmt.Errorf("sending message timed out") return "ERROR", fmt.Errorf("sending message timed out")
} }
return "ERROR", nil
} }
func (wac *Conn) sendProto(p *proto.WebMessageInfo) (<-chan string, error) { func (wac *Conn) sendProto(p *proto.WebMessageInfo) (<-chan string, error) {
@@ -105,6 +118,100 @@ func (wac *Conn) sendProto(p *proto.WebMessageInfo) (<-chan string, error) {
return wac.writeBinary(n, message, ignore, p.Key.GetId()) return wac.writeBinary(n, message, ignore, p.Key.GetId())
} }
// RevokeMessage revokes a message (marks as "message removed") for everyone
func (wac *Conn) RevokeMessage(remotejid, msgid string, fromme bool) (revokeid string, err error) {
// create a revocation ID (required)
rawrevocationID := make([]byte, 10)
rand.Read(rawrevocationID)
revocationID := strings.ToUpper(hex.EncodeToString(rawrevocationID))
//
ts := uint64(time.Now().Unix())
status := proto.WebMessageInfo_PENDING
mtype := proto.ProtocolMessage_REVOKE
revoker := &proto.WebMessageInfo{
Key: &proto.MessageKey{
FromMe: &fromme,
Id: &revocationID,
RemoteJid: &remotejid,
},
MessageTimestamp: &ts,
Message: &proto.Message{
ProtocolMessage: &proto.ProtocolMessage{
Type: &mtype,
Key: &proto.MessageKey{
FromMe: &fromme,
Id: &msgid,
RemoteJid: &remotejid,
},
},
},
Status: &status,
}
if _, err := wac.Send(revoker); err != nil {
return revocationID, err
}
return revocationID, nil
}
// DeleteMessage deletes a single message for the user (removes the msgbox). To
// delete the message for everyone, use RevokeMessage
func (wac *Conn) DeleteMessage(remotejid, msgid string, fromMe bool) error {
ch, err := wac.deleteChatProto(remotejid, msgid, fromMe)
if err != nil {
return fmt.Errorf("could not send proto: %v", err)
}
select {
case response := <-ch:
resp := StatusResponse{RequestType: "message deletion"}
if err = json.Unmarshal([]byte(response), &resp); err != nil {
return fmt.Errorf("error decoding deletion response: %v", err)
} else if resp.Status != 200 {
return resp
}
return nil
case <-time.After(wac.msgTimeout):
return fmt.Errorf("deleting message timed out")
}
}
func (wac *Conn) deleteChatProto(remotejid, msgid string, fromMe bool) (<-chan string, error) {
tag := fmt.Sprintf("%s.--%d", wac.timeTag, wac.msgCount)
owner := "true"
if !fromMe {
owner = "false"
}
n := binary.Node{
Description: "action",
Attributes: map[string]string{
"epoch": strconv.Itoa(wac.msgCount),
"type": "set",
},
Content: []interface{}{
binary.Node{
Description: "chat",
Attributes: map[string]string{
"type": "clear",
"jid": remotejid,
"media": "true",
},
Content: []binary.Node{
{
Description: "item",
Attributes: map[string]string{
"owner": owner,
"index": msgid,
},
},
},
},
},
}
return wac.writeBinary(n, chat, expires|skipOffline, tag)
}
func init() { func init() {
rand.Seed(time.Now().UTC().UnixNano()) rand.Seed(time.Now().UTC().UnixNano())
} }
@@ -139,7 +246,7 @@ func getMessageInfo(msg *proto.WebMessageInfo) MessageInfo {
return MessageInfo{ return MessageInfo{
Id: msg.GetKey().GetId(), Id: msg.GetKey().GetId(),
RemoteJid: msg.GetKey().GetRemoteJid(), RemoteJid: msg.GetKey().GetRemoteJid(),
SenderJid: msg.GetKey().GetParticipant(), SenderJid: msg.GetParticipant(),
FromMe: msg.GetKey().GetFromMe(), FromMe: msg.GetKey().GetFromMe(),
Timestamp: msg.GetMessageTimestamp(), Timestamp: msg.GetMessageTimestamp(),
Status: MessageStatus(msg.GetStatus()), Status: MessageStatus(msg.GetStatus()),
@@ -159,7 +266,7 @@ func getInfoProto(info *MessageInfo) *proto.WebMessageInfo {
} }
info.FromMe = true info.FromMe = true
status := proto.WebMessageInfo_WEB_MESSAGE_INFO_STATUS(info.Status) status := proto.WebMessageInfo_WebMessageInfoStatus(info.Status)
return &proto.WebMessageInfo{ return &proto.WebMessageInfo{
Key: &proto.MessageKey{ Key: &proto.MessageKey{
@@ -180,15 +287,16 @@ type ContextInfo struct {
QuotedMessage *proto.Message QuotedMessage *proto.Message
Participant string Participant string
IsForwarded bool IsForwarded bool
MentionedJID []string
} }
func getMessageContext(msg *proto.ContextInfo) ContextInfo { func getMessageContext(msg *proto.ContextInfo) ContextInfo {
return ContextInfo{ return ContextInfo{
QuotedMessageID: msg.GetStanzaId(), // StanzaId QuotedMessageID: msg.GetStanzaId(), // StanzaId
QuotedMessage: msg.GetQuotedMessage(), QuotedMessage: msg.GetQuotedMessage(),
Participant: msg.GetParticipant(), Participant: msg.GetParticipant(),
IsForwarded: msg.GetIsForwarded(), IsForwarded: msg.GetIsForwarded(),
MentionedJID: msg.GetMentionedJid(),
} }
} }
@@ -226,7 +334,6 @@ func getTextMessage(msg *proto.WebMessageInfo) TextMessage {
text.ContextInfo = getMessageContext(m.GetContextInfo()) text.ContextInfo = getMessageContext(m.GetContextInfo())
} else { } else {
text.Text = msg.GetMessage().GetConversation() text.Text = msg.GetMessage().GetConversation()
} }
return text return text
@@ -704,7 +811,6 @@ func getContactMessageProto(msg ContactMessage) *proto.WebMessageInfo {
} }
func ParseProtoMessage(msg *proto.WebMessageInfo) interface{} { func ParseProtoMessage(msg *proto.WebMessageInfo) interface{} {
switch { switch {
case msg.GetMessage().GetAudioMessage() != nil: case msg.GetMessage().GetAudioMessage() != nil:
@@ -739,8 +845,86 @@ func ParseProtoMessage(msg *proto.WebMessageInfo) interface{} {
default: default:
// cannot match message // cannot match message
spew.Dump(msg)
return ErrMessageTypeNotImplemented
}
} }
return nil /*
BatteryMessage represents a battery level and charging state.
*/
type BatteryMessage struct {
Plugged bool
Powersave bool
Percentage int
}
func getBatteryMessage(msg map[string]string) BatteryMessage {
plugged, _ := strconv.ParseBool(msg["live"])
powersave, _ := strconv.ParseBool(msg["powersave"])
percentage, _ := strconv.Atoi(msg["value"])
batteryMessage := BatteryMessage{
Plugged: plugged,
Powersave: powersave,
Percentage: percentage,
}
return batteryMessage
}
func getNewContact(msg map[string]string) Contact {
contact := Contact{
Jid: msg["jid"],
Notify: msg["notify"],
}
return contact
}
// ReadMessage represents a chat that the user read on the WhatsApp mobile app.
type ReadMessage struct {
Jid string
}
func getReadMessage(msg map[string]string) ReadMessage {
return ReadMessage{
Jid: msg["jid"],
}
}
// ReceivedMessage probably represents a message that the user read on the WhatsApp mobile app.
type ReceivedMessage struct {
Index string
Jid string
Owner bool
Participant string
Type string
}
func getReceivedMessage(msg map[string]string) ReceivedMessage {
owner, _ := strconv.ParseBool(msg["owner"])
// This field might not exist
participant, _ := msg["participant"]
return ReceivedMessage{
Index: msg["index"],
Jid: msg["jid"],
Owner: owner,
Participant: participant,
Type: msg["type"],
}
}
func ParseNodeMessage(msg binary.Node) interface{} {
switch msg.Description {
case "battery":
return getBatteryMessage(msg.Attributes)
case "user":
return getNewContact(msg.Attributes)
case "read":
return getReadMessage(msg.Attributes)
case "received":
return getReceivedMessage(msg.Attributes)
default:
return &msg
}
} }
+23 -13
View File
@@ -5,13 +5,15 @@ import (
"crypto/sha256" "crypto/sha256"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/Rhymen/go-whatsapp/binary"
"github.com/Rhymen/go-whatsapp/crypto/cbc"
"github.com/gorilla/websocket"
"github.com/pkg/errors"
"io" "io"
"io/ioutil" "io/ioutil"
"net/http"
"strings" "strings"
"github.com/gorilla/websocket"
"github.com/Rhymen/go-whatsapp/binary"
"github.com/Rhymen/go-whatsapp/crypto/cbc"
) )
func (wac *Conn) readPump() { func (wac *Conn) readPump() {
@@ -27,7 +29,9 @@ func (wac *Conn) readPump() {
for { for {
readerFound := make(chan struct{}) readerFound := make(chan struct{})
go func() { go func() {
if wac.ws != nil {
msgType, reader, readErr = wac.ws.conn.NextReader() msgType, reader, readErr = wac.ws.conn.NextReader()
}
close(readerFound) close(readerFound)
}() }()
select { select {
@@ -38,12 +42,12 @@ func (wac *Conn) readPump() {
} }
msg, err := ioutil.ReadAll(reader) msg, err := ioutil.ReadAll(reader)
if err != nil { if err != nil {
wac.handle(errors.Wrap(err, "error reading message from Reader")) wac.handle(fmt.Errorf("error reading message from Reader: %w", err))
continue continue
} }
err = wac.processReadData(msgType, msg) err = wac.processReadData(msgType, msg)
if err != nil { if err != nil {
wac.handle(errors.Wrap(err, "error processing data")) wac.handle(fmt.Errorf("error processing data: %w", err))
} }
case <-wac.ws.close: case <-wac.ws.close:
return return
@@ -59,6 +63,10 @@ func (wac *Conn) processReadData(msgType int, msg []byte) error {
data[0] = "!" data[0] = "!"
} }
if len(data) == 2 && len(data[1]) == 0 {
return nil
}
if len(data) != 2 || len(data[1]) == 0 { if len(data) != 2 || len(data[1]) == 0 {
return ErrInvalidWsData return ErrInvalidWsData
} }
@@ -88,7 +96,7 @@ func (wac *Conn) processReadData(msgType int, msg []byte) error {
} }
message, err := wac.decryptBinaryMessage([]byte(data[1])) message, err := wac.decryptBinaryMessage([]byte(data[1]))
if err != nil { if err != nil {
return errors.Wrap(err, "error decoding binary") return fmt.Errorf("error decoding binary: %w", err)
} }
wac.dispatch(message) wac.dispatch(message)
} else { //RAW json status updates } else { //RAW json status updates
@@ -104,16 +112,18 @@ func (wac *Conn) decryptBinaryMessage(msg []byte) (*binary.Node, error) {
var response struct { var response struct {
Status int `json:"status"` Status int `json:"status"`
} }
err := json.Unmarshal(msg, &response)
if err == nil { if err := json.Unmarshal(msg, &response); err == nil {
if response.Status == 404 { if response.Status == http.StatusNotFound {
return nil, ErrServerRespondedWith404 return nil, ErrServerRespondedWith404
} }
return nil, errors.New(fmt.Sprintf("server responded with %d", response.Status)) return nil, fmt.Errorf("server responded with %d", response.Status)
} else { } else {
return nil, ErrInvalidServerResponse return nil, ErrInvalidServerResponse
} }
return nil, ErrInvalidServerResponse
} }
h2.Write([]byte(msg[32:])) h2.Write([]byte(msg[32:]))
if !hmac.Equal(h2.Sum(nil), msg[:32]) { if !hmac.Equal(h2.Sum(nil), msg[:32]) {
@@ -123,13 +133,13 @@ func (wac *Conn) decryptBinaryMessage(msg []byte) (*binary.Node, error) {
// message decrypt // message decrypt
d, err := cbc.Decrypt(wac.session.EncKey, nil, msg[32:]) d, err := cbc.Decrypt(wac.session.EncKey, nil, msg[32:])
if err != nil { if err != nil {
return nil, errors.Wrap(err, "decrypting message with AES-CBC failed") return nil, fmt.Errorf("decrypting message with AES-CBC failed: %w", err)
} }
// message unmarshal // message unmarshal
message, err := binary.Unmarshal(d) message, err := binary.Unmarshal(d)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not decode binary") return nil, fmt.Errorf("could not decode binary: %w", err)
} }
return message, nil return message, nil
+87 -44
View File
@@ -18,7 +18,7 @@ import (
) )
//represents the WhatsAppWeb client version //represents the WhatsAppWeb client version
var waVersion = []int{0, 4, 2080} var waVersion = []int{2, 2100, 6}
/* /*
Session contains session individual information. To be able to resume the connection without scanning the qr code Session contains session individual information. To be able to resume the connection without scanning the qr code
@@ -157,6 +157,28 @@ func (wac *Conn) SetClientVersion(major int, minor int, patch int) {
waVersion = []int{major, minor, patch} waVersion = []int{major, minor, patch}
} }
func (wac *Conn) adminInitRequest(clientId string) (string, time.Duration, error) {
login := []interface{}{"admin", "init", waVersion, []string{wac.longClientName, wac.shortClientName, wac.clientVersion}, clientId, true}
loginChan, err := wac.writeJson(login)
if err != nil {
return "", 0, fmt.Errorf("error writing login: %v\n", err)
}
var r string
select {
case r = <-loginChan:
case <-time.After(wac.msgTimeout):
return "", 0, fmt.Errorf("login connection timed out")
}
var resp map[string]interface{}
if err = json.Unmarshal([]byte(r), &resp); err != nil {
return "", 0, fmt.Errorf("error decoding login resp: %v\n", err)
}
return resp["ref"].(string), time.Duration(resp["ttl"].(float64)) * time.Millisecond, nil
}
// GetClientVersion returns WhatsApp client version // GetClientVersion returns WhatsApp client version
func (wac *Conn) GetClientVersion() []int { func (wac *Conn) GetClientVersion() []int {
return waVersion return waVersion
@@ -186,6 +208,10 @@ github.com/Baozisoftware/qrcode-terminal-go Example login procedure:
fmt.Printf("login successful, session: %v\n", session) fmt.Printf("login successful, session: %v\n", session)
*/ */
func (wac *Conn) Login(qrChan chan<- string) (Session, error) { func (wac *Conn) Login(qrChan chan<- string) (Session, error) {
return wac.LoginWithRetry(qrChan, 0)
}
func (wac *Conn) LoginWithRetry(qrChan chan<- string, maxRetries int) (Session, error) {
session := Session{} session := Session{}
//Makes sure that only a single Login or Restore can happen at the same time //Makes sure that only a single Login or Restore can happen at the same time
if !atomic.CompareAndSwapUint32(&wac.sessionLock, 0, 1) { if !atomic.CompareAndSwapUint32(&wac.sessionLock, 0, 1) {
@@ -213,25 +239,6 @@ func (wac *Conn) Login(qrChan chan<- string) (Session, error) {
} }
session.ClientId = base64.StdEncoding.EncodeToString(clientId) session.ClientId = base64.StdEncoding.EncodeToString(clientId)
login := []interface{}{"admin", "init", waVersion, []string{wac.longClientName, wac.shortClientName, wac.clientVersion}, session.ClientId, true}
loginChan, err := wac.writeJson(login)
if err != nil {
return session, fmt.Errorf("error writing login: %v\n", err)
}
var r string
select {
case r = <-loginChan:
case <-time.After(wac.msgTimeout):
return session, fmt.Errorf("login connection timed out")
}
var resp map[string]interface{}
if err = json.Unmarshal([]byte(r), &resp); err != nil {
return session, fmt.Errorf("error decoding login resp: %v\n", err)
}
ref := resp["ref"].(string)
priv, pub, err := curve25519.GenerateKey() priv, pub, err := curve25519.GenerateKey()
if err != nil { if err != nil {
@@ -244,18 +251,35 @@ func (wac *Conn) Login(qrChan chan<- string) (Session, error) {
wac.listener.m["s1"] = s1 wac.listener.m["s1"] = s1
wac.listener.Unlock() wac.listener.Unlock()
ref, ttl, err := wac.adminInitRequest(session.ClientId)
if err != nil {
return session, err
}
qrChan <- fmt.Sprintf("%v,%v,%v", ref, base64.StdEncoding.EncodeToString(pub[:]), session.ClientId) qrChan <- fmt.Sprintf("%v,%v,%v", ref, base64.StdEncoding.EncodeToString(pub[:]), session.ClientId)
var resp2 []interface{}
select {
case r1 := <-s1:
wac.loginSessionLock.Lock() wac.loginSessionLock.Lock()
defer wac.loginSessionLock.Unlock() defer wac.loginSessionLock.Unlock()
var resp2 []interface{}
For:
for {
select {
case r1 := <-s1:
if err := json.Unmarshal([]byte(r1), &resp2); err != nil { if err := json.Unmarshal([]byte(r1), &resp2); err != nil {
return session, fmt.Errorf("error decoding qr code resp: %v", err) return session, fmt.Errorf("error decoding qr code resp: %v", err)
} }
case <-time.After(time.Duration(resp["ttl"].(float64)) * time.Millisecond): break For
return session, fmt.Errorf("qr code scan timed out") case <-time.After(ttl):
maxRetries--
if maxRetries < 0 {
_, _ = wac.Disconnect()
return session, ErrLoginTimedOut
}
ref, ttl, err = wac.adminInitRequest(session.ClientId)
if err != nil {
return session, err
}
qrChan <- fmt.Sprintf("%v,%v,%v", ref, base64.StdEncoding.EncodeToString(pub[:]), session.ClientId)
}
} }
info := resp2[1].(map[string]interface{}) info := resp2[1].(map[string]interface{})
@@ -384,15 +408,15 @@ func (wac *Conn) Restore() error {
select { select {
case r := <-initChan: case r := <-initChan:
var resp map[string]interface{} resp := StatusResponse{RequestType: "init"}
if err = json.Unmarshal([]byte(r), &resp); err != nil { if err = json.Unmarshal([]byte(r), &resp); err != nil {
return fmt.Errorf("error decoding login connResp: %v\n", err) return fmt.Errorf("error decoding login connResp: %v\n", err)
} } else if resp.Status != 200 {
wac.timeTag = ""
if int(resp["status"].(float64)) != 200 { return resp
return fmt.Errorf("init responded with %d", resp["status"])
} }
case <-time.After(wac.msgTimeout): case <-time.After(wac.msgTimeout):
wac.timeTag = ""
return fmt.Errorf("restore session init timed out") return fmt.Errorf("restore session init timed out")
} }
@@ -401,19 +425,19 @@ func (wac *Conn) Restore() error {
select { select {
case r1 := <-s1: case r1 := <-s1:
if err := json.Unmarshal([]byte(r1), &connResp); err != nil { if err := json.Unmarshal([]byte(r1), &connResp); err != nil {
wac.timeTag = ""
return fmt.Errorf("error decoding s1 message: %v\n", err) return fmt.Errorf("error decoding s1 message: %v\n", err)
} }
case <-time.After(wac.msgTimeout): case <-time.After(wac.msgTimeout):
wac.timeTag = ""
//check for an error message //check for an error message
select { select {
case r := <-loginChan: case r := <-loginChan:
var resp map[string]interface{} resp := StatusResponse{RequestType: "admin login"}
if err = json.Unmarshal([]byte(r), &resp); err != nil { if err = json.Unmarshal([]byte(r), &resp); err != nil {
return fmt.Errorf("error decoding login connResp: %v\n", err) return fmt.Errorf("error decoding login connResp: %v\n", err)
} } else if resp.Status != 200 {
if int(resp["status"].(float64)) != 200 { return fmt.Errorf("admin login errored: %w", wac.getAdminLoginResponseError(resp))
return fmt.Errorf("admin login responded with %d", int(resp["status"].(float64)))
} }
default: default:
// not even an error message assume timeout // not even an error message assume timeout
@@ -429,15 +453,18 @@ func (wac *Conn) Restore() error {
wac.listener.Unlock() wac.listener.Unlock()
if err := wac.resolveChallenge(connResp[1].(map[string]interface{})["challenge"].(string)); err != nil { if err := wac.resolveChallenge(connResp[1].(map[string]interface{})["challenge"].(string)); err != nil {
wac.timeTag = ""
return fmt.Errorf("error resolving challenge: %v\n", err) return fmt.Errorf("error resolving challenge: %v\n", err)
} }
select { select {
case r := <-s2: case r := <-s2:
if err := json.Unmarshal([]byte(r), &connResp); err != nil { if err := json.Unmarshal([]byte(r), &connResp); err != nil {
wac.timeTag = ""
return fmt.Errorf("error decoding s2 message: %v\n", err) return fmt.Errorf("error decoding s2 message: %v\n", err)
} }
case <-time.After(wac.msgTimeout): case <-time.After(wac.msgTimeout):
wac.timeTag = ""
return fmt.Errorf("restore session challenge timed out") return fmt.Errorf("restore session challenge timed out")
} }
} }
@@ -445,15 +472,16 @@ func (wac *Conn) Restore() error {
//check for login 200 --> login success //check for login 200 --> login success
select { select {
case r := <-loginChan: case r := <-loginChan:
var resp map[string]interface{} resp := StatusResponse{RequestType: "admin login"}
if err = json.Unmarshal([]byte(r), &resp); err != nil { if err = json.Unmarshal([]byte(r), &resp); err != nil {
wac.timeTag = ""
return fmt.Errorf("error decoding login connResp: %v\n", err) return fmt.Errorf("error decoding login connResp: %v\n", err)
} } else if resp.Status != 200 {
wac.timeTag = ""
if int(resp["status"].(float64)) != 200 { return fmt.Errorf("admin login errored: %w", wac.getAdminLoginResponseError(resp))
return fmt.Errorf("admin login responded with %d", resp["status"])
} }
case <-time.After(wac.msgTimeout): case <-time.After(wac.msgTimeout):
wac.timeTag = ""
return fmt.Errorf("restore session login timed out") return fmt.Errorf("restore session login timed out")
} }
@@ -470,6 +498,22 @@ func (wac *Conn) Restore() error {
return nil return nil
} }
func (wac *Conn) getAdminLoginResponseError(resp StatusResponse) error {
switch resp.Status {
case 400:
return ErrBadRequest
case 401:
return ErrUnpaired
case 403:
return fmt.Errorf("%w - tos: %d", ErrAccessDenied, resp.TermsOfService)
case 405:
return ErrLoggedIn
case 409:
return ErrReplaced
}
return fmt.Errorf("%d (unknown error)", status)
}
func (wac *Conn) resolveChallenge(challenge string) error { func (wac *Conn) resolveChallenge(challenge string) error {
decoded, err := base64.StdEncoding.DecodeString(challenge) decoded, err := base64.StdEncoding.DecodeString(challenge)
if err != nil { if err != nil {
@@ -487,12 +531,11 @@ func (wac *Conn) resolveChallenge(challenge string) error {
select { select {
case r := <-challengeChan: case r := <-challengeChan:
var resp map[string]interface{} resp := StatusResponse{RequestType: "login challenge"}
if err := json.Unmarshal([]byte(r), &resp); err != nil { if err := json.Unmarshal([]byte(r), &resp); err != nil {
return fmt.Errorf("error decoding login resp: %v\n", err) return fmt.Errorf("error decoding login resp: %v\n", err)
} } else if resp.Status != 200 {
if int(resp["status"].(float64)) != 200 { return resp
return fmt.Errorf("challenge responded with %d\n", resp["status"])
} }
case <-time.After(wac.msgTimeout): case <-time.After(wac.msgTimeout):
return fmt.Errorf("connection timed out") return fmt.Errorf("connection timed out")
+25 -17
View File
@@ -6,13 +6,12 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"strconv" "strconv"
"time" "time"
"github.com/gorilla/websocket"
"github.com/Rhymen/go-whatsapp/binary" "github.com/Rhymen/go-whatsapp/binary"
"github.com/Rhymen/go-whatsapp/crypto/cbc" "github.com/Rhymen/go-whatsapp/crypto/cbc"
"github.com/gorilla/websocket"
"github.com/pkg/errors"
) )
//writeJson enqueues a json message into the writeChan //writeJson enqueues a json message into the writeChan
@@ -30,6 +29,11 @@ func (wac *Conn) writeJson(data []interface{}) (<-chan string, error) {
messageTag := fmt.Sprintf("%d.--%d", ts, wac.msgCount) messageTag := fmt.Sprintf("%d.--%d", ts, wac.msgCount)
bytes := []byte(fmt.Sprintf("%s,%s", messageTag, d)) bytes := []byte(fmt.Sprintf("%s,%s", messageTag, d))
if wac.timeTag == "" {
tss := fmt.Sprintf("%d", ts)
wac.timeTag = tss[len(tss)-3:]
}
ch, err := wac.write(websocket.TextMessage, messageTag, bytes) ch, err := wac.write(websocket.TextMessage, messageTag, bytes)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -49,7 +53,7 @@ func (wac *Conn) writeBinary(node binary.Node, metric metric, flag flag, message
data, err := wac.encryptBinaryMessage(node) data, err := wac.encryptBinaryMessage(node)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "encryptBinaryMessage(node) failed") return nil, fmt.Errorf("encryptBinaryMessage(node) failed: %w", err)
} }
bytes := []byte(messageTag + ",") bytes := []byte(messageTag + ",")
@@ -58,7 +62,7 @@ func (wac *Conn) writeBinary(node binary.Node, metric metric, flag flag, message
ch, err := wac.write(websocket.BinaryMessage, messageTag, bytes) ch, err := wac.write(websocket.BinaryMessage, messageTag, bytes)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to write message") return nil, fmt.Errorf("failed to write message: %w", err)
} }
wac.msgCount++ wac.msgCount++
@@ -69,14 +73,14 @@ func (wac *Conn) sendKeepAlive() error {
bytes := []byte("?,,") bytes := []byte("?,,")
respChan, err := wac.write(websocket.TextMessage, "!", bytes) respChan, err := wac.write(websocket.TextMessage, "!", bytes)
if err != nil { if err != nil {
return errors.Wrap(err, "error sending keepAlive") return fmt.Errorf("error sending keepAlive: %w", err)
} }
select { select {
case resp := <-respChan: case resp := <-respChan:
msecs, err := strconv.ParseInt(resp, 10, 64) msecs, err := strconv.ParseInt(resp, 10, 64)
if err != nil { if err != nil {
return errors.Wrap(err, "Error converting time string to uint") return fmt.Errorf("Error converting time string to uint: %w", err)
} }
wac.ServerLastSeen = time.Unix(msecs/1000, (msecs%1000)*int64(time.Millisecond)) wac.ServerLastSeen = time.Unix(msecs/1000, (msecs%1000)*int64(time.Millisecond))
@@ -91,29 +95,30 @@ func (wac *Conn) sendKeepAlive() error {
When phone is unreachable, WhatsAppWeb sends ["admin","test"] time after time to try a successful contact. When phone is unreachable, WhatsAppWeb sends ["admin","test"] time after time to try a successful contact.
Tested with Airplane mode and no connection at all. Tested with Airplane mode and no connection at all.
*/ */
func (wac *Conn) sendAdminTest() (bool, error) { func (wac *Conn) sendAdminTest() error {
data := []interface{}{"admin", "test"} data := []interface{}{"admin", "test"}
r, err := wac.writeJson(data) r, err := wac.writeJson(data)
if err != nil { if err != nil {
return false, errors.Wrap(err, "error sending admin test") return fmt.Errorf("error sending admin test: %w", err)
} }
var response []interface{} var response []interface{}
var resp string
select { select {
case resp := <-r: case resp = <-r:
if err := json.Unmarshal([]byte(resp), &response); err != nil { if err := json.Unmarshal([]byte(resp), &response); err != nil {
return false, fmt.Errorf("error decoding response message: %v\n", err) return fmt.Errorf("error decoding response message: %v\n", err)
} }
case <-time.After(wac.msgTimeout): case <-time.After(wac.msgTimeout):
return false, ErrConnectionTimeout return ErrConnectionTimeout
} }
if len(response) == 2 && response[0].(string) == "Pong" && response[1].(bool) == true { if len(response) == 2 && response[0].(string) == "Pong" && response[1].(bool) == true {
return true, nil return nil
} else { } else {
return false, nil return fmt.Errorf("unexpected ping response: %s", resp)
} }
} }
@@ -127,6 +132,9 @@ func (wac *Conn) write(messageType int, answerMessageTag string, data []byte) (<
wac.listener.Unlock() wac.listener.Unlock()
} }
if wac == nil || wac.ws == nil {
return nil, ErrInvalidWebsocket
}
wac.ws.Lock() wac.ws.Lock()
err := wac.ws.conn.WriteMessage(messageType, data) err := wac.ws.conn.WriteMessage(messageType, data)
wac.ws.Unlock() wac.ws.Unlock()
@@ -137,7 +145,7 @@ func (wac *Conn) write(messageType int, answerMessageTag string, data []byte) (<
delete(wac.listener.m, answerMessageTag) delete(wac.listener.m, answerMessageTag)
wac.listener.Unlock() wac.listener.Unlock()
} }
return nil, errors.Wrap(err, "error writing to websocket") return nil, fmt.Errorf("error writing to websocket: %w", err)
} }
return ch, nil return ch, nil
} }
@@ -145,12 +153,12 @@ func (wac *Conn) write(messageType int, answerMessageTag string, data []byte) (<
func (wac *Conn) encryptBinaryMessage(node binary.Node) (data []byte, err error) { func (wac *Conn) encryptBinaryMessage(node binary.Node) (data []byte, err error) {
b, err := binary.Marshal(node) b, err := binary.Marshal(node)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "binary node marshal failed") return nil, fmt.Errorf("binary node marshal failed: %w", err)
} }
cipher, err := cbc.Encrypt(wac.session.EncKey, nil, b) cipher, err := cbc.Encrypt(wac.session.EncKey, nil, b)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "encrypt failed") return nil, fmt.Errorf("encrypt failed: %w", err)
} }
h := hmac.New(sha256.New, wac.session.MacKey) h := hmac.New(sha256.New, wac.session.MacKey)
+21
View File
@@ -0,0 +1,21 @@
language: go
matrix:
include:
- go: 1.4.3
- go: 1.5.4
- go: 1.6.3
- go: 1.7
- go: tip
allow_failures:
- go: tip
install:
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
script:
- echo "Test and track coverage" ; $HOME/gopath/bin/goveralls -package "." -service=travis-ci
-repotoken $COVERALLS_TOKEN
- echo "Build examples" ; cd examples && go build
- echo "Check if gofmt'd" ; diff -u <(echo -n) <(gofmt -d -s .)
env:
global:
secure: HroGEAUQpVq9zX1b1VIkraLiywhGbzvNnTZq2TMxgK7JHP8xqNplAeF1izrR2i4QLL9nsY+9WtYss4QuPvEtZcVHUobw6XnL6radF7jS1LgfYZ9Y7oF+zogZ2I5QUMRLGA7rcxQ05s7mKq3XZQfeqaNts4bms/eZRefWuaFZbkw=
+22
View File
@@ -0,0 +1,22 @@
The MIT License
Copyright (c) 2014 Benedikt Lang <github at benediktlang.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+194
View File
@@ -0,0 +1,194 @@
semver for golang [![Build Status](https://travis-ci.org/blang/semver.svg?branch=master)](https://travis-ci.org/blang/semver) [![GoDoc](https://godoc.org/github.com/blang/semver?status.png)](https://godoc.org/github.com/blang/semver) [![Coverage Status](https://img.shields.io/coveralls/blang/semver.svg)](https://coveralls.io/r/blang/semver?branch=master)
======
semver is a [Semantic Versioning](http://semver.org/) library written in golang. It fully covers spec version `2.0.0`.
Usage
-----
```bash
$ go get github.com/blang/semver
```
Note: Always vendor your dependencies or fix on a specific version tag.
```go
import github.com/blang/semver
v1, err := semver.Make("1.0.0-beta")
v2, err := semver.Make("2.0.0-beta")
v1.Compare(v2)
```
Also check the [GoDocs](http://godoc.org/github.com/blang/semver).
Why should I use this lib?
-----
- Fully spec compatible
- No reflection
- No regex
- Fully tested (Coverage >99%)
- Readable parsing/validation errors
- Fast (See [Benchmarks](#benchmarks))
- Only Stdlib
- Uses values instead of pointers
- Many features, see below
Features
-----
- Parsing and validation at all levels
- Comparator-like comparisons
- Compare Helper Methods
- InPlace manipulation
- Ranges `>=1.0.0 <2.0.0 || >=3.0.0 !3.0.1-beta.1`
- Wildcards `>=1.x`, `<=2.5.x`
- Sortable (implements sort.Interface)
- database/sql compatible (sql.Scanner/Valuer)
- encoding/json compatible (json.Marshaler/Unmarshaler)
Ranges
------
A `Range` is a set of conditions which specify which versions satisfy the range.
A condition is composed of an operator and a version. The supported operators are:
- `<1.0.0` Less than `1.0.0`
- `<=1.0.0` Less than or equal to `1.0.0`
- `>1.0.0` Greater than `1.0.0`
- `>=1.0.0` Greater than or equal to `1.0.0`
- `1.0.0`, `=1.0.0`, `==1.0.0` Equal to `1.0.0`
- `!1.0.0`, `!=1.0.0` Not equal to `1.0.0`. Excludes version `1.0.0`.
Note that spaces between the operator and the version will be gracefully tolerated.
A `Range` can link multiple `Ranges` separated by space:
Ranges can be linked by logical AND:
- `>1.0.0 <2.0.0` would match between both ranges, so `1.1.1` and `1.8.7` but not `1.0.0` or `2.0.0`
- `>1.0.0 <3.0.0 !2.0.3-beta.2` would match every version between `1.0.0` and `3.0.0` except `2.0.3-beta.2`
Ranges can also be linked by logical OR:
- `<2.0.0 || >=3.0.0` would match `1.x.x` and `3.x.x` but not `2.x.x`
AND has a higher precedence than OR. It's not possible to use brackets.
Ranges can be combined by both AND and OR
- `>1.0.0 <2.0.0 || >3.0.0 !4.2.1` would match `1.2.3`, `1.9.9`, `3.1.1`, but not `4.2.1`, `2.1.1`
Range usage:
```
v, err := semver.Parse("1.2.3")
range, err := semver.ParseRange(">1.0.0 <2.0.0 || >=3.0.0")
if range(v) {
//valid
}
```
Example
-----
Have a look at full examples in [examples/main.go](examples/main.go)
```go
import github.com/blang/semver
v, err := semver.Make("0.0.1-alpha.preview+123.github")
fmt.Printf("Major: %d\n", v.Major)
fmt.Printf("Minor: %d\n", v.Minor)
fmt.Printf("Patch: %d\n", v.Patch)
fmt.Printf("Pre: %s\n", v.Pre)
fmt.Printf("Build: %s\n", v.Build)
// Prerelease versions array
if len(v.Pre) > 0 {
fmt.Println("Prerelease versions:")
for i, pre := range v.Pre {
fmt.Printf("%d: %q\n", i, pre)
}
}
// Build meta data array
if len(v.Build) > 0 {
fmt.Println("Build meta data:")
for i, build := range v.Build {
fmt.Printf("%d: %q\n", i, build)
}
}
v001, err := semver.Make("0.0.1")
// Compare using helpers: v.GT(v2), v.LT, v.GTE, v.LTE
v001.GT(v) == true
v.LT(v001) == true
v.GTE(v) == true
v.LTE(v) == true
// Or use v.Compare(v2) for comparisons (-1, 0, 1):
v001.Compare(v) == 1
v.Compare(v001) == -1
v.Compare(v) == 0
// Manipulate Version in place:
v.Pre[0], err = semver.NewPRVersion("beta")
if err != nil {
fmt.Printf("Error parsing pre release version: %q", err)
}
fmt.Println("\nValidate versions:")
v.Build[0] = "?"
err = v.Validate()
if err != nil {
fmt.Printf("Validation failed: %s\n", err)
}
```
Benchmarks
-----
BenchmarkParseSimple-4 5000000 390 ns/op 48 B/op 1 allocs/op
BenchmarkParseComplex-4 1000000 1813 ns/op 256 B/op 7 allocs/op
BenchmarkParseAverage-4 1000000 1171 ns/op 163 B/op 4 allocs/op
BenchmarkStringSimple-4 20000000 119 ns/op 16 B/op 1 allocs/op
BenchmarkStringLarger-4 10000000 206 ns/op 32 B/op 2 allocs/op
BenchmarkStringComplex-4 5000000 324 ns/op 80 B/op 3 allocs/op
BenchmarkStringAverage-4 5000000 273 ns/op 53 B/op 2 allocs/op
BenchmarkValidateSimple-4 200000000 9.33 ns/op 0 B/op 0 allocs/op
BenchmarkValidateComplex-4 3000000 469 ns/op 0 B/op 0 allocs/op
BenchmarkValidateAverage-4 5000000 256 ns/op 0 B/op 0 allocs/op
BenchmarkCompareSimple-4 100000000 11.8 ns/op 0 B/op 0 allocs/op
BenchmarkCompareComplex-4 50000000 30.8 ns/op 0 B/op 0 allocs/op
BenchmarkCompareAverage-4 30000000 41.5 ns/op 0 B/op 0 allocs/op
BenchmarkSort-4 3000000 419 ns/op 256 B/op 2 allocs/op
BenchmarkRangeParseSimple-4 2000000 850 ns/op 192 B/op 5 allocs/op
BenchmarkRangeParseAverage-4 1000000 1677 ns/op 400 B/op 10 allocs/op
BenchmarkRangeParseComplex-4 300000 5214 ns/op 1440 B/op 30 allocs/op
BenchmarkRangeMatchSimple-4 50000000 25.6 ns/op 0 B/op 0 allocs/op
BenchmarkRangeMatchAverage-4 30000000 56.4 ns/op 0 B/op 0 allocs/op
BenchmarkRangeMatchComplex-4 10000000 153 ns/op 0 B/op 0 allocs/op
See benchmark cases at [semver_test.go](semver_test.go)
Motivation
-----
I simply couldn't find any lib supporting the full spec. Others were just wrong or used reflection and regex which i don't like.
Contribution
-----
Feel free to make a pull request. For bigger changes create a issue first to discuss about it.
License
-----
See [LICENSE](LICENSE) file.
+23
View File
@@ -0,0 +1,23 @@
package semver
import (
"encoding/json"
)
// MarshalJSON implements the encoding/json.Marshaler interface.
func (v Version) MarshalJSON() ([]byte, error) {
return json.Marshal(v.String())
}
// UnmarshalJSON implements the encoding/json.Unmarshaler interface.
func (v *Version) UnmarshalJSON(data []byte) (err error) {
var versionString string
if err = json.Unmarshal(data, &versionString); err != nil {
return
}
*v, err = Parse(versionString)
return
}
+17
View File
@@ -0,0 +1,17 @@
{
"author": "blang",
"bugs": {
"URL": "https://github.com/blang/semver/issues",
"url": "https://github.com/blang/semver/issues"
},
"gx": {
"dvcsimport": "github.com/blang/semver"
},
"gxVersion": "0.10.0",
"language": "go",
"license": "MIT",
"name": "semver",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "3.5.1"
}
+416
View File
@@ -0,0 +1,416 @@
package semver
import (
"fmt"
"strconv"
"strings"
"unicode"
)
type wildcardType int
const (
noneWildcard wildcardType = iota
majorWildcard wildcardType = 1
minorWildcard wildcardType = 2
patchWildcard wildcardType = 3
)
func wildcardTypefromInt(i int) wildcardType {
switch i {
case 1:
return majorWildcard
case 2:
return minorWildcard
case 3:
return patchWildcard
default:
return noneWildcard
}
}
type comparator func(Version, Version) bool
var (
compEQ comparator = func(v1 Version, v2 Version) bool {
return v1.Compare(v2) == 0
}
compNE = func(v1 Version, v2 Version) bool {
return v1.Compare(v2) != 0
}
compGT = func(v1 Version, v2 Version) bool {
return v1.Compare(v2) == 1
}
compGE = func(v1 Version, v2 Version) bool {
return v1.Compare(v2) >= 0
}
compLT = func(v1 Version, v2 Version) bool {
return v1.Compare(v2) == -1
}
compLE = func(v1 Version, v2 Version) bool {
return v1.Compare(v2) <= 0
}
)
type versionRange struct {
v Version
c comparator
}
// rangeFunc creates a Range from the given versionRange.
func (vr *versionRange) rangeFunc() Range {
return Range(func(v Version) bool {
return vr.c(v, vr.v)
})
}
// Range represents a range of versions.
// A Range can be used to check if a Version satisfies it:
//
// range, err := semver.ParseRange(">1.0.0 <2.0.0")
// range(semver.MustParse("1.1.1") // returns true
type Range func(Version) bool
// OR combines the existing Range with another Range using logical OR.
func (rf Range) OR(f Range) Range {
return Range(func(v Version) bool {
return rf(v) || f(v)
})
}
// AND combines the existing Range with another Range using logical AND.
func (rf Range) AND(f Range) Range {
return Range(func(v Version) bool {
return rf(v) && f(v)
})
}
// ParseRange parses a range and returns a Range.
// If the range could not be parsed an error is returned.
//
// Valid ranges are:
// - "<1.0.0"
// - "<=1.0.0"
// - ">1.0.0"
// - ">=1.0.0"
// - "1.0.0", "=1.0.0", "==1.0.0"
// - "!1.0.0", "!=1.0.0"
//
// A Range can consist of multiple ranges separated by space:
// Ranges can be linked by logical AND:
// - ">1.0.0 <2.0.0" would match between both ranges, so "1.1.1" and "1.8.7" but not "1.0.0" or "2.0.0"
// - ">1.0.0 <3.0.0 !2.0.3-beta.2" would match every version between 1.0.0 and 3.0.0 except 2.0.3-beta.2
//
// Ranges can also be linked by logical OR:
// - "<2.0.0 || >=3.0.0" would match "1.x.x" and "3.x.x" but not "2.x.x"
//
// AND has a higher precedence than OR. It's not possible to use brackets.
//
// Ranges can be combined by both AND and OR
//
// - `>1.0.0 <2.0.0 || >3.0.0 !4.2.1` would match `1.2.3`, `1.9.9`, `3.1.1`, but not `4.2.1`, `2.1.1`
func ParseRange(s string) (Range, error) {
parts := splitAndTrim(s)
orParts, err := splitORParts(parts)
if err != nil {
return nil, err
}
expandedParts, err := expandWildcardVersion(orParts)
if err != nil {
return nil, err
}
var orFn Range
for _, p := range expandedParts {
var andFn Range
for _, ap := range p {
opStr, vStr, err := splitComparatorVersion(ap)
if err != nil {
return nil, err
}
vr, err := buildVersionRange(opStr, vStr)
if err != nil {
return nil, fmt.Errorf("Could not parse Range %q: %s", ap, err)
}
rf := vr.rangeFunc()
// Set function
if andFn == nil {
andFn = rf
} else { // Combine with existing function
andFn = andFn.AND(rf)
}
}
if orFn == nil {
orFn = andFn
} else {
orFn = orFn.OR(andFn)
}
}
return orFn, nil
}
// splitORParts splits the already cleaned parts by '||'.
// Checks for invalid positions of the operator and returns an
// error if found.
func splitORParts(parts []string) ([][]string, error) {
var ORparts [][]string
last := 0
for i, p := range parts {
if p == "||" {
if i == 0 {
return nil, fmt.Errorf("First element in range is '||'")
}
ORparts = append(ORparts, parts[last:i])
last = i + 1
}
}
if last == len(parts) {
return nil, fmt.Errorf("Last element in range is '||'")
}
ORparts = append(ORparts, parts[last:])
return ORparts, nil
}
// buildVersionRange takes a slice of 2: operator and version
// and builds a versionRange, otherwise an error.
func buildVersionRange(opStr, vStr string) (*versionRange, error) {
c := parseComparator(opStr)
if c == nil {
return nil, fmt.Errorf("Could not parse comparator %q in %q", opStr, strings.Join([]string{opStr, vStr}, ""))
}
v, err := Parse(vStr)
if err != nil {
return nil, fmt.Errorf("Could not parse version %q in %q: %s", vStr, strings.Join([]string{opStr, vStr}, ""), err)
}
return &versionRange{
v: v,
c: c,
}, nil
}
// inArray checks if a byte is contained in an array of bytes
func inArray(s byte, list []byte) bool {
for _, el := range list {
if el == s {
return true
}
}
return false
}
// splitAndTrim splits a range string by spaces and cleans whitespaces
func splitAndTrim(s string) (result []string) {
last := 0
var lastChar byte
excludeFromSplit := []byte{'>', '<', '='}
for i := 0; i < len(s); i++ {
if s[i] == ' ' && !inArray(lastChar, excludeFromSplit) {
if last < i-1 {
result = append(result, s[last:i])
}
last = i + 1
} else if s[i] != ' ' {
lastChar = s[i]
}
}
if last < len(s)-1 {
result = append(result, s[last:])
}
for i, v := range result {
result[i] = strings.Replace(v, " ", "", -1)
}
// parts := strings.Split(s, " ")
// for _, x := range parts {
// if s := strings.TrimSpace(x); len(s) != 0 {
// result = append(result, s)
// }
// }
return
}
// splitComparatorVersion splits the comparator from the version.
// Input must be free of leading or trailing spaces.
func splitComparatorVersion(s string) (string, string, error) {
i := strings.IndexFunc(s, unicode.IsDigit)
if i == -1 {
return "", "", fmt.Errorf("Could not get version from string: %q", s)
}
return strings.TrimSpace(s[0:i]), s[i:], nil
}
// getWildcardType will return the type of wildcard that the
// passed version contains
func getWildcardType(vStr string) wildcardType {
parts := strings.Split(vStr, ".")
nparts := len(parts)
wildcard := parts[nparts-1]
possibleWildcardType := wildcardTypefromInt(nparts)
if wildcard == "x" {
return possibleWildcardType
}
return noneWildcard
}
// createVersionFromWildcard will convert a wildcard version
// into a regular version, replacing 'x's with '0's, handling
// special cases like '1.x.x' and '1.x'
func createVersionFromWildcard(vStr string) string {
// handle 1.x.x
vStr2 := strings.Replace(vStr, ".x.x", ".x", 1)
vStr2 = strings.Replace(vStr2, ".x", ".0", 1)
parts := strings.Split(vStr2, ".")
// handle 1.x
if len(parts) == 2 {
return vStr2 + ".0"
}
return vStr2
}
// incrementMajorVersion will increment the major version
// of the passed version
func incrementMajorVersion(vStr string) (string, error) {
parts := strings.Split(vStr, ".")
i, err := strconv.Atoi(parts[0])
if err != nil {
return "", err
}
parts[0] = strconv.Itoa(i + 1)
return strings.Join(parts, "."), nil
}
// incrementMajorVersion will increment the minor version
// of the passed version
func incrementMinorVersion(vStr string) (string, error) {
parts := strings.Split(vStr, ".")
i, err := strconv.Atoi(parts[1])
if err != nil {
return "", err
}
parts[1] = strconv.Itoa(i + 1)
return strings.Join(parts, "."), nil
}
// expandWildcardVersion will expand wildcards inside versions
// following these rules:
//
// * when dealing with patch wildcards:
// >= 1.2.x will become >= 1.2.0
// <= 1.2.x will become < 1.3.0
// > 1.2.x will become >= 1.3.0
// < 1.2.x will become < 1.2.0
// != 1.2.x will become < 1.2.0 >= 1.3.0
//
// * when dealing with minor wildcards:
// >= 1.x will become >= 1.0.0
// <= 1.x will become < 2.0.0
// > 1.x will become >= 2.0.0
// < 1.0 will become < 1.0.0
// != 1.x will become < 1.0.0 >= 2.0.0
//
// * when dealing with wildcards without
// version operator:
// 1.2.x will become >= 1.2.0 < 1.3.0
// 1.x will become >= 1.0.0 < 2.0.0
func expandWildcardVersion(parts [][]string) ([][]string, error) {
var expandedParts [][]string
for _, p := range parts {
var newParts []string
for _, ap := range p {
if strings.Index(ap, "x") != -1 {
opStr, vStr, err := splitComparatorVersion(ap)
if err != nil {
return nil, err
}
versionWildcardType := getWildcardType(vStr)
flatVersion := createVersionFromWildcard(vStr)
var resultOperator string
var shouldIncrementVersion bool
switch opStr {
case ">":
resultOperator = ">="
shouldIncrementVersion = true
case ">=":
resultOperator = ">="
case "<":
resultOperator = "<"
case "<=":
resultOperator = "<"
shouldIncrementVersion = true
case "", "=", "==":
newParts = append(newParts, ">="+flatVersion)
resultOperator = "<"
shouldIncrementVersion = true
case "!=", "!":
newParts = append(newParts, "<"+flatVersion)
resultOperator = ">="
shouldIncrementVersion = true
}
var resultVersion string
if shouldIncrementVersion {
switch versionWildcardType {
case patchWildcard:
resultVersion, _ = incrementMinorVersion(flatVersion)
case minorWildcard:
resultVersion, _ = incrementMajorVersion(flatVersion)
}
} else {
resultVersion = flatVersion
}
ap = resultOperator + resultVersion
}
newParts = append(newParts, ap)
}
expandedParts = append(expandedParts, newParts)
}
return expandedParts, nil
}
func parseComparator(s string) comparator {
switch s {
case "==":
fallthrough
case "":
fallthrough
case "=":
return compEQ
case ">":
return compGT
case ">=":
return compGE
case "<":
return compLT
case "<=":
return compLE
case "!":
fallthrough
case "!=":
return compNE
}
return nil
}
// MustParseRange is like ParseRange but panics if the range cannot be parsed.
func MustParseRange(s string) Range {
r, err := ParseRange(s)
if err != nil {
panic(`semver: ParseRange(` + s + `): ` + err.Error())
}
return r
}
+418
View File
@@ -0,0 +1,418 @@
package semver
import (
"errors"
"fmt"
"strconv"
"strings"
)
const (
numbers string = "0123456789"
alphas = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-"
alphanum = alphas + numbers
)
// SpecVersion is the latest fully supported spec version of semver
var SpecVersion = Version{
Major: 2,
Minor: 0,
Patch: 0,
}
// Version represents a semver compatible version
type Version struct {
Major uint64
Minor uint64
Patch uint64
Pre []PRVersion
Build []string //No Precendence
}
// Version to string
func (v Version) String() string {
b := make([]byte, 0, 5)
b = strconv.AppendUint(b, v.Major, 10)
b = append(b, '.')
b = strconv.AppendUint(b, v.Minor, 10)
b = append(b, '.')
b = strconv.AppendUint(b, v.Patch, 10)
if len(v.Pre) > 0 {
b = append(b, '-')
b = append(b, v.Pre[0].String()...)
for _, pre := range v.Pre[1:] {
b = append(b, '.')
b = append(b, pre.String()...)
}
}
if len(v.Build) > 0 {
b = append(b, '+')
b = append(b, v.Build[0]...)
for _, build := range v.Build[1:] {
b = append(b, '.')
b = append(b, build...)
}
}
return string(b)
}
// Equals checks if v is equal to o.
func (v Version) Equals(o Version) bool {
return (v.Compare(o) == 0)
}
// EQ checks if v is equal to o.
func (v Version) EQ(o Version) bool {
return (v.Compare(o) == 0)
}
// NE checks if v is not equal to o.
func (v Version) NE(o Version) bool {
return (v.Compare(o) != 0)
}
// GT checks if v is greater than o.
func (v Version) GT(o Version) bool {
return (v.Compare(o) == 1)
}
// GTE checks if v is greater than or equal to o.
func (v Version) GTE(o Version) bool {
return (v.Compare(o) >= 0)
}
// GE checks if v is greater than or equal to o.
func (v Version) GE(o Version) bool {
return (v.Compare(o) >= 0)
}
// LT checks if v is less than o.
func (v Version) LT(o Version) bool {
return (v.Compare(o) == -1)
}
// LTE checks if v is less than or equal to o.
func (v Version) LTE(o Version) bool {
return (v.Compare(o) <= 0)
}
// LE checks if v is less than or equal to o.
func (v Version) LE(o Version) bool {
return (v.Compare(o) <= 0)
}
// Compare compares Versions v to o:
// -1 == v is less than o
// 0 == v is equal to o
// 1 == v is greater than o
func (v Version) Compare(o Version) int {
if v.Major != o.Major {
if v.Major > o.Major {
return 1
}
return -1
}
if v.Minor != o.Minor {
if v.Minor > o.Minor {
return 1
}
return -1
}
if v.Patch != o.Patch {
if v.Patch > o.Patch {
return 1
}
return -1
}
// Quick comparison if a version has no prerelease versions
if len(v.Pre) == 0 && len(o.Pre) == 0 {
return 0
} else if len(v.Pre) == 0 && len(o.Pre) > 0 {
return 1
} else if len(v.Pre) > 0 && len(o.Pre) == 0 {
return -1
}
i := 0
for ; i < len(v.Pre) && i < len(o.Pre); i++ {
if comp := v.Pre[i].Compare(o.Pre[i]); comp == 0 {
continue
} else if comp == 1 {
return 1
} else {
return -1
}
}
// If all pr versions are the equal but one has further prversion, this one greater
if i == len(v.Pre) && i == len(o.Pre) {
return 0
} else if i == len(v.Pre) && i < len(o.Pre) {
return -1
} else {
return 1
}
}
// Validate validates v and returns error in case
func (v Version) Validate() error {
// Major, Minor, Patch already validated using uint64
for _, pre := range v.Pre {
if !pre.IsNum { //Numeric prerelease versions already uint64
if len(pre.VersionStr) == 0 {
return fmt.Errorf("Prerelease can not be empty %q", pre.VersionStr)
}
if !containsOnly(pre.VersionStr, alphanum) {
return fmt.Errorf("Invalid character(s) found in prerelease %q", pre.VersionStr)
}
}
}
for _, build := range v.Build {
if len(build) == 0 {
return fmt.Errorf("Build meta data can not be empty %q", build)
}
if !containsOnly(build, alphanum) {
return fmt.Errorf("Invalid character(s) found in build meta data %q", build)
}
}
return nil
}
// New is an alias for Parse and returns a pointer, parses version string and returns a validated Version or error
func New(s string) (vp *Version, err error) {
v, err := Parse(s)
vp = &v
return
}
// Make is an alias for Parse, parses version string and returns a validated Version or error
func Make(s string) (Version, error) {
return Parse(s)
}
// ParseTolerant allows for certain version specifications that do not strictly adhere to semver
// specs to be parsed by this library. It does so by normalizing versions before passing them to
// Parse(). It currently trims spaces, removes a "v" prefix, and adds a 0 patch number to versions
// with only major and minor components specified
func ParseTolerant(s string) (Version, error) {
s = strings.TrimSpace(s)
s = strings.TrimPrefix(s, "v")
// Split into major.minor.(patch+pr+meta)
parts := strings.SplitN(s, ".", 3)
if len(parts) < 3 {
if strings.ContainsAny(parts[len(parts)-1], "+-") {
return Version{}, errors.New("Short version cannot contain PreRelease/Build meta data")
}
for len(parts) < 3 {
parts = append(parts, "0")
}
s = strings.Join(parts, ".")
}
return Parse(s)
}
// Parse parses version string and returns a validated Version or error
func Parse(s string) (Version, error) {
if len(s) == 0 {
return Version{}, errors.New("Version string empty")
}
// Split into major.minor.(patch+pr+meta)
parts := strings.SplitN(s, ".", 3)
if len(parts) != 3 {
return Version{}, errors.New("No Major.Minor.Patch elements found")
}
// Major
if !containsOnly(parts[0], numbers) {
return Version{}, fmt.Errorf("Invalid character(s) found in major number %q", parts[0])
}
if hasLeadingZeroes(parts[0]) {
return Version{}, fmt.Errorf("Major number must not contain leading zeroes %q", parts[0])
}
major, err := strconv.ParseUint(parts[0], 10, 64)
if err != nil {
return Version{}, err
}
// Minor
if !containsOnly(parts[1], numbers) {
return Version{}, fmt.Errorf("Invalid character(s) found in minor number %q", parts[1])
}
if hasLeadingZeroes(parts[1]) {
return Version{}, fmt.Errorf("Minor number must not contain leading zeroes %q", parts[1])
}
minor, err := strconv.ParseUint(parts[1], 10, 64)
if err != nil {
return Version{}, err
}
v := Version{}
v.Major = major
v.Minor = minor
var build, prerelease []string
patchStr := parts[2]
if buildIndex := strings.IndexRune(patchStr, '+'); buildIndex != -1 {
build = strings.Split(patchStr[buildIndex+1:], ".")
patchStr = patchStr[:buildIndex]
}
if preIndex := strings.IndexRune(patchStr, '-'); preIndex != -1 {
prerelease = strings.Split(patchStr[preIndex+1:], ".")
patchStr = patchStr[:preIndex]
}
if !containsOnly(patchStr, numbers) {
return Version{}, fmt.Errorf("Invalid character(s) found in patch number %q", patchStr)
}
if hasLeadingZeroes(patchStr) {
return Version{}, fmt.Errorf("Patch number must not contain leading zeroes %q", patchStr)
}
patch, err := strconv.ParseUint(patchStr, 10, 64)
if err != nil {
return Version{}, err
}
v.Patch = patch
// Prerelease
for _, prstr := range prerelease {
parsedPR, err := NewPRVersion(prstr)
if err != nil {
return Version{}, err
}
v.Pre = append(v.Pre, parsedPR)
}
// Build meta data
for _, str := range build {
if len(str) == 0 {
return Version{}, errors.New("Build meta data is empty")
}
if !containsOnly(str, alphanum) {
return Version{}, fmt.Errorf("Invalid character(s) found in build meta data %q", str)
}
v.Build = append(v.Build, str)
}
return v, nil
}
// MustParse is like Parse but panics if the version cannot be parsed.
func MustParse(s string) Version {
v, err := Parse(s)
if err != nil {
panic(`semver: Parse(` + s + `): ` + err.Error())
}
return v
}
// PRVersion represents a PreRelease Version
type PRVersion struct {
VersionStr string
VersionNum uint64
IsNum bool
}
// NewPRVersion creates a new valid prerelease version
func NewPRVersion(s string) (PRVersion, error) {
if len(s) == 0 {
return PRVersion{}, errors.New("Prerelease is empty")
}
v := PRVersion{}
if containsOnly(s, numbers) {
if hasLeadingZeroes(s) {
return PRVersion{}, fmt.Errorf("Numeric PreRelease version must not contain leading zeroes %q", s)
}
num, err := strconv.ParseUint(s, 10, 64)
// Might never be hit, but just in case
if err != nil {
return PRVersion{}, err
}
v.VersionNum = num
v.IsNum = true
} else if containsOnly(s, alphanum) {
v.VersionStr = s
v.IsNum = false
} else {
return PRVersion{}, fmt.Errorf("Invalid character(s) found in prerelease %q", s)
}
return v, nil
}
// IsNumeric checks if prerelease-version is numeric
func (v PRVersion) IsNumeric() bool {
return v.IsNum
}
// Compare compares two PreRelease Versions v and o:
// -1 == v is less than o
// 0 == v is equal to o
// 1 == v is greater than o
func (v PRVersion) Compare(o PRVersion) int {
if v.IsNum && !o.IsNum {
return -1
} else if !v.IsNum && o.IsNum {
return 1
} else if v.IsNum && o.IsNum {
if v.VersionNum == o.VersionNum {
return 0
} else if v.VersionNum > o.VersionNum {
return 1
} else {
return -1
}
} else { // both are Alphas
if v.VersionStr == o.VersionStr {
return 0
} else if v.VersionStr > o.VersionStr {
return 1
} else {
return -1
}
}
}
// PreRelease version to string
func (v PRVersion) String() string {
if v.IsNum {
return strconv.FormatUint(v.VersionNum, 10)
}
return v.VersionStr
}
func containsOnly(s string, set string) bool {
return strings.IndexFunc(s, func(r rune) bool {
return !strings.ContainsRune(set, r)
}) == -1
}
func hasLeadingZeroes(s string) bool {
return len(s) > 1 && s[0] == '0'
}
// NewBuildVersion creates a new valid build version
func NewBuildVersion(s string) (string, error) {
if len(s) == 0 {
return "", errors.New("Buildversion is empty")
}
if !containsOnly(s, alphanum) {
return "", fmt.Errorf("Invalid character(s) found in build meta data %q", s)
}
return s, nil
}
+28
View File
@@ -0,0 +1,28 @@
package semver
import (
"sort"
)
// Versions represents multiple versions.
type Versions []Version
// Len returns length of version collection
func (s Versions) Len() int {
return len(s)
}
// Swap swaps two versions inside the collection by its indices
func (s Versions) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
// Less checks if version at index i is less than version at index j
func (s Versions) Less(i, j int) bool {
return s[i].LT(s[j])
}
// Sort sorts a slice of versions
func Sort(versions []Version) {
sort.Sort(Versions(versions))
}
+30
View File
@@ -0,0 +1,30 @@
package semver
import (
"database/sql/driver"
"fmt"
)
// Scan implements the database/sql.Scanner interface.
func (v *Version) Scan(src interface{}) (err error) {
var str string
switch src := src.(type) {
case string:
str = src
case []byte:
str = string(src)
default:
return fmt.Errorf("Version.Scan: cannot convert %T to string.", src)
}
if t, err := Parse(str); err == nil {
*v = t
}
return
}
// Value implements the database/sql/driver.Valuer interface.
func (v Version) Value() (driver.Value, error) {
return v.String(), nil
}
+2 -2
View File
@@ -323,7 +323,7 @@ func (c *Compiler) Compile(node parser.Node) error {
return err return err
} }
case *parser.Ident: case *parser.Ident:
symbol, _, ok := c.symbolTable.Resolve(node.Name) symbol, _, ok := c.symbolTable.Resolve(node.Name, false)
if !ok { if !ok {
return c.errorf(node, "unresolved reference '%s'", node.Name) return c.errorf(node, "unresolved reference '%s'", node.Name)
} }
@@ -659,7 +659,7 @@ func (c *Compiler) compileAssign(
return c.errorf(node, "operator ':=' not allowed with selector") return c.errorf(node, "operator ':=' not allowed with selector")
} }
symbol, depth, exists := c.symbolTable.Resolve(ident) symbol, depth, exists := c.symbolTable.Resolve(ident, false)
if op == token.Define { if op == token.Define {
if depth == 0 && exists { if depth == 0 && exists {
return c.errorf(node, "'%s' redeclared in this block", ident) return c.errorf(node, "'%s' redeclared in this block", ident)
+1 -1
View File
@@ -116,7 +116,7 @@ func (s *Script) Compile() (*Compiled, error) {
// global symbol names to indexes // global symbol names to indexes
globalIndexes := make(map[string]int, len(globals)) globalIndexes := make(map[string]int, len(globals))
for _, name := range symbolTable.Names() { for _, name := range symbolTable.Names() {
symbol, _, _ := symbolTable.Resolve(name) symbol, _, _ := symbolTable.Resolve(name, false)
if symbol.Scope == ScopeGlobal { if symbol.Scope == ScopeGlobal {
globalIndexes[name] = symbol.Index globalIndexes[name] = symbol.Index
} }
+30 -8
View File
@@ -44,6 +44,17 @@ func (t *SymbolTable) Define(name string) *Symbol {
if t.Parent(true) == nil { if t.Parent(true) == nil {
symbol.Scope = ScopeGlobal symbol.Scope = ScopeGlobal
// if symbol is defined in a block of global scope, symbol index must
// be tracked at the root-level table instead.
if p := t.parent; p != nil {
for p.parent != nil {
p = p.parent
}
t.numDefinition--
p.numDefinition++
}
} else { } else {
symbol.Scope = ScopeLocal symbol.Scope = ScopeLocal
} }
@@ -71,12 +82,25 @@ func (t *SymbolTable) DefineBuiltin(index int, name string) *Symbol {
// Resolve resolves a symbol with a given name. // Resolve resolves a symbol with a given name.
func (t *SymbolTable) Resolve( func (t *SymbolTable) Resolve(
name string, name string,
) (symbol *Symbol, depth int, ok bool) { recur bool,
symbol, ok = t.store[name] ) (*Symbol, int, bool) {
if !ok && t.parent != nil { symbol, ok := t.store[name]
symbol, depth, ok = t.parent.Resolve(name) if ok {
// symbol can be used if
if symbol.Scope != ScopeLocal || // it's not of local scope, OR,
symbol.LocalAssigned || // it's assigned at least once, OR,
recur { // it's defined in higher level
return symbol, 0, true
}
}
if t.parent == nil {
return nil, 0, false
}
symbol, depth, ok := t.parent.Resolve(name, true)
if !ok { if !ok {
return return nil, 0, false
} }
depth++ depth++
@@ -87,9 +111,7 @@ func (t *SymbolTable) Resolve(
symbol.Scope != ScopeBuiltin { symbol.Scope != ScopeBuiltin {
return t.defineFree(symbol), depth, true return t.defineFree(symbol), depth, true
} }
return return symbol, depth, true
}
return
} }
// Fork creates a new symbol table for a new scope. // Fork creates a new symbol table for a new scope.
+12
View File
@@ -0,0 +1,12 @@
language: go
go:
- "1.10.x"
- "1.11.x"
- "1.12.x"
before_install:
- go get github.com/mattn/goveralls
script:
- go test -v -race -cover
- $GOPATH/bin/goveralls -service=travis-ci
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2012 Grigory Dryapak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+226
View File
@@ -0,0 +1,226 @@
# Imaging
[![GoDoc](https://godoc.org/github.com/disintegration/imaging?status.svg)](https://godoc.org/github.com/disintegration/imaging)
[![Build Status](https://travis-ci.org/disintegration/imaging.svg?branch=master)](https://travis-ci.org/disintegration/imaging)
[![Coverage Status](https://coveralls.io/repos/github/disintegration/imaging/badge.svg?branch=master&service=github)](https://coveralls.io/github/disintegration/imaging?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/disintegration/imaging)](https://goreportcard.com/report/github.com/disintegration/imaging)
Package imaging provides basic image processing functions (resize, rotate, crop, brightness/contrast adjustments, etc.).
All the image processing functions provided by the package accept any image type that implements `image.Image` interface
as an input, and return a new image of `*image.NRGBA` type (32bit RGBA colors, non-premultiplied alpha).
## Installation
go get -u github.com/disintegration/imaging
## Documentation
http://godoc.org/github.com/disintegration/imaging
## Usage examples
A few usage examples can be found below. See the documentation for the full list of supported functions.
### Image resizing
```go
// Resize srcImage to size = 128x128px using the Lanczos filter.
dstImage128 := imaging.Resize(srcImage, 128, 128, imaging.Lanczos)
// Resize srcImage to width = 800px preserving the aspect ratio.
dstImage800 := imaging.Resize(srcImage, 800, 0, imaging.Lanczos)
// Scale down srcImage to fit the 800x600px bounding box.
dstImageFit := imaging.Fit(srcImage, 800, 600, imaging.Lanczos)
// Resize and crop the srcImage to fill the 100x100px area.
dstImageFill := imaging.Fill(srcImage, 100, 100, imaging.Center, imaging.Lanczos)
```
Imaging supports image resizing using various resampling filters. The most notable ones:
- `Lanczos` - A high-quality resampling filter for photographic images yielding sharp results.
- `CatmullRom` - A sharp cubic filter that is faster than Lanczos filter while providing similar results.
- `MitchellNetravali` - A cubic filter that produces smoother results with less ringing artifacts than CatmullRom.
- `Linear` - Bilinear resampling filter, produces smooth output. Faster than cubic filters.
- `Box` - Simple and fast averaging filter appropriate for downscaling. When upscaling it's similar to NearestNeighbor.
- `NearestNeighbor` - Fastest resampling filter, no antialiasing.
The full list of supported filters: NearestNeighbor, Box, Linear, Hermite, MitchellNetravali, CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, Cosine. Custom filters can be created using ResampleFilter struct.
**Resampling filters comparison**
Original image:
![srcImage](testdata/branches.png)
The same image resized from 600x400px to 150x100px using different resampling filters.
From faster (lower quality) to slower (higher quality):
Filter | Resize result
--------------------------|---------------------------------------------
`imaging.NearestNeighbor` | ![dstImage](testdata/out_resize_nearest.png)
`imaging.Linear` | ![dstImage](testdata/out_resize_linear.png)
`imaging.CatmullRom` | ![dstImage](testdata/out_resize_catrom.png)
`imaging.Lanczos` | ![dstImage](testdata/out_resize_lanczos.png)
### Gaussian Blur
```go
dstImage := imaging.Blur(srcImage, 0.5)
```
Sigma parameter allows to control the strength of the blurring effect.
Original image | Sigma = 0.5 | Sigma = 1.5
-----------------------------------|----------------------------------------|---------------------------------------
![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_blur_0.5.png) | ![dstImage](testdata/out_blur_1.5.png)
### Sharpening
```go
dstImage := imaging.Sharpen(srcImage, 0.5)
```
`Sharpen` uses gaussian function internally. Sigma parameter allows to control the strength of the sharpening effect.
Original image | Sigma = 0.5 | Sigma = 1.5
-----------------------------------|-------------------------------------------|------------------------------------------
![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_sharpen_0.5.png) | ![dstImage](testdata/out_sharpen_1.5.png)
### Gamma correction
```go
dstImage := imaging.AdjustGamma(srcImage, 0.75)
```
Original image | Gamma = 0.75 | Gamma = 1.25
-----------------------------------|------------------------------------------|-----------------------------------------
![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_gamma_0.75.png) | ![dstImage](testdata/out_gamma_1.25.png)
### Contrast adjustment
```go
dstImage := imaging.AdjustContrast(srcImage, 20)
```
Original image | Contrast = 15 | Contrast = -15
-----------------------------------|--------------------------------------------|-------------------------------------------
![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_contrast_p15.png) | ![dstImage](testdata/out_contrast_m15.png)
### Brightness adjustment
```go
dstImage := imaging.AdjustBrightness(srcImage, 20)
```
Original image | Brightness = 10 | Brightness = -10
-----------------------------------|----------------------------------------------|---------------------------------------------
![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_brightness_p10.png) | ![dstImage](testdata/out_brightness_m10.png)
### Saturation adjustment
```go
dstImage := imaging.AdjustSaturation(srcImage, 20)
```
Original image | Saturation = 30 | Saturation = -30
-----------------------------------|----------------------------------------------|---------------------------------------------
![srcImage](testdata/flowers_small.png) | ![dstImage](testdata/out_saturation_p30.png) | ![dstImage](testdata/out_saturation_m30.png)
## FAQ
### Incorrect image orientation after processing (e.g. an image appears rotated after resizing)
Most probably, the given image contains the EXIF orientation tag.
The stadard `image/*` packages do not support loading and saving
this kind of information. To fix the issue, try opening images with
the `AutoOrientation` decode option. If this option is set to `true`,
the image orientation is changed after decoding, according to the
orientation tag (if present). Here's the example:
```go
img, err := imaging.Open("test.jpg", imaging.AutoOrientation(true))
```
### What's the difference between `imaging` and `gift` packages?
[imaging](https://github.com/disintegration/imaging)
is designed to be a lightweight and simple image manipulation package.
It provides basic image processing functions and a few helper functions
such as `Open` and `Save`. It consistently returns *image.NRGBA image
type (8 bits per channel, RGBA).
[gift](https://github.com/disintegration/gift)
supports more advanced image processing, for example, sRGB/Linear color
space conversions. It also supports different output image types
(e.g. 16 bits per channel) and provides easy-to-use API for chaining
multiple processing steps together.
## Example code
```go
package main
import (
"image"
"image/color"
"log"
"github.com/disintegration/imaging"
)
func main() {
// Open a test image.
src, err := imaging.Open("testdata/flowers.png")
if err != nil {
log.Fatalf("failed to open image: %v", err)
}
// Crop the original image to 300x300px size using the center anchor.
src = imaging.CropAnchor(src, 300, 300, imaging.Center)
// Resize the cropped image to width = 200px preserving the aspect ratio.
src = imaging.Resize(src, 200, 0, imaging.Lanczos)
// Create a blurred version of the image.
img1 := imaging.Blur(src, 5)
// Create a grayscale version of the image with higher contrast and sharpness.
img2 := imaging.Grayscale(src)
img2 = imaging.AdjustContrast(img2, 20)
img2 = imaging.Sharpen(img2, 2)
// Create an inverted version of the image.
img3 := imaging.Invert(src)
// Create an embossed version of the image using a convolution filter.
img4 := imaging.Convolve3x3(
src,
[9]float64{
-1, -1, 0,
-1, 1, 1,
0, 1, 1,
},
nil,
)
// Create a new image and paste the four produced images into it.
dst := imaging.New(400, 400, color.NRGBA{0, 0, 0, 0})
dst = imaging.Paste(dst, img1, image.Pt(0, 0))
dst = imaging.Paste(dst, img2, image.Pt(0, 200))
dst = imaging.Paste(dst, img3, image.Pt(200, 0))
dst = imaging.Paste(dst, img4, image.Pt(200, 200))
// Save the resulting image as JPEG.
err = imaging.Save(dst, "testdata/out_example.jpg")
if err != nil {
log.Fatalf("failed to save image: %v", err)
}
}
```
Output:
![dstImage](testdata/out_example.jpg)

Some files were not shown because too many files have changed in this diff Show More