V
V
Vladimir Rakitin2019-12-15 21:12:24
C++ / C#
Vladimir Rakitin, 2019-12-15 21:12:24

Telegram bot greeting C#?

I was thinking about how to greet him when a new member enters the group, or rather, to have the bot do it, I’m looking for a similar method, but something doesn’t work out very well.
I thought about watching it through ChatMemberStatus, but I don’t understand how, although there is also the NewChatMembers method, I tried it through it, but it simply answers every message that the user has entered the chat, here is the line of code

if (message.Type == MessageType.Text && message.NewChatMembers != null) 
                    return;
                    await Bot.SendTextMessageAsync(message.Chat.Id, $"{name}, Привет !");
                Console.WriteLine($"{name} Вошел в чат");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2019-12-15
@vabka

You are trying to use the wrong message.Type. You need MessageType.ChatMembersAdded - with this value, the NewChatMembers field will contain an array of users who were just added
5df687a5e31c0216006716.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question