Skip to content

Instantly share code, notes, and snippets.

@bitbonk
Created November 17, 2022 16:23
Show Gist options
  • Save bitbonk/f18fe5109c2a26ca83ea22e800730f2e to your computer and use it in GitHub Desktop.
Save bitbonk/f18fe5109c2a26ca83ea22e800730f2e to your computer and use it in GitHub Desktop.
Using Masto.NET in Azure Functions
public class RepostOnMastodon
{
private readonly AuthenticationClient client;
public RepostOnMastodon()
{
this.client = new AuthenticationClient("something.social");
}
[FunctionName("RepostOnMastodon")]
public async Task Run([TimerTrigger("* * * * *")] TimerInfo myTimer, ILogger log)
{
var appRegistration =
await this.client.CreateApp("[email protected] reposter", Scope.Read | Scope.Write | Scope.Follow);
var auth = await this.client.ConnectWithCode("mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx6kg");
var mastoClient = new MastodonClient(appRegistration, auth);
var result = await mastoClient.PostStatus($"Hello, current time is {DateTime.Now}", Visibility.Direct);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment