brandonpoc 4 Posted October 7, 2018 Report Share Posted October 7, 2018 I decided to try my hand at extending uBot functionality and write a plugin. I'm writing a Redis database plugin to allow interfacing with the server, set/get'ing, etc; however, uBot is not able to load the plugin because, I assume, the DLL provided (installed by "nugat", a package manager for .Net that installs assemblies) isn't being found. After snooping on system calls I see uBot is trying to access a key in the registry with the assembly DLL in the name, but not looking for the DLL file in any capacity. I would assume that the function(s) being used from the assemblies would get included into the uBot plugin DLL at time of compile, but this apparently isn't the case. Anyone have any idea? I used the IL disassembler on things like the Spintax plugin and notice that it is using some JSON DLL and is not packaged with that DLL but instead several of the references to it are included in the DLL itself. How do I do this with .Net, or what am I missing? I am not a Windows developer, I'm a UNIX/Linux developer, so the way Visual Studio and these assemblies for C# work confuses me a bit. ThanksBrandon Quote Link to post Share on other sites
HelloInsomnia 1103 Posted October 7, 2018 Report Share Posted October 7, 2018 If you want to use a nuget package try this: https://github.com/Fody/Costura Basically, when you compile your DLL for the plugin this is going to stick any dependencies in there with it so you end up with a single DLL. 1 Quote Link to post Share on other sites
brandonpoc 4 Posted October 8, 2018 Author Report Share Posted October 8, 2018 Thanks, going to give it a try! I have several other plugin-related queries as well, being that the Plugin development page on the Wiki while being somewhat informative and describes the interfaces and implementation to each class, isn't too clear on how they all work together and to the uBot program itself, and the examples of source code available of actual working plugins are somewhat lacking. For instance, for my plugin I intend on having it work like this: 1) Create a redis connection (returned by function, assigned by variable); this will be an instantiated object that is unique to a third-party assembly/DLL. Do I just return this as a UBotTypes.UBotVariable (or whatever it is) or is there some other variable type? I see integer, list, variable and string. I assume variable.. ? 2) The Redis routines will then all operate with that returned connection as its server parameter, so this is assuming the instance stays open after the functions exit etc and that uBot doesn't do anything to it. The user will need to pass that variable into the other redis functions, implemented as functions themselves, with return variables stating different types of errors. I will implement a special function that interprets errors. Are there any additional in-depth documentation for plugin development or source available for more advanced uBot Plugins than the defaults? Thanks Quote Link to post Share on other sites
HelloInsomnia 1103 Posted October 8, 2018 Report Share Posted October 8, 2018 One day I'd like to make videos talking about plugin dev but it's in a very long list of other videos so I can't say when it will happen. But to try and answer your questions you probably have to house things like a connection object on the plugin side, you can't return something like a connection object to Ubot because Ubot is only going to support strings for the most part. So what you could do is create a static class to hold the connection - or you could create a container command - or you could have a static dictionary as well to hold multiple connections probably. I'm typing this all off the top of my head so while I'm pretty sure any of these will work you will have to test them to be sure. A user could call a plugin command to initially set properties of a static class (which could have the connection) and then when the user calls another plugin command to set or get data the static class could be used for the connection parameter. Quote Link to post Share on other sites
brandonpoc 4 Posted October 8, 2018 Author Report Share Posted October 8, 2018 (edited) Is doing all of that statically thread-safe for uBot, as long as the functions themselves are thread safe? And do you know of any examples of plugins that the source is avaialble for that do something similar- such as a SQL database plugin or something? Thanks Edited October 8, 2018 by brandonpoc Quote Link to post Share on other sites
brandonpoc 4 Posted October 8, 2018 Author Report Share Posted October 8, 2018 (edited) Costura worked, *after* the nightmare of getting it to work properly with VS Studio 2015. I'm not sure what the deal is but it couldn't compile the right version, and then when I'd try to switch versions, the previous ones info would be embedded in the metadata of the project and I'd have to start a new one. Apparently the MSBuild format for the project isn't right on the latest version of Costura. So, to help people out - if you need Costura.Fody to work w/ VS Studio .Net 2015 (or if it's giving you the MSBuild XML errors anywhere else), try this: Make sure you have .Net 4.7.2 installed and that you have .Net 4.7.2 target set for your project. Install Nugat and all that. Open the package manager console in VS Studio (not the GUI, but the command line one), to add nugat packages to the current solution; "Install-Package -Version 3.1.0 Costura.Fody" This will install the older 3.1.0 of Costura. Do not do the Update-Package Fody thing that it recommends. Now, create a new text file in your project called "FodyWeaver.xml", and put this: <?xml version="1.0" encoding="utf-8" ?><Weavers> <Costura/></Weavers> That will tell it to load Costura when it "weaves" the assembly. Now, all the Assembly DLLs, including the UBot Studio plugin DLL, will be included in the output DLL instead of having to distribute them in a separate folder and all that. This was required to get my StackExchange.Redis.dll assembly properly included. .net is a nightmare. Regards Edited October 8, 2018 by brandonpoc Quote Link to post Share on other sites
HelloInsomnia 1103 Posted October 8, 2018 Report Share Posted October 8, 2018 There are no good examples that I know of sorry, and for threading it's probably something again I'd need to make videos explaining because it depends on how you set things up. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.