Telegram Bot API C# How to get All Pinned Messages? - c#

Telegram added the feature to pin more than one message. I'm doing it like this:
var chat = botClient.GetChatAsync(chatid).Result;
pinnedmsgtxt = chat.PinnedMessage.Text;
pinnedmsg= chat.PinnedMessage;
but I can only get the last message that was pinned. Any way to get all of them? Am I missing something? I'm using https://github.com/TelegramBots/telegram.bot

Use messages.search method with inputMessagesFilterPinned filter.
Please read more here:
Pin API
Message Search API
Pinned messages filter

Related

DSharpPlus send an embed to a specific channel?

I'm new to working with discord bots and I was wondering if anybody knew a way to send embedded messages to specific channels. The only way I've found so far to send one is to use RespondAsync which just directly replies to whoever issues the command in the same channel. The purpose of my bot is to create automated link directories in read only channels and the command will just refresh them. Having trouble finding much Dsharpplus c# examples, and I'm terrible at making sense of documentation. Any help would be appreciated.
await ctx.RespondAsync(embed);
this is what I've been using to send my embeds for testing purposes, but like I said I'd like to send it in a way that it posts to a specified channel
You just need to get the DiscordChannel object of the channel(s) you want to send the embed. You can get the ID of the channel via right-click in Discord and "Copy ID"
DiscordChannel channel = await _client.GetChannelAsync(ID_OF_CHANNEL);
DiscordEmbedBuilder embed = new DiscordEmbedBuilder
{
Color = DiscordColor.SpringGreen,
Description = "Good to see you!",
Title = "Hello World"
};
await channel.SendMessageAsync(embed: embed);
The DiscordGuild class also has GetChannelAsync you can use.

Check if user ID exists in Discord server in c#

I'm trying to make a auth link that the user will open then to get the client id from the user and check if the user is exists in a server. I'm not sure what lib should I use would love to get help thank you. I saw this code but this is in JavaScript and I need it in c# + the part of auth link
USER_ID = '123123123';
if (guild.member(USER_ID)) {
// there is a GuildMember with that ID
}```
DSharpPlus is a fairly simple library to use. It'll throw 404 not found when the user isn't found so you'll need to check the ClientErrored event for failure.
var guild = //get current guild somehow
var user = await guild.GetMemberAsync(USERID);
Documentation on GetMemberAsync: https://dsharpplus.emzi0767.com/api/DSharpPlus.Entities.DiscordGuild.html#DSharpPlus_Entities_DiscordGuild_GetMemberAsync_System_UInt64_
Repo: https://github.com/DSharpPlus/DSharpPlus
D#+ vs Discord.Net is DNet will give you more control over handling of events and messages. D#+ is more plug and play kind of deal.

Access previous message content from a user reply message on Telegram

Does anyone know how can I access a previous message content when a user sends a reply message on Telegram?
for example:
James: hello
me: reply on James message with "hello friend"
here i want to get the hello message content or its message id in my telegram bot to process a command.
sth like this:
if(message.Contains("/delete")){
bot.DeleteMessageAsync(chatId, PreviousMessage or OriginalMessage ID)
}
PreviousMessage or OriginalMessage ID are equals to MessageId
but instead of MessageId i want to use sth like those two
I have checked telegram bot documentation and I did not find anything
How can i do it?
(Im using getUpdates method)
sorry for my poor English
You can find the original message ID in message.reply_to_message.message_id. Naming could differ depends on the library you use. More information and other attributes that could be useful you can find in the official Telegram's documentation for the Message object.

Telegram Bot: get chat Id group

I've created a Telegram Bot using C# and I want to see who is using my bot when sending message.
I can get when people send a message to my bot in private chat but in the Groups, I can't get Username who is using Bot and it's return the GroupName.
The method I use is
var me = Bot.GetChatAsync(e.Message.Chat.Id).Result;
From doc this field User is optional for groups.
You can see who send message in e.Message.From, this property returns who send it as User.
And you should await methods that is awaitable.
And in your case Bot.GetChatAsync, this will return Chat from ChatId.
It means: Info about chat from Id.
And you pass Chat not ChatId to Bot.GetChatAsync

pass httpheader to the conversationupdated event - directline

Sending custom http header value while starting a conversation with the bot using DirectLine client. Was expecting it in the ConversationUpdate event in which I'm not able to finding it in the Request.Headers["userName"]
headers.Add("userName", name);
var conversation = await directLine.Conversations.StartConversationWithHttpMessagesAsync(headers);
The customHeaders parameter is automatically included in the client when generated by autorest, but it is not being used.
Initiating a direct line conversation with a specified from.Name is currently a prioritized backlog item.
I'm sorry these are not the answers you're looking for.

Categories