justdmitry / nettelegrambotapi Goto Github PK
View Code? Open in Web Editor NEWC# client library for building Telegram bot
License: MIT License
C# client library for building Telegram bot
License: MIT License
string API_HASH;
long user;
string message = "text";
TelegramBot bot = new TelegramBot(API_HASH);
try
{
Console.WriteLine(
bot.MakeRequestAsync(new NetTelegramBotApi.Requests.SendMessage(user, message))
.GetAwaiter()
.GetResult()
.From
.FirstName);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.Write(e.StackTrace);
Console.Write(e.InnerException);
}
Console.ReadLine();
It's sample of code. No exception, anything. Just doesn't work.
Hi,
What is the reason for use of this code?
bot.MakeRequestAsync(reqAction).Wait();
System.Threading.Thread.Sleep(500);
Hi,
today my bot not start and Gives the following error in this request (https://api.telegram.org/bot132020125:AAGkjcMkiYAg-NR3VPVyriP3ljheSqz1ZzI/getMe), i do not change any code ! is it possible telegram filter me?
when i enter url in my chrome i got this error : 504 Gateway Time-out , nginx/1.6.2
My error in c# :
StatusCode: 504, ReasonPhrase: 'Gateway Time-out', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: keep-alive
Date: Sun, 06 Sep 2015 17:40:10 GMT
Server: nginx/1.6.2
Content-Length: 182
Content-Type: text/html
}
I really want to develop a server-side interface for a bot using PowerShell.
The only difficulty I am facing is, I cannot load the library NetTelegramBotApi.dll.
It seems the entry point is not declared.
Thanks in advance.
Telegram team made some changes in API, marked as August 15, 2015:
Voice
and new method sendVoice
for sending voice messages.Audio
and sendAudio
should now be used for sending music files. Telegram clients will show such files in the in-app music player. If you were using sendAudio
for your bot to send voice messages, please use sendVoice
instead.performer
, title
to the Audio
object and sendAudio
method.voice
to the Message
object.Source: https://core.telegram.org/bots/api-changelog#august-15-2015
i wanna to send 10 or more message in one action to all my bot members, How do?
Hi,
How can i work and Analysis the photo that user sended in update.Message.Photo?
i want Analysis photo of user with QR code and return text.
thanks.
hi when I want to send file with UTF8 filename, don't show correct file name,
for example my file name is فارسی.docx but at reception user show filename like: =?utf-8?B?RDpcVXNlcnNcQXBhY2hpXERvY3VtZW50c1zYrdmF2K8g2YXYutix2KjZii5kb2N4?=
Поэтому тут иногда возникает ошибка:
if (update.Message.Text.Length % 2 == 0)
{
bot.MakeRequest(new SendMessage(update.Message.Chat.Id, "Вы отправили " + update.Message.Text.Length + " символов."));
}
else
{
bot.MakeRequest(new ForwardMessage(update.Message.Chat.Id, update.Message.Chat.Id, update.Message.MessageId));
}
Лучше сделать вот так:
if (update.Message.Text != null)
{
if (update.Message.Text.Length % 2 == 0)
{
bot.MakeRequest(new SendMessage(update.Message.Chat.Id, "Вы отправили " + update.Message.Text.Length + " символов."));
}
else
{
bot.MakeRequest(new ForwardMessage(update.Message.Chat.Id, update.Message.Chat.Id, update.Message.MessageId));
}
}
Bot API 2.3.1: deleteWebhook
moved out of setWebhook
to get a whole separate method for itself.
Hi,
How do I use the bot keyboard ?
Telegram team made some changes in API, marked as September 7, 2015:
parse_mode
addded to sendMessage
. For the moment messages with markdown will be displayed correctly only in Telegram for Android. Other official apps will catch up soon.Source: https://core.telegram.org/bots/api-changelog#september-7-2015
I think NetTelegramBotApi
does not have InlineQueryResultGame, if it has please help to create inline keyboard for games, this is not a bug exactly, but i think its an issue
thanks...
Please tell me how to send the media content to the message. For example, image
hi and thanks for your project
i want use keyboard and set with command .it means when click on keys send command whth \ but dont show in message this message have command .can you help me how i do it?
) Буду весьма признателен если все функции из users
будут доступны
Telegram team made some changes in API, marked as July 2015
thumb
field is now optional for Video
, Sticker
and Document
objectscaption
field has been removed from the Video
object and added to the Message
object instead.caption
and duration
optional fields have been added to the sendVideo
method.user_id
in the Contact
object is now correctly labeled as Integer, not Stringhi
how i can reply last message bot received?
Hi,
What is max length of text allow telegram to send ? 4096 UTF8 characters ?
hi, im running my bots with NetTelegramBotApi on a windows server 2008 R2
my robot is disabled after a short time which it is inactive and doesnt receive any pm
what do i do ?
i wanna to send message when a user left from group, How do?
Есть ли метод для парсинга готовый?
Hi
how use this to make Welcome Message for Groups or when some Body left Group or change name send A message to Group ?
Telegram team made some changes in API, marked as September 18, 2015:
getFile
and File
.Source: https://core.telegram.org/bots/api-changelog#september-18-2015
hi
when i use inlineKeyboard with Url is work
but when i use CallBackData it is not work and it doesnt send any message in bot?
how is it?
and please tell about CallBackQuery? thanks
it's my code
var reqAction = new SendMessage(update.Message.Chat.Id, "test") {
ReplyMarkup = new InlineKeyboardMarkup
{
InlineKeyboard = new[] {
new[] { new InlineKeyboardButton {
Text="test",
CallbackData="1"
}
}
}
}
};
bot.MakeRequestAsync(reqAction);
continue;
No error shown but it appears to have build errors when I try to start.
hi
i wanna implement invitation for my robot, users who using my bot can invite their friends with referrer code (userID) to my bot and i want to understand whos invited this new user to reward him.
like: https://telegram.me/my_bot?start=186643468
I cannot find this method
Hello
Pplease update your program API
telegram's API have some new tools but your bot api haven't them
i try to get audio and then send it as voice message.
for this,i download the audio by GetFile() and then convert it to .ogg then send it as voice message
by SendVoice()
But my robot send nothing !
help Please.
Hello
How can I forward a message from a channel in my bot?
I find ID of channel and messageId but when use forwardMessage request in (await bot.makeRequestAsynd(myReq)) has error.
Text Error:
Exeption: Exception thrown:
'NetTelegramBotApi.BotRequestException' in mscorlib.dll
("Request failed (status code 400): Bad Request: chat not found")
Hi,
when i want send pdf file this error accourd
Value cannot be null.
Parameter name: content
using (var docData = Assembly.GetExecutingAssembly().GetManifestResourceStream("TelegramBotDemo.test.pdf"))
{
var req = new SendDocument(update.Message.Chat.Id, new FileToSend(docData, "test.pdf"));
var msg = bot.MakeRequestAsync(req).Result;
uploadedDocumentId = msg.Document.FileId;
}
Telegram team made some changes in API, marked as August 29, 2015:
setWebhook
method.Source: https://core.telegram.org/bots/api-changelog#august-29-2015
Hi,
thanks for your good code.
i have 2 question :
1 - How do I use command with / in bot ?
2 - How do I use web hook?
hi
i want to work with webhook
i tried in console app and use of self signed certifacation bot i realy dont undrstand how to set it up
please help me
this is very important for me
help please ...
thanks
hi, i can send replymarkup keyboard but i wanna send inline buttons,
how i can send message with inline keyboard buttons ?
В общем даже не знаю зачем тут этот метод. Всегда возвращает null. Пробую загрузить картинку в Stream. По любому возвращает
{"ok":false,"error_code":400,"description":"Error: IMAGE_PROCESS_FAILED"}.
var data = Translit(city);
try
{
data = "D:\\123";
var reqAction = new SendChatAction(chat_id, "upload_photo");
bot.MakeRequestAsync(reqAction).Wait();
System.Threading.Thread.Sleep(500);
System.Drawing.Image image = Image.FromFile(string.Format("{0}.png", data));
using (MemoryStream stream = new MemoryStream())
{
// Save image to stream.
image.Save(stream, ImageFormat.Bmp);
using (var photoData =Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format("{0}.png", data)))
{
var req = new SendPhoto(chat_id, new FileToSend(stream, string.Format(".png", city)))
{
Caption = "Telegram_logo.png"
};
var msg = bot.MakeRequestAsync(req).Result;
uploadedPhotoId = msg.Photo.Last().FileId;
}
}
}
Hi, I've just updated an old application using NetTelegramBotApi, and I would like to trigger a message to every user of my bot informing them about the changes and new functionalities. Is there a way I can do that without the need of expecting the user to start a conversation ?
thanks!
Hi,
Do you know how to send message in telegram with phone number or username ?
hi
i want to send bitmap variable type as a photo by NetTelegramBotApi:
Bitmap bmp;
using (var photoData = Assembly.GetExecutingAssembly().GetManifestResourceStream("InstagramPuzzleBot.Resources.sample.png"))
i want to send bitmap contents, what should i write instead of : Assembly.GetExecutingAssembly().GetManifestResourceStream("NetTelegramBotApi.t_logo.png
?
i used this bug i got error:
Stream mms = new MemoryStream();
Bitmap bmp = makePuzzle(address, ID); //function with bitmap return type
bmp.Save(mms, System.Drawing.Imaging.ImageFormat.Bmp);
var reqAction = new SendChatAction(update.Message.Chat.Id, "upload_photo");
bot.MakeRequestAsync(reqAction).Wait();
System.Threading.Thread.Sleep(500);
using (var photoData = mms)
{
var req = new SendPhoto(update.Message.Chat.Id, new FileToSend(photoData, "sample.png"))
{
Caption = "samplephoto"
};
var msg = bot.MakeRequestAsync(req).Result;
SamplePhotoID = msg.Photo.Last().FileId;
}
Bot API 2.3.1: Use the new field max_connections
in setWebhook
to optimize your bot's server load
Please,
I am trying use the Timeout property in the MakeRequestAsync to call GetUpdates but don't work. And I went to see the source code and not finded the property in the function.
She is used? My internet is unstable and I receive errors in all the time.
Thanks!
В демо примере подсказок не нашел.
if (text == "/Погода")
{
bot.MakeRequestAsync(new SendMessage(update.Message.Chat.Id, "Введите название города в котором хотите посмотреть погоду.")).Wait();
// Как сделать так чтобы он ждал отправки текста?
System.Threading.Thread.Sleep(500);
if (text != "")
{
....
}
hi
can i set icon for keyboard buttons like some bots ?
Hi,
When i want to send document in line var msg = bot.MakeRequestAsync(req).Result; i have error :
One or more errors occurred. (How to see the original error?)
my file is pdf and size is 1.7 mb !!!
this is my code , it happens with file 1.7 mb only !!! for 500 k is ok ! please help me
using (var docData = File.OpenRead(FilePath))
{
var req = new SendDocument(update.Message.Chat.Id, new FileToSend(docData, Path.GetFileName(FilePath)));
var msg = bot.MakeRequestAsync(req).Result;
uploadedDocumentId = msg.Document.FileId;
}
the new InlineKeyboardMarkup is not implemented
also the callback_query option is missing
great job! just missing some new stuff
how i can make keyboard for it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.