Skip to content

Activities

Nill edited this page Sep 9, 2021 · 4 revisions

An Activity is an object representing certain activities or processes that warrant either providing additional data to the current Context (such as access to the underlying HttpContext for a web request, or access to network information in an MTProto handler) or warrant rich auditing.

The Activity property of Context can be used to access the current activity, if there is one.

public async Task TestCommand(Context c, EventArgs e)
{
	if (c.Activity is UpdateActivity ua) {
	    HTML msg = ua.UpdateReceivedVia switch
	    { 
	       UpdateReceivedVia.Polling => "We are polling",
	       UpdateReceivedVia.Webhook => "We are using webhooks",
	       _ => "We can't tell"
        };
        await c.SendReply(msg);

	}
}

Clone this wiki locally