FAQ - WolfLive.Api and Wolfringo
WolfLive.Api is one of unofficial WOLF libraries, developed by Alec.
In this FAQ article, I explain some differences between WolfLive.Api and Wolfringo, to make Wolfringo easier to use for anyone who used WolfLive.Api in the past.
Will Wolfringo work with same framework versions as WolfLive.Api?
Yes! Both Wolfringo and WolfLive.Api target .NET Standard 2.0, so in theory they should support exactly same framework versions.
Can I use Dependency Injection?
WolfLive.Api supports Dependency Injection using <xref:System.IServiceProvider>. This allows sharing dependencies and services in a testable manner.
Wolfringo does the same. In fact, Wolfringo is designed with Dependency Injection in mind, especially its Commands System!
Feel free to check Dependency Injection guide for more information.
Do I need to manually register Wolfringo Commands Handler?
WolfLive.Api requires command classes to be manually registered in Program.cs.
Wolfringo doesn't require you to register them manually if they are marked with [CommandsHandler] attribute. Manual registration is needed only if you don't add the attribute, or remove starting assembly from automatic loading. See Enabling Commands guide for more information.
Does Wolfringo Commands Handler have a class to inherit from?
WolfLive.Api has an option for command classes to inherit from WolfContext
. This is a short-hand to access command context - such as Message, Client etc.
Wolfringo does not have such class to inherit from. Because of this, your class won't have any command-related properties out of the box. But don't worry - you can access a CommandContext easily by using Command Parameters.
Do Wolfringo Commands allow requiring permission, or work in group only?
WolfLive.Api allows restricting commands execution using attributes (called Filters). WolfLive.Api also allows you to create your own filters.
Wolfringo is no different in that regard! Feel free to check Commands Requirements guide for more details.
Can I do something on certain non-message events?
WolfLive.Api allows you to design EventTemplates and add them as a listener to a string-identified event.
Wolfringo allows you to do that as well, and works pretty similar - but you do not need to create your own event template. Wolfringo's IWolfClient has a special AddMessageListener<T>(delegate) method, where T is any IWolfMessage. Using this method, you can add event listener to any message type, and it'll be triggered whenever a message of that type is received by the client.
_client.AddMessageListener<GroupUpdateEvent>(OnGroupUpdated);
private async void OnGroupUpdated(GroupUpdateEvent message)
{
// do something here
}