New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Channel
#2620
base: main
Are you sure you want to change the base?
feat: Channel
#2620
Conversation
sending photo in channels has some problems |
wanna tell me what they are? |
After sending an image in a channel... |
Tested and worked great here. Here is how I did it. Step 1: Install @alechkos wweb.js version:
Step 2: Create a channel and get it's ID:
Step 3: Start publishing:
|
One question, tho. How to publish media? |
sending media is still doesn't work |
Same here. I even though it was my connection, but every other media downloaded from channels work great. It's a bug |
Thank you for testing, |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: Sven Neumann <s.neumann@websix.de>
Now you can send polls in channels:const { Client, Poll, /* others */ } = require('whatsapp-web.js');
// client initialization...
const channelId = 'your_channel_id@newsletter';
client.on('ready', async () => {
await client.sendMessage(channelId, new Poll('Cats or Dogs?', ['Cats', 'Dogs']));
// Also you can send polls with multiple answers:
await client.sendMessage(channelId, new Poll('Cats or Dogs?', ['Cats', 'Dogs'], { allowMultipleAnswers: true }));
}); |
Should we support get channel by using getChatById? |
Definitely yes |
const sendChannelMsgResponse = await window.Store.SendChannelMessage.sendNewsletterMessageJob({ | ||
msg: msg, | ||
type: message.type === 'chat' ? 'text' : isMedia ? 'media' : 'pollCreation', | ||
newsletterJid: chat.id.toJid(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should allow some extra option so pepole can control some fileds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should allow some extra option so pepole can control some fileds
Unfortunately, once you you change those props, the message is not being sent.
But I have not tested it a lot.
You can try to play with adding some extra properties. If it will work for you, just suggest your changes and I'll add them as your commit :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shirser121
Don't we already have extra options here?
...(isMedia ? { mediaMetadata: msg.avParams() } : {}) | ||
}); | ||
|
||
if (sendChannelMsgResponse.success) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If success is false, what happened?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If success is false, what happened?
Once the response is success
, we update the timestamp
and serverId
props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise we don't
Table of Contents
- Description
- Related Issues
- Usage Example
- I Want to Test this PR
- I Got an Error While Testing This PR ❌
- How Has the PR Been Tested (latest test on 22.04.2024)
- Types of Changes
Description
The PR introduces new functionality for managing channels.
Added new methods:
Client.createChannel
that takes 2 parameters:title
(required)options
(optional) with properties:description
for a channel descriptionpicture
for a channel profile picture which will be set upon a channel creationClient.subscribeToChannel
to subscribe to channel that takes a channel IDClient.unsubscribeFromChannel
to unsubscribe from channel. The method takes 2 parameters:options
(optional) with propertydeleteLocalModels
. If true, after an unsubscription, it will completely remove a channel from the channel collection making it seem like the current user have never interacted with it. Otherwise it will only remove a channel from the list of channels the current user is subscribed to and will set the membership type for that channel to GUESTClient.searchChannels
to search channels, the method takes 5 optional parameters:searchText
, the text by which you want to find the channel (empty string by default)countryCodes
, an array of country codes in ISO 3166-1 alpha-2 standart to search for channels created in these countries, your local region is used as a value by defaultview
for specifing the category of channels to get, valid values are:RECOMMENDED
(default value)MOST_ACTIVE
POPULAR
NEW
FEATURED
limit
for specifing the limit of found channels to be appear in the returnig results (default value is 50)sortOptions
to sort the returning results by with these properties:field
for specifing the field to sort by, valid values are:SUBSCRIBERS
(default value)order
, valid values are:DESCENDING
(default value)Updated
Client.getChatById
to retrieve aChannel
instance by its IDClient.getChannelByInviteCode
to retrieve aChannel
instance by its invite code (that comes afterhttps://whatsapp.com/channel/
), e.g.:0029Va4K0PZ5a245NkngBA2M
(an invite code of a WhatsApp channel)Client.getChannels
that returns all your cachedChannel
objects as an arrayClient.sendChannelAdminInvite
andChannel.sendChannelAdminInvite
to send a channel admin invitation to a user, allowing them to become an admin of the channel, you can also provide a text comment that will be sent along within invitation by providing a string in acomment
property of an optionaloptions
objectClient.acceptChannelAdminInvite
andChannel.acceptChannelAdminInvite
to accept a channel admin invitation and promote the current user to a channel adminClient.revokeChannelAdminInvite
andChannel.revokeChannelAdminInvite
to revoke a channel admin invitation previously sent to a user by a channel ownerClient.demoteChannelAdmin
andChannel.demoteChannelAdmin
to demote a channel admin to a regular subscriber (can be used also for self-demotion)Channel.sendMessage
and updatedClient.sendMessage
to send a message to a channel (currently supported message types to send are: text, image, sticker, gif, video and poll)Channel.fetchMessages
that works similarly toChat.fetchMessages
Channel.getSubscribers
to get subscribers of the channel (only those who are in your contact list), you can pass an optionallimit
parameter to specify the limit of subscribers to retrieve (if not specified, thelimit
value will be set to the maximum provided by WhatsApp)Channel.setSubject
that updates the channel subject (name)Channel.setDescription
that updates the channel descriptionChannel.setProfilePicture
that updates the channel propfile pictureChannel.setReactionSetting
that updates available reactions to use in the channel, valid values to pass:0
for ALL reactions to be available1
for BASIC reactions to be available: 👍, ❤️, 😂, 😮, 😢, 🙏2
for NONE reactions to be avaliable (turnes off using reactions in a channel)Channel.mute
andChannel.unmute
to mute and unmute channel respectively (once you subcribed to a channel it will be muted)Channel.deleteChannel
that deletes the channel you createdRelated Issues
The PR closes #2094, closes #2529, closes #2538, closes #2551, closes #2952
Usage Example
1. To create a channel:
2. To subscribe to a channel:
3. To unsubscribe from a channel:
4. To search for channels:
5. To get a channel by its ID:
6. To get a channel by its invite code:
7. To get all cached channels:
8. To send a channel admin invitation to a user as a channel admin:
9. To accept a channel admin invitation as a regular user:
10. To revoke a channel admin invitation as a channel admin:
11. To demote a channel admin:
12. To get channel subscribers:
13. To set channel subject (name):
14. To set channel description:
15. To set channel profile picture:
16. To set a channel available reactions:
17. To mute/unmute a channel:
18. To delete a channel:
To test this PR by yourself you should do two steps:
1. Install the PR by running one of the following commands:
2. Lock your WWeb version on 2.2412.54:
If you encounter any errors while testing this PR, please provide in a comment:
console.log(await client.getWWebVersion());
Important
You have to reapply the PR each time it is changed (new commits were pushed since your last application)
How Has The PR Been Tested (latest test on 22.04.2024)
Tested with a code provided in usage example.
Tested On:
Types of accounts:
Environment:
Types of Changes
Checklist