BEFORE YOU GET STARTED: This bot requires you use git to download the bot. Downloading the zip will not work! It doesn't work because the bot uses git submodules, which are not included with the zip download.
SteamBot is a bot written in C# for the purpose of interacting with Steam Chat and Steam Trade. As of right now, about 8 contributors have all added to the bot. The bot is publicly available under the MIT License.
If you've just recently cloned this repository, there are a few things you need to do in order to build the source code.
- Run
git submodule init
to initalize the submodule configuration file. - Run
git submodule update
to pull the latest version of the submodules that are included (namely, SteamKit2).
- Since SteamKit2 is licensed under the LGPL, and SteamBot should be released under the MIT license, SteamKit2's code cannot be included in SteamBot. This includes executables. We'll probably make downloads available on GitHub.
- Open
SteamBot.sln
in your C# development environment, either MonoDevelop or Visual Studio should work. - Build the program.
-
First, you need to configure your bots. This is done by creating a
settings.json
file located in the same place as the SteamBot executable. -
There is a template settings file provided for you. Edit the file
settings-template.json
inproject_root\Bin\Debug
. Some configuration options:Admins
: An array of Steam Profile IDs of the users that are an Admin of your bot(s). Each Profile ID should be a string in quotes and seperated by a comma. These admins are global to all bots listed in theBots
array.ApiKey
: The API key you have been assigned by Valve. If you do not have one, it can be requested from Value at their Web API Key page. This is required and the bot(s) will not work without an API Key. The API Key should be a string in quotes.mainLog
: The log containing runtime information for all bots.Bots
: An array of dictionaries containing information about each individual bot you will be running. You can run multiple bots at the same time by having multiple elements in theBots
array. Each entry in theBots
array consists of the following values:Username
: The Steam user name for this bot. It should be a string in quotes. (required)Password
: The password for the Steam user associated with this bot. It should be a string in quotes. (required)DisplayName
: The name the bot will present on Steam. It should be a string in quotes. (required)ChatResponse
: This is the response the bot will provide when a user chats with it via Steam Friends. It should be a string in quotes. (required)logFile
: The log file for this specific bot. It should be a string in quotes. (required)BotControlClass
: The fully qualified class that controls how this specific bot will behave. Generally, this is a seperate file (ie.SimpleUserHandler.cs
) and has the same name as your class (without the trailing.cs
extension). It must be the fully qualified class (ie.SteamBot.SimpleUserHandler
). It should be a string in quotes. (required)Admins
: Additional admins, specific to this bot. (optional)MaximumTradeTime
: Maximium length of time for a trade session (in seconds). It should be a numeric value. Defaults to 180 seconds. (optional)MaximumActionGap
: Length of time the bot will allow the user to remain inactive. It should be a numeric value. Defaults to 30 seconds. (optional)DisplayNamePrefix
: A prefix to display in front of the DisplayName. It should be a string encloded by quotes. Defaults to an empty string. (optional)TradePollingInterval
: Length of time, in milliseconds, between polling events. Higher values reduce CPU usage at the cost of a slower trading session. It should be a numeric value. Default is 800 ms. Lowest value is 100 ms. (optional)LogLevel
: Detail level of bot's log. In order from most verbose to least verbose, valid options are:Debug
: Information that is helpful in performing diagnostics.Info
: Generally useful information such as start/stop, polling events, etc. (default)Success
: Events that have completed in an expected manner.Warn
: Potential application problems, but which have been automatically handled.Error
: Event that prevents the bot from continuing to function without corrective action.Interface
: Events that require user interaction, such as entering a Steam Guard code to complete a login.Nothing
: A log level that surpresses all previous levels. (not recommended)
-
Rename
settings-template.json
tosettings.json
- Next you need to actually edit the bot to make it do what you want.
- You can edit the files
SimpleUserHandler.cs
orAdminUserHandler.cs
as they contains examples of most everything you need. Alternatively, you can subclassUserHandler
and create your own class to control bot behavior. If you do this, remember to modify theBotControlClass
setting in your configuration. Add your code to each of the events. Events are explained in code comments. - Look at the section below to see some useful information if you intend to create your own
UserHandler
.
- Run the SteamBot executable.
- Open your operating systems console or command prompt.
- Run the executable (SteamBot.exe under Windows). After a successful build it should be under
<project_root>\Bin\Debug
by default.
In order to fully customize your bot you are going to want to create a class that inherits from SteamBot.UserHandler
. This class is an abstract base class that provides several methods that must be overridden in order to work. These methods are mostly reactionary in nature, i.e. what to do when the bot has been proposed a trade or sent a message. These explained well in UserHandler.cs
code comments. Here is a basic run-down of what's available to your subclass if you decide to do this.
Returns true
if the other user interacting with the bot is one of the configured Admins. See settings.json format above.
The Log
class for the Bot that you can use this to output important information to the console you see on the screen.
The Bot
instance for the bot the user handler is running for. You can use this to access some advanced features of the Bot like the Steam Friends system below.
Send a chat message to the specified user (by steam id).
Add a friend by steam id.
Remove a friend by steam id.
Most of the trade interaction will occur through the abstract methods that you will have to implement as a subclass. These are mostly Trade events that happened outside of the Bot. For example OnTradeAddItem
is called when the other user adds an item to the trade window. In this function your class could add equal, lesser, or greater value items (or send the user a nasty message about low-balling). To do this you will have to interact with the trade via the UserHandler.Trade
object described below.
Add an item by its id
property into the next available slot in the trade window.
Same as AddItem, but you specify the defindex of the item instead of the id.
Removes the specified item from the trade window.
Sets the trade ready-status depending on the ready
parameter. true
to set the bot's status to ready.
Calling this method accepts the trade. It's the second step after both parties ready-up.
Sends a message to the other user over trade chat.
If it's a bug, open an Issue; if you have a fix, read CONTRIBUTING.md and open a Pull Request. A list of contributors (add yourself if you want to):
- Jessecar96 (project lead)
- geel9
- Dr. Cat, MD or redjazz96
- cwhelchel
SteamBot is licensed under the MIT License. Check out LICENSE for more details.
Please read CONTRIBUTING.md.