STEAM GROUP
Archi's SC Farm Archi-ASF
STEAM GROUP
Archi's SC Farm Archi-ASF
68,628
IN-GAME
455,011
ONLINE
Founded
October 29, 2015
Language
English
All Discussions > 💬 General > Topic Details
Rstuff Jun 19, 2019 @ 10:46am
Help with creating plugin
I am working on an ASF plugin for personal use. I am a very inexperienced programmer however I'm done with the plugin basics and even have most of the logic for the functionality that I want to be used but I still need some function/method calls if they exist in ASF that I couldn't find, such as:
  • Creating a new custom trade offer to the master with specified app/inventory ID and asset IDs.
  • I also want to check some things through the Steam Web API for the master account so it would be nice if there would be a way to get the Web API Key for the given bot (and the master's SteamID64).
  • Starting and ending a game Idling and then if there is nothing to farm then a logoff/disconnect/close bot call.
  • Back to trading: How can I check in a received trade offer what are the items requested and offered, preferably by asset ID so I can decide by my logic if it is acceptable or not.

My main goal would be to completely automate everything with ASF so that I won't even have to login the bot's account for my shenanigans.
So can anyone help me with these? Do these methods exist or can I somehow achieve such things?
Did I entirely misunderstand the purpose of plugins?
< >
Showing 1-15 of 19 comments
Rudokhvist Jun 19, 2019 @ 12:01pm 
Originally posted by Rstuff:
  • Creating a new custom trade offer to the master with specified app/inventory ID and asset IDs.
I guess you need to get inventory with Bot.ArchiWebHandler.GetInventory, form an array of items you want to send and then use Bot.ArchiWebHandler.SendTradeOffer

Originally posted by Rstuff:
  • I also want to check some things through the Steam Web API for the master account so it would be nice if there would be a way to get the Web API Key for the given bot (and the master's SteamID64).
What do you mean by "master account" in this case? Do you mean just one of the bots that you specified or what? Not "master" user permission in terms of ASF, right? In this case I suggest you to check existing methods of ArchiWebHandler and select the one that suits best for you.
To disconnect bot just stop it with Bot.Actions.Stop.

Originally posted by Rstuff:
  • Starting and ending a game Idling and then if there is nothing to farm then a logoff/disconnect/close bot call.
That's probably the most hard thing to do with plugins. Of course you can re-implement whole farming module, or use commands like "play" to emulate this behaviour, but if first case it may be hard (if even possible, I'm unsure), and in second case - weird. Depends

Originally posted by Rstuff:
  • Back to trading: How can I check in a received trade offer what are the items requested and offered, preferably by asset ID so I can decide by my logic if it is acceptable or not.
You have IBotTradeOffer plugin api endpoind for that.


Originally posted by Rstuff:
Did I entirely misunderstand the purpose of plugins?
It seems you want to make asf a full fledged steam bot. In most cases it's possible, but it's definitely not the purpose of plugins, plugins are supposed to extend functionality of ASF, not change the existing behaviour. In your case I guess it would be easy to start from scratch, or mabe fork ASF and change it for your needs. But that's just my opinion of course.
Archi Jun 19, 2019 @ 12:35pm 
Ryzhe explained majority of ASF API for you above, I'd only add that for second thing you have AWH (ArchiWebHandler) and its Url* methods for sending any request you want, for third thing you need to implement your own idling module, as you can most certainly tell ASF to play the game (either through command or a request), but ASF will not have any more logic than that, unless you use my module for cards idling.

And contrary to ryzhe's statement above, I believe ASF plugin is the best place you can pick in order to convert ASF into your own personal bot without much hassle, it only takes a bit of willings and time to explore what ASF offers you in terms of internal API, or alternatively if you decide you're not satisfied with it, you can always re-implement everything you need in your own way, ASF puts no limits on what your plugin can do. Writing a plugin to make ASF do what you want is most certainly much easier than forking the project or rewriting ASF core, especially if you're just starting.

And if you didn't yet, see my example plugin[github.com] which shows a bit of potential usage.
Last edited by Archi; Jun 19, 2019 @ 12:40pm
Rstuff Jun 19, 2019 @ 3:33pm 
Thank you both for the answers and the help.
At first it was so overwhelming and I was so confused but now I have an idea of how and where to start.
It may take a very long time to realize what I planned but I have high hopes with my ASF project.

Thanks again Ryzhehvost and of course thanks to the great Archi
Archi Jun 19, 2019 @ 4:59pm 
It's always overwhelming at first but as a plugin creator you have access to what others do not - ASF codebase. Vast majority of whole API you have access to (like fetching inventory, sending trade offer, sending AWH requests and likewise), ASF is using itself for its own functionality, which you can look up and see how ASF is using its own API, and then you can also relate how your plugin can make use of the same.

For example, here[github.com] is a function that joins a group, which ASF uses for statistics module. You can see that it uses UrlPostWithSession() to achieve the goal, and you have access to the same function. Nothing stops you from sending some other request through the same way. If you dig deeper, you'll see that every functionality that operates on Steam community is using the same thing, with small modifications for appropriate request and data needed.

The difficult part is learning basics of C# language, what ASF API offers and what you need to do in order to achieve something with Steam. Despite of it looking like a lot, I can assure you that it's MUCH less than what you'd need to learn if you wanted to code something like ASF from scratch, because apart from the above which you'd need to master in far higher lever, the amount of knowledge, low-level things, hacks and workarounds that I have in ASF goes far beyond what you need to understand in order to have a nice experience with ASF API as a plugin. It's not worth the time and effort to reinvent the wheel, unless you want to actually learn something in the process, but then again nothing stops you from doing the same AND spending time productively, on something that is actually useful instead of being a copy of something that already works.

I recommend to dig into ASF source code for examples of how I managed to achieve particular things, it's one of the most complex and complete examples of Steam platform integration for bot-like usages, and plugins allow you to make use of everything I've created and further extend it to your liking. Even if you completely disagreed with over 90% of my functions and implementations, you'd still save your time on 10% that you agree with, and you'd need to re-implement remaining 90% anyway, whether in your own standalone program or ASF plugin, except in your own standalone program you'd need to implement far more to make it work in the first place, while as ASF plugin you're saving on all the hassle that you don't need/want to reimplement yourself, and you most likely don't want to write authentication, session logic, redirections and all other stuff I had to write before you.

It's much easier to write a plugin that modifies ASF, rather than modifying ASF source code to do something else. You can still do the second, but you need to put far more effort and have far better understanding for that, and unless you want to write another ASF from scratch, there is next to no reasoning for going this way.
Last edited by Archi; Jun 19, 2019 @ 5:05pm
Rstuff Jul 7, 2019 @ 4:22pm 
Hey it's me again. I'm progressing slowly but surely thanks to you and in fact I am nearing the end of my first project (which would be a selective card forwarding plugin depending on the master's badge progress) but I encountered a little problem.

As Ryzhehvost told me I need to use Bot.ArchiWebHandler.SendTradeOffer to create a trade offer, however I cannot access this method. As I see in the source files this method is not public but internal. The only public SendTradeOffer method I found was in Bot.Actions but that's not what I need, right?

How can I use the ArchiWebHandler.SendTradeOffer method without me "forking" the program?
Last edited by Rstuff; Jul 7, 2019 @ 4:26pm
Archi Jul 8, 2019 @ 3:43am 
https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Plugins#api-availability

We have a very open policy in terms of our API availability, so if you'd like to make use of something that ASF code already includes, simply open an issue and explain in it your planned use case of our ASF's internal API. We most likely won't have anything against, as long as your use case makes sense. It's simply impossible for us to open everything that somebody would like to make use of, so we've opened what makes the most sense for us, and waiting for your requests in case you'd like to have access to something that isn't public yet. This also includes all suggestions in regards to new IPlugin interfaces that could make sense to be added in order to extend existing functionality.

I've opened that method for you, so simply update to latest ASF source tree and you'll be able to make use of it.
Rstuff Jul 8, 2019 @ 9:34am 
Originally posted by Archi:
https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Plugins#api-availability

I've opened that method for you, so simply update to latest ASF source tree and you'll be able to make use of it.

I cannot thank you enough Archi.

I knew about the API availability, I was just curious if there is a tricky way that I don't know of to access that method, as I am using the latest release's DLL as reference.
Now my question is even if I (somehow) change the reference from the DLL to the source tree and create the plugin it won't work with the latest ASF release, would it?
Rudokhvist Jul 8, 2019 @ 10:20am 
You'll just have to wait until next ASF version released, it will have the methods you need public. Until then you can use self-compiled asf version (or use the latest one and develop basing on self-compiled, if your plugin is not ready yet).
Archi quoted wiki for you to tell you that next time, if you need some method, you can just create issue on github with needed API and reasons why you need it, this way Archi will not miss it.
Good luck with your plugin.
Archi Jul 8, 2019 @ 12:34pm 
Originally posted by Rstuff:
Now my question is even if I (somehow) change the reference from the DLL to the source tree and create the plugin it won't work with the latest ASF release, would it?

Yes, you'll need to wait for the next version with that commit to be released, which is V4.0.3.1. That however doesn't mean you can't work with it immediately, check release cycle wiki entry and my latest appveyor builds if you'd like to have it right away.
Rstuff Jul 8, 2019 @ 4:05pm 
Originally posted by Archi:
check release cycle wiki entry and my latest appveyor builds if you'd like to have it right away.
That is exactly what I did. At first I tried to compile it myself but man I got a lot of errors and after a long time not being able to fix one of those errors I gave up. Then I remembered I read something about the release so I went back and read the wiki and found the appveyor build. I tested it right away and it works.
So thanks again Archi.


Originally posted by Ryzhehvost:
Good luck with your plugin.
Thank you too Ryzhehvost.

Thank you both for beeing patient with me and my stupid questions. :steamhappy:
Rudokhvist Jul 8, 2019 @ 10:17pm 
Originally posted by Rstuff:
At first I tried to compile it myself but man I got a lot of errors and after a long time not being able to fix one of those errors I gave up.
Rule of thumb - if you have a troubles - read wiki: https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Compilation
Rstuff Jul 13, 2019 @ 9:30am 
I want to ask you to bear with me just a little bit more, please. I am really one step away from the plugin creating singularity. :cleanseal:

However I've got a tiny little bit of problem again, that I am not entirely sure it is a plugin related problem because I encountered a similar case before I even thought about plugins.

So the case was: I set up in the bot configuration
"SendOnFarmingFinished": true,
"ShutdownOnFarmingFinished": true,
but one time ASF didn't send the cards after farming, as I thought it disconnected the bot before it being able to create the trade offer. I didn't bother with it and the next time I ran ASF everything worked as intended.

Back to the plugin: I have some tasks in the code including the GetInventory method, for which I use the await operator and that made me change the whole OnBotLoggedOn to an async method. I hope that's not a problem, or is it?
Even so with the ShutdownOnFarmingFinished set to true ASF disconnects the bot before it reaches the end of the plugin's OnBotLoggedOn method. That's as far as I know because there are tasks that take longer time and I saw on the console/log that BOT OnDisconnected() happened before it got to the OnBotLoggedOn() GetInventory failure.

If I set ShutdownOnFarmingFinished to false, then everything works properly but I don't want to run the bot without any purpose.
Is there a way to make ASF wait for the plugin run before it disconnects or there is nothing I can do?
Last edited by Rstuff; Jul 13, 2019 @ 9:32am
Archi Jul 13, 2019 @ 12:23pm 
Nothing you can do, your plugin can't influence ASF to wait for it. You should instead make appropriate config, optionally add extra setting (such as MyPluginShutdownAfterFinished) and then shutdown yourself.
Rstuff Jul 13, 2019 @ 4:51pm 
Then that's that. Thanks again and again.

Who knows I may write a plugin to monitor my other plugins. lol
Rstuff Dec 18, 2019 @ 9:03am 
Can I still ask some more questions? :)

I had my plugins working fine and now that it became necessary and I have a little time, I'm trying to upgrade from netcore2.2 to 3.1. What I first did is that I updated the referenced ArchiSteamFarm.dll to the latest release's and now I have some error on asf methods, fields and whatnot saying:
"The type * is defined in an assembly that is not referenced. You must add a reference to assembly System.Private.CoreLib ...".
What is this? Why is it needed now? What should I do?

I also have some not so important questions:
Is there a public bool or other method to know if the bot is farming right now or started farming?
I'm asking this because I want to pause/stop/terminate the plugin if this happens or if bot disconnects.
Also is there an easy way to terminate the plugin mid-process if needed? I read I can achieve something like this with Actions but I didn't dig deep into it yet.
< >
Showing 1-15 of 19 comments
Per page: 1530 50

All Discussions > 💬 General > Topic Details