Giter VIP home page Giter VIP logo

watgbridge's Introduction

WhatsApp-Telegram-Bridge

Despite the name, its not exactly a "bridge". It forwards messages from WhatsApp to Telegram and you can reply to them from Telegram.

       

DISCLAIMER !!!

This project is in no way affiliated with WhatsApp or Telegram. Using this can also lead to your account getting banned by WhatsApp so use at your own risk.

Sample Screenshots

Telegram Side WhatsApp Side

Features and Design Choices

  • All messages from various chats (on WhatsApp) are sent to different topics/threads within the same target group (on Telegram)
  • Configuration options available to disable different types of updates from WhatsApp
  • Can reply and send new messages from Telegram
  • Can tag all people using @all or @everyone. Others can also use this in group chats which you specify in configuration file
  • Can react to messages by replying with single instance of the desired emoji
  • Supports static stickers from both ends
  • Can send Animated (TGS) stickers from Telegram
  • Video stickers from Telegram side are supported
  • Video stickers from WhatsApp side are currently forwarded as GIFs to Telegram

Bugs and TODO

  • Document naming is messed up and not consistent on Telegram, have to find a way to always send sane names

PRs are welcome :)

Installation

  • Make a supergroup (enable message history for new members) with topics enabled
  • Add your bot in the group, make it an admin with permissions to Manage topics
  • Install git, gcc and golang, ffmpeg , imagemagick (optional), on your system
  • Clone this repository anywhere and navigate to the cloned directory
  • Run go build
  • Copy sample_config.yaml to config.yaml and fill the values, there are comments to help you.
  • Execute the binary by running ./watgbridge
  • On first run, it will show QR code for logging into WhatsApp that can by scanned by the WhatsApp app in Linked devices
  • It is recommended to restart the bot after every few hours becuase WhatsApp likes to disconnect a lot. So a sample Systemd service file has been provided (watgbridge.service.sample). Edit the User and ExecStart according to your setup:
    • If you do not have local bot API server, remove tgbotapi.service from the After key in Unit section.
    • This service file will restart the bot every 24 hours

watgbridge's People

Contributors

akshettrj avatar celestix avatar destroyer-32 avatar tamilvip007 avatar v4dkou avatar zekxtreme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

watgbridge's Issues

/unlink

Bot command for remove topics associations

add docker

Hope you could add docker for this repository.

Notify on telegram side when whatsapp requires auth

I installed this on a Raspberry Pi 4 and set up a service to run it. Sometimes, the application asks for the QR code again, but it's hard to notice since I wasn't checking the service, and I have no way to do so without connecting to the Raspberry Pi to check if the service is asking for the QR code.

Is it possible to add a notification on the Telegram side when WhatsApp isn't authenticated correctly to make it more noticeable?

Thanks in advance for your great job!

Error: "unable to createForumTopic"

I always get this message in the #general thread of my group when anything inside of WA happens:

image

I seem to be unable to get the bot to relay any messages or reactions to my Telegram group. I might have messed up the settings on the Telegram side though. Tried everything in Group permissions, made the bot admin, turned privacy mode off on the bot and rejoined it - nothing helps. Any idea what I'm doing wrong?

How do I fix this error?

{"level":"error","ts":1685481952.1088867,"logger":"WaTgBridge.WhatsMeow_Client","caller":"whatsapp/client.go:32","msg":"Event handler panicked while handling a *events.Message: runtime error: invalid memory address or nil pointer dereference\ngoroutine 30 [running]:\nruntime/debug.Stack()\n\t/snap/go/current/src/runtime/debug/stack.go:24 +0x65\ngo.mau.fi/whatsmeow.(*Client).dispatchEvent.func1()\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/client.go:594 +0x7d\npanic({0xec82a0, 0x17f16f0})\n\t/snap/go/current/src/runtime/panic.go:884 +0x213\nwatgbridge/whatsapp.MessageFromOthersEventHandler({0xc0005b9608, 0x12}, 0xc0001ad2c0)\n\t/go/src/watgbridge/whatsapp/handlers.go:1101 +0x9745\nwatgbridge/whatsapp.WhatsAppEventHandler({0xeaccc0?, 0xc0001ad2c0?})\n\t/go/src/watgbridge/whatsapp/handlers.go:95 +0x1049\ngo.mau.fi/whatsmeow.(*Client).dispatchEvent(0xc00059c000?, {0xeaccc0, 0xc0001ad2c0})\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/client.go:598 +0xdc\ngo.mau.fi/whatsmeow.(*Client).handleDecryptedMessage(0xc000489900?, 0xc0006ec240, 0xc000189800)\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/message.go:482 +0xce\ngo.mau.fi/whatsmeow.(*Client).decryptMessages(0xc00059c000, 0xc0006ec240, 0xc0006dec60)\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/message.go:171 +0xae5\ngo.mau.fi/whatsmeow.(*Client).handleEncryptedMessage(0xc00059c000, 0x0?)\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/message.go:49 +0x33f\ngo.mau.fi/whatsmeow.(*Client).handlerQueueLoop(0xc00059c000, {0x11a3510, 0xc000582140})\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/client.go:559 +0x6b\ncreated by go.mau.fi/whatsmeow.(*Client).Connect\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/client.go:313 +0x45b\n","stacktrace":"watgbridge/whatsapp.whatsmeowLogger.Errorf\n\t/go/src/watgbridge/whatsapp/client.go:32\ngo.mau.fi/whatsmeow.(*Client).dispatchEvent.func1\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/client.go:594\nruntime.gopanic\n\t/snap/go/current/src/runtime/panic.go:884\nruntime.panicmem\n\t/snap/go/current/src/runtime/panic.go:260\nruntime.sigpanic\n\t/snap/go/current/src/runtime/signal_unix.go:837\nwatgbridge/whatsapp.MessageFromOthersEventHandler\n\t/go/src/watgbridge/whatsapp/handlers.go:1101\nwatgbridge/whatsapp.WhatsAppEventHandler\n\t/go/src/watgbridge/whatsapp/handlers.go:95\ngo.mau.fi/whatsmeow.(*Client).dispatchEvent\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/client.go:598\ngo.mau.fi/whatsmeow.(*Client).handleDecryptedMessage\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/message.go:482\ngo.mau.fi/whatsmeow.(*Client).decryptMessages\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/message.go:171\ngo.mau.fi/whatsmeow.(*Client).handleEncryptedMessage\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/message.go:49\ngo.mau.fi/whatsmeow.(*Client).handlerQueueLoop\n\t/root/go/pkg/mod/go.mau.fi/[email protected]/client.go:559"

Poll support

Now that WhatsApp have polls too, currently when a poll is sent from whatsapp nothing is received on telegram side

Button for adding to group

Use the API to send a button through the bot for selecting/creating the target chat on Telegram during initial setup

Linker warning when compiling

After running the go build command, the compilation stops with the following messages:

I appreciate any help.

github.com/Benau/go_rlottie

In file included from vector_stb_stb_image.cpp:14:
vector_stb_stb_image.h: In function ‘int stbi__jpeg_info(stbi__context*, int*, int*, int*)’:
vector_stb_stb_image.h:956:29: warning: value computed is not used [-Wunused-value]
956 | #define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL))
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vector_stb_stb_image.h:3811:7: note: in expansion of macro ‘stbi__errpuc’
3811 | stbi__errpuc("outofmem", "Out of memory");
| ^~~~~~~~~~~~

watgbridge

/usr/bin/ld: warning: /tmp/go-link-2201394933/000027.o: missing .note.GNU-stack section implies executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker

Add i18n

Add the ability to use i18n. To add multiple languages

error

getting this error while trying to run the go build

root@ubuntu-s-2vcpu-2gb-amd-sgp1-01:~/go/src/watgbridge# go build
go: downloading github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.15
go: downloading github.com/go-co-op/gocron v1.18.0
go: downloading go.uber.org/zap v1.24.0
go: downloading github.com/robfig/cron/v3 v3.0.1
go: downloading golang.org/x/sync v0.1.0
go: downloading go.uber.org/atomic v1.10.0
go: downloading go.uber.org/multierr v1.6.0
go: downloading go.mau.fi/whatsmeow v0.0.0-20230213175431-ec411f5b9afe
go: downloading gorm.io/driver/mysql v1.4.6
go: downloading gorm.io/driver/postgres v1.4.7
go: downloading gorm.io/driver/sqlite v1.4.4
go: downloading gorm.io/gorm v1.24.5
go: downloading gopkg.in/yaml.v3 v3.0.1
go: downloading github.com/Benau/tgsconverter v0.0.0-20210809170556-99f4a4f6337f
go: downloading github.com/forPelevin/gomoji v1.1.8
go: downloading github.com/kolesa-team/go-webp v1.0.2
go: downloading github.com/lithammer/fuzzysearch v1.1.5
go: downloading golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb
go: downloading google.golang.org/protobuf v1.28.1
go: downloading github.com/emersion/go-vcard v0.0.0-20220507122617-d4056df0ec4a
go: downloading github.com/jackc/pgx/v5 v5.3.0
go: downloading github.com/mattn/go-sqlite3 v1.14.16
go: downloading github.com/mdp/qrterminal/v3 v3.0.0
go: downloading github.com/go-sql-driver/mysql v1.7.0
go: downloading go.mau.fi/libsignal v0.1.0
go: downloading github.com/jinzhu/now v1.1.5
go: downloading github.com/Benau/go_rlottie v0.0.0-20210807002906-98c1b2421989
go: downloading github.com/av-elier/go-decimal-to-rational v0.0.0-20191127152832-89e6aad02ecf
go: downloading github.com/kettek/apng v0.0.0-20220823221153-ff692776a607
go: downloading github.com/sizeofint/webpanimation v0.0.0-20210809145948-1d2b32119882
go: downloading github.com/rivo/uniseg v0.4.3
go: downloading golang.org/x/text v0.7.0
go: downloading rsc.io/qr v0.2.0
go: downloading github.com/jinzhu/inflection v1.0.0
go: downloading github.com/gorilla/websocket v1.5.0
go: downloading golang.org/x/crypto v0.6.0
go: downloading filippo.io/edwards25519 v1.0.0
go: downloading github.com/jackc/pgpassfile v1.0.0
go: downloading github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a
# github.com/kolesa-team/go-webp/decoder
../../pkg/mod/github.com/kolesa-team/[email protected]/decoder/decoder.go:27:10: fatal error: webp/decode.h: No such file or directory
 #include <webp/decode.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
# github.com/kolesa-team/go-webp/encoder
../../pkg/mod/github.com/kolesa-team/[email protected]/encoder/encoder.go:27:10: fatal error: webp/encode.h: No such file or directory
 #include <webp/encode.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
root@ubuntu-s-2vcpu-2gb-amd-sgp1-01:~/go/src/watgbridge# go build
# github.com/kolesa-team/go-webp/decoder
../../pkg/mod/github.com/kolesa-team/[email protected]/decoder/decoder.go:27:10: fatal error: webp/decode.h: No such file or directory
 #include <webp/decode.h>
          ^~~~~~~~~~~~~~~
compilation terminated.
# github.com/kolesa-team/go-webp/encoder
../../pkg/mod/github.com/kolesa-team/[email protected]/encoder/encoder.go:27:10: fatal error: webp/encode.h: No such file or directory
 #include <webp/encode.h>
          ^~~~~~~~~~~~~~~
compilation terminated.

go version: go1.20.3 linux/amd64
system: ubuntu-20

Group invite link is possibly broken

Me:
/joininvitelink https://chat.whatsapp.com/xxx/

Bot:
Failed to join:

info query returned status 400: bad-request

Afk. I will check the server logs later

[Feature Request] Send the confirmation messages silently

Whenever I am messaging actively with someone, it gets a bit annoying to see the “Successfully sent” confirmations. I am fine with them being there so I can undo a message if I screw up, but maybe these should be sent out silently, so my phone doesn't keep ringing whenever I chat on PC.

Document names while forwarding

Currently, the Document naming is very inconsistent on both platforms. The file names do not have correct extensions as displayed in the app or which extension it had while uploading. Some testing will have to be done to fix the naming issue, as it causes the forwarded document names to be of the wrong extension, which prevents them from being opened in appropriate applications especially on mobile devices

Imitate user's presense

Overall the experience of interacting with people who use WhatsApp through watgbridge seems almost flawless, barring one thing: it appears as if I am using some kind of stealth mode (messages are not marked as read, "last seen" timestamp is not being updated)

This is due to a limitation of the Bot API that does not allow receiving "message read" or "presence" events.

However, if we send a message to a contact, we can safely say that we've seen a message and we did open the messenger.
I would propose marking all unread messages in a chat as read and sending presence updates when we send a message there.

As this is not exactly a clean solution, I would make it configurable.

Relevant whatsmeow methods:

Where am I expected to find the required values?

Hello.

I've just tried to build your application.
It seems to compile fine on Linux Debian 12 (with just a deprecation warning).
But in your installation instructions, you wrote :

Copy sample_config.yaml to config.yaml and fill the values, there are comments to help you.

In the config.yaml file, I have :

telegram:
  bot_token: 186779
  #api_url: http://localhost:8082 # Uncomment if you have a local bot API server running (for bypassing file size limits)
  self_hosted_api: false
  owner_id: 704338780
  sudo_users_id:
    - 704338780
  target_chat_id: -100423424      # This is the chat where messages will be forwarded
  skip_video_stickers: false      # Setting this as true will stop trying to convert telegram video stickers to webp and sending them
  skip_setting_commands: false    # This will not show you list of commands when you start typing / in telegram

… with several numeric values which certainly don't belong to me.

Where am I expected to find the values to put instead?
There are no comments to help me about that.
The only one that I may have found is the bot_token, but still, it doesn't looks like a 6 digits value.

And I suppose that the WhatsApp part may have values that I will have to find, too.

Gingko.

Support for some sticker formats

Currently, all types of stickers are not supported. Support for them will need some tinkering to be done

From WhatsApp side

  • Animated stickers (WebP) are not supported

From Telegram side

  • Video stickers are not supported

name instead of ph number

hello there can u add support to disapl contact id in telegram by thier contact name instead of phone number also instead of /send command can u make it like sending a message in topic will send the message to the user without using any command

URL previews

Right now messages containing an URL sent through watgbridge do not have the preview generated from HTML tags <meta property="og:image"> like they do if you use the official client.

For feature parity, they probably should.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.