Coder Social home page Coder Social logo

telegrambots / telegram.bot.extensions.polling Goto Github PK

View Code? Open in Web Editor NEW
45.0 11.0 12.0 156 KB

Provides ITelegramBotClient extensions for polling updates

License: MIT License

C# 100.00%
telegram telegram-bot telegram-bot-api update-polling

telegram.bot.extensions.polling's Issues

ReceiverOptions parameter name mismatch

Update Streams are not supported in QueuedUpdateReceiver

CS8411
Asynchronous foreach statement cannot operate on variables of type 'QueuedUpdateReceiver'
because 'QueuedUpdateReceiver' does not contain a suitable public instance or extension definition 
for 'GetAsyncEnumerator'

I get this error when I try to use update streams as shown in an example in README.md

My project runs .NET 5, package version is latest atm (0.2.0)

Handling Concurrency Conflicts

Hi everyone. I have one problem with Handling Concurrency Conflicts.
I have two project and they work parallel but i have that error:

Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded.

How can i solve this problem?

handle million of users

Hi there,

how to handle the load of million of users' messages and process them all without speed lag?

botClient.StartReceiving(
HandleUpdateAsync,
HandleErrorAsync,
receiverOptions,
cancellationToken: cts.Token);

I've used new thread initialization in HandleUpdateAsync and all of my backend services are async, but I have critical speed problems in busy times.

ThrowOutPendingUpdatesAsync should have 0 timeout

ThrowOutPendingUpdatesAsync should have 0 timeout to receive and skip only existing updates. Now it'll wait for a few seconds if there are no pending updates and could skip new updates:

var timeout = (int) botClient.Timeout.TotalSeconds;
var request = new GetUpdatesRequest
{
Limit = 1,
Offset = -1,
Timeout = timeout,
AllowedUpdates = Array.Empty<UpdateType>(),
};
var updates = await botClient.MakeRequestAsync(request: request, cancellationToken: cancellationToken)
.ConfigureAwait(false);

what is ReceiveOptions?

Hey,

maybe it will be obvious, but just following your Readme compile tells me that ReceiveOptions does not exist in the current context without any resolution. Can you please advise?

Add cancellation token to YieldUpdatesAsync

Current implementation doesn't allow the following common pattern:

await foreach (var update in receiver.YieldUpdatesAsync().WithCancellation(cancellationToken))
{
    // ... 
}

To allow this to work YieldUpdatesAsync needs to have cancellation token as a parameter with an attribute:

public interface IYieldingUpdateReceiver
{
    int PendingUpdates { get; }
    IAsyncEnumerable<Update> YieldUpdatesAsync([EnumeratorCancellation] CancellationToken cancellationToken = default);
}

This will allow uniform cancellation support in IYieldingUpdateReceiver implementations instead of ad-hoc params in different implementations.

Add client parameter to IUpdateHandler

I think it's a good idea to add ITelegramBotClient as the first parameter in IUpdateHandler.HandleUpdate. This way you don't need to capture a reference to the client with DefaultUpdateHandler.

It will break the interface, but it's fine since the library is still effectively in preview.

Connection to database

I have a problem when I try connect to database with telegramBot:

System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Object name: 'ApplicationContext'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.