How to fire method when user enter in group? - bots

Looking at the Telegram API documentation I can't find any hook that allow me to call a method when an user enter in a group.
Note that forma 'enter' I mean when the user open the chat, and not a join to the group.
I'm using TelegrafJS framework.
Kind regards.

As far as I know it's a security feature that you have no access to what people 'open', there is a reason that the join button is there, so that people share their info with the group when they are comfortable sharing it.
If there was, you'd have to use the same solution with a different result (I.E: new_browsed_users)
Since the Update object doesn't return it, then we can assume there isn't a way.
Telegram Bot Event When Users Join To Channel

I'm not in TelegrafJS, but should be like this:
bot.on('new_chat_members', (ctx) => ctx.reply('đź‘Ť'))
See "new_chat_members" here.

Related

How to get the Group chat added member list from ChatBot in msteams

how to collect all the group chat members from the chat bot using MSTeams?
You can use the GetPagedMembers capability for this - see the docs from Microsoft here: https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/get-teams-context?tabs=dotnet (switch to your language of choice in the samples blocks).
Note that, using this approach, you can only do this when the user is actually interacting with the bot (e.g. posting a message) because you need the context. If that's a problem let me know and I will send additional info.
Here are the two ways that can work for you
Using graph - List members of a chat. Refer this sample.
Get conversation member. (you are already aware about this as I can see.)

How i can make welcome command and add option to set channel where it'll be sending?

I'm new discord bot developer and I wanted to add command that allows to set welcome channel in my bot, but I don't really know how to do it. I tried to find an answer, but all of them have defined id already, so it won't work on other servers. If you can help me or give me tip how to do it, please.
I mean I wanted to define channel id as an argument but how I can save it for server so it won't save it for all servers.
You'd need to set up a database and store the channel and server IDs there. If you're just starting out, try using LowDB, which isn't exactly what I'd call a "database", but should get the job done for now.
If you want to use an actual database that is still very easy to understand, give MongoDB a try.
To get your feature working, you'd need to store the server and channel IDs to the database, and check it whenever a new user joins.

Muliple choice option in skype channel botframework [node.js]

I'm searching solution form last week but no luck.
Can user select the multiple options in skype Nodejs SDK.
I'm looking for the solution where user can be able to select the more than one option from the choice list.
Let's say I wanted to implement the subscription functionality so the bot
will pass the list of items to Skype client to view user.
Choice List
From above Now I want to subscribe the more that one item form list Ex. (Computer, Tech, Gadgets)
Can anyone Please help me to achieve by aim. If not possible can you please give me the actual reason.
Thanks :)
The ability to select multiple items in a choice prompt is not currently an available feature of the BotBuilder SDK.
An alternate way to handle this scenario would be to guide the user through a series of choice prompts where they could add a new item to an internal data object, or alternately store it in the session.userData or session.conversationData object.
If you'd like to make a feature request you can email: feedback#botframework.com

Don't let member to send message in telegram group

I'm looking for a way in telegram group that don't let member to send message or, delete message after a person send.
Is it possible to create a bot like this how help admins to stop chatting after start the bot?
Is there any other way to do this?
Now you can do this.
Restriction from chatting in group:
Now you can achieve this with restrictChatMember() Bot API method.
Deletion of users' messages:
For deletion use this method: deleteMessage()
DON'T forget to grant admin rights to your bot.
11/07/18: This answer is no longer up to date please look at woozly's answer
Short answer: No (at least not with the bot api)
Longer answer:
There currently is no way of stopping someone from chatting without outright kicking them out of the group. Additionally, bots currently lack the ability to delete messages so that's also not doable with the bot API.
Edit: Actually it's probably possible using the Telegram API instead of the Telegram Bot API where you would just create a regular user which is controlled programmatically to delete messages of "muted" people. I assume that this is likely not as simple as doing stuff with the bot API but in theory, it's possible.
#telemethebot has exact the feature you request:
Silent Mode
When group silent mode switched on, only group administrators can speak in that group. This help you turning your Telegram supergroup to a channel temporarily.
Teleme - Features

Telegram Bot Event When Users Join To Channel

After create telegram bot, access and admin this bot to channel. how to get channel members list or event when users join to this channel?
Pretty disappointed with the current answers, so I'll leave an updated (as of February 2018) answer that explains how to do this with the Telegram API itself, as well as with the framework I am using, Telegraf for Node.
The Telegram API is both very powerful, and pretty simple as far as API's go. If you are using the polling method of getting updates, and not websockets which are a whole other issue, checking if someone new has been added to a group or channel is very easy.
The API method getUpdates returns an array of Update objects, which contain all of the possible information you could want including any messages sent, inline queries, and new chat members. To get any new chat members you simply need to access update.message.new_chat_members which will contain an array of new users. For reference you can look in the API documentation here.
To fetch the update objects in browser, or with curl, all you have to do is send a GET or POST request to https://api.telegram.org/botYOUR-BOT-TOKEN/getUpdates. Then just look for messages->new_chat_members.
If you are using the Telegraf bot framework with NodeJs you can use the bot.on method with the event new_chat_members.
Example:
bot.on('new_chat_members', (ctx) => console.log(ctx.message.new_chat_members))
I know this was asked a while ago, but I hope this helps other people searching.
From docs:
new_chat_members New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
So i think you can't.
To get updates on users join group or channel you must correctly setup webhook for your bot. This update type is disabled by default. See https://core.telegram.org/bots/api#setwebhook
allowed_updates
A JSON-serialized list of the update types you want your bot to
receive. For example, specify [“message”, “edited_channel_post”,
“callback_query”] to only receive updates of these types. See Update
for a complete list of available update types. Specify an empty list
to receive all update types except chat_member (default). If not
specified, the previous setting will be used.
Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received
for a short period of time.
So, the request should look like this:
https://api.telegram.org/<BOT_TOKEN>/setWebhook?url=<WEBHOOK_URL>&allowed_updates=["chat_member"]
Yes! You can use this:
https://api.telegram.org/bot[TOKEN]/promoteChatMember?chat_id=#[channelname]&user_id=[user_id]
if user is joined response is ok, else response is not ok.

Resources