Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds CONTRIBUTING.md

  • Loading branch information...
commit 0681fb8c8898a865d6c0a46df4b68a6b1809ddf1 1 parent 09c845e
Jeremy Rodi medcat authored
30 CONTRIBUTING.md
View
@@ -0,0 +1,30 @@
+# Contributing to SteamBot #
+When you're contributing to SteamBot, there are a few rules you should follow. First and foremost, SteamBot should be able to compile and run on Linux. SteamBot development works in both Visual Studio and MonoDevelop, but _please_ keep your temporary files (such as `.pidb`, `.*~`, or even `.tmp`) out of the project.
+
+## How To Contribute ##
+1. Fork The Repository ([Jessecar96/SteamBot](https://github.com/Jessecar96/SteamBot))
+2. Branch It
+ - this is because when you do the pull request for it, it includes commits you make after you make the pull request and before the pull request is accepted
+3. Make Your Changes
+4. Commit Your Changes
+5. Do 3 and 4 as Needed
+6. Push Your Changes Back to GitHub
+7. Start a Pull Request on the Repository
+ - make sure you explain what the pull request does
+
+## Indentation ##
+With SteamBot, you should use four (4) spaces as an indent; tabs should not be used as indentation ever. This comes from
+Microsoft's [C# Coding Conventions](http://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx) (thank you, Philipp). It gets annoying when you have both in there, and it clogs up commit logs trying to fix it.
+
+## Brackets ##
+Brackets should be on the next line of a function definition or an if directive. Brackets should always be on their own line.
+
+## Issues ##
+Make sure you
+- Describe the problem
+- Show how to reproduce it, if applicable
+- Explain what you think is causing it, if applicable
+- Give a plausible solution
+
+## Commits ##
+Commits should be in the present tense, and with Title Capitalization. If needed, a body should be on the next line in normal capitalization.
10 README.md
View
@@ -42,6 +42,12 @@ Accepts the trade.
ends a message to the other user over trade chat.
## More help? ##
-If it's a bug, open an Issue; if you have a fix, open a Pull Request. If you have questions or comments, contact <http://steamcommunity.com/id/jessecar>.
+If it's a bug, open an Issue; if you have a fix, open a Pull Request. A list of contributors (add yourself if you want to):
+ - [Jessecar96](http://steamcommunity.com/id/jessecar) (project lead)
+ - [geel9](http://steamcommunity.com/id/geel9)
+ - [Dr. Cat, MD or redjazz96](http://steamcommunity.com/id/redjazz96)
-SteamBot is licensed under the MIT license. Check out LICENSE for more details.
+SteamBot is licensed under the MIT license. Check out LICENSE for more details.
+
+## Wanna Contribute? ##
+Check out CONTRIBUTING.md.
23 SteamBot/Bot.cs
View
@@ -119,10 +119,13 @@ void HandleSteamMessage (CallbackMsg msg)
msg.Handle<SteamUser.LoginKeyCallback> (callback =>
{
while (true) {
- if (Authenticate (callback)) {
+ if (Authenticate (callback))
+ {
PrintConsole ("Authenticated.");
break;
- } else {
+ }
+ else
+ {
PrintConsole ("Retrying auth...", ConsoleColor.Red);
Thread.Sleep (2000);
}
@@ -154,7 +157,8 @@ void HandleSteamMessage (CallbackMsg msg)
//Type (emote or chat)
EChatEntryType type = callback.EntryType;
- if (type == EChatEntryType.ChatMsg) {
+ if (type == EChatEntryType.ChatMsg)
+ {
PrintConsole ("[Chat] " + SteamFriends.GetFriendPersonaName (callback.Sender) + ": " + callback.Message, ConsoleColor.Magenta);
//string message = callback.Message;
@@ -196,7 +200,8 @@ void HandleSteamMessage (CallbackMsg msg)
msg.Handle<SteamClient.DisconnectedCallback> (callback =>
{
IsLoggedIn = false;
- if (CurrentTrade != null) {
+ if (CurrentTrade != null)
+ {
CurrentTrade = null;
}
PrintConsole ("[SteamRE] Disconnected from Steam Network!", ConsoleColor.Magenta);
@@ -214,7 +219,8 @@ bool Authenticate (SteamUser.LoginKeyCallback callback)
PrintConsole ("Got login key, performing web auth...");
- using (dynamic userAuth = WebAPI.GetInterface("ISteamUserAuth")) {
+ using (dynamic userAuth = WebAPI.GetInterface("ISteamUserAuth"))
+ {
// generate an AES session key
var sessionKey = CryptoHelper.GenerateRandomBlock (32);
@@ -232,14 +238,17 @@ bool Authenticate (SteamUser.LoginKeyCallback callback)
KeyValue authResult;
- try {
+ try
+ {
authResult = userAuth.AuthenticateUser (
steamid: SteamClient.SteamID.ConvertToUInt64 (),
sessionkey: WebHelpers.UrlEncode (cryptedSessionKey),
encrypted_loginkey: WebHelpers.UrlEncode (cryptedLoginKey),
method: "POST"
);
- } catch (Exception) {
+ }
+ catch (Exception)
+ {
return false;
}
7 SteamBot/Configuration.cs
View
@@ -20,10 +20,13 @@ public static Configuration LoadConfiguration (string filename)
// merge bot-specific admins with global admins
foreach (BotInfo bot in config.Bots)
{
- if (bot.Admins == null) {
+ if (bot.Admins == null)
+ {
bot.Admins = new ulong[config.Admins.Length];
Array.Copy(config.Admins, bot.Admins, config.Admins.Length);
- } else {
+ }
+ else
+ {
bot.Admins = bot.Admins.Concat(config.Admins).ToArray();
}
}
12 SteamBot/Inventory.cs
View
@@ -25,8 +25,10 @@ protected Inventory (InventoryResult apiInventory)
public Item GetItem (ulong id)
{
- foreach (Item item in Items) {
- if (item.Id == id) {
+ foreach (Item item in Items)
+ {
+ if (item.Id == id)
+ {
return item;
}
}
@@ -36,8 +38,10 @@ public Item GetItem (ulong id)
public List<Item> GetItemsByDefindex (int defindex)
{
var items = new List<Item> ();
- foreach (Item item in Items) {
- if (item.Defindex == defindex) {
+ foreach (Item item in Items)
+ {
+ if (item.Defindex == defindex)
+ {
items.Add (item);
}
}
100 SteamBot/Main.cs
View
@@ -37,7 +37,7 @@ class MainClass : ICertificatePolicy
*/
//Name of the Bot
- public static string BotPersonaName = "[StǝamBot] Test Bot 1";
+ public static string BotPersonaName = "[StǝamBot] Unnamed";
//Default Persona State
public static EPersonaState BotPersonaState = EPersonaState.LookingToTrade;
@@ -56,12 +56,16 @@ public bool CheckValidationResult (ServicePoint sp, X509Certificate certificate,
static void printConsole(String line,ConsoleColor color = ConsoleColor.White, bool isDebug = false)
{
System.Console.ForegroundColor = color;
- if(isDebug){
- if(FindArg( AllArgs, "-debug" )){
- System.Console.WriteLine(line);
+ if (isDebug)
+ {
+ if (FindArg ( AllArgs, "-debug" ))
+ {
+ System.Console.WriteLine (line);
}
- }else{
- System.Console.WriteLine(line);
+ }
+ else
+ {
+ System.Console.WriteLine (line);
}
System.Console.ForegroundColor = ConsoleColor.White;
}
@@ -81,27 +85,28 @@ public static void Main (string[] args)
steamClient = new SteamClient ();
- steamTrade = steamClient.GetHandler<SteamTrading>();
+ steamTrade = steamClient.GetHandler<SteamTrading> ();
SteamUser steamUser = steamClient.GetHandler<SteamUser> ();
- steamFriends = steamClient.GetHandler<SteamFriends>();
+ steamFriends = steamClient.GetHandler<SteamFriends> ();
steamClient.Connect ();
#endregion
- while (true) {
+ while (true)
+ {
CallbackMsg msg = steamClient.WaitForCallback (true);
//Console Debug
- printConsole (msg.ToString(),ConsoleColor.Blue,true);
+ printConsole (msg.ToString (),ConsoleColor.Blue,true);
#region Logged Off Handler
msg.Handle<SteamUser.LoggedOffCallback> (callback =>
{
- printConsole("Logged Off: "+callback.Result,ConsoleColor.Red);
+ printConsole ("Logged Off: "+callback.Result,ConsoleColor.Red);
});
#endregion
@@ -109,7 +114,7 @@ public static void Main (string[] args)
#region Steam Disconnect Handler
msg.Handle<SteamClient.DisconnectedCallback> (callback =>
{
- printConsole("Disconnected.",ConsoleColor.Red);
+ printConsole ("Disconnected.",ConsoleColor.Red);
});
#endregion
@@ -125,37 +130,43 @@ public static void Main (string[] args)
msg.Handle<SteamClient.ConnectedCallback> (callback =>
{
//Print Callback
- printConsole("Steam Connected Callback: "+callback.Result, ConsoleColor.Cyan);
+ printConsole ("Steam Connected Callback: "+callback.Result, ConsoleColor.Cyan);
//Validate Result
- if(callback.Result==EResult.OK){
+ if (callback.Result==EResult.OK)
+ {
//Get Steam Login Details
- printConsole("Username: ",ConsoleColor.Cyan);
- string user = Console.ReadLine();
- printConsole("Password: ",ConsoleColor.Cyan);
+ printConsole ("Username: ",ConsoleColor.Cyan);
+ string user = Console.ReadLine ();
+ printConsole ("Password: ",ConsoleColor.Cyan);
Console.ForegroundColor = ConsoleColor.Black;
- string pass = Console.ReadLine();
+ string pass = Console.ReadLine ();
Console.ForegroundColor = ConsoleColor.White;
- printConsole("Getting Web Cookies...",ConsoleColor.Yellow);
+ printConsole ("Getting Web Cookies...",ConsoleColor.Yellow);
//Get Web Cookies
- SteamWeb web = new SteamWeb();
+ SteamWeb web = new SteamWeb ();
WebCookies = web.DoLogin (user,pass);
- if(WebCookies!=null){
+ if (WebCookies!=null)
+ {
printConsole ("SteamWeb Cookies retrived.",ConsoleColor.Green);
//Do Login
steamUser.LogOn (new SteamUser.LogOnDetails{
Username = user,
Password = pass
});
- }else{
+ }
+ else
+ {
printConsole ("Error while getting SteamWeb Cookies.",ConsoleColor.Red);
}
- }else{
+ }
+ else
+ {
//Failure
printConsole ("Failed to Connect to steam.",ConsoleColor.Red);
@@ -169,16 +180,19 @@ public static void Main (string[] args)
//Logged in (or not)
msg.Handle<SteamUser.LoggedOnCallback>( callback =>
{
- printConsole("Logged on callback: "+callback.Result, ConsoleColor.Cyan);
+ printConsole ("Logged on callback: "+callback.Result, ConsoleColor.Cyan);
- if(callback.Result != EResult.OK){
- printConsole("Login Failed!",ConsoleColor.Red);
- }else{
- printConsole("Successfulyl Logged In!\nWelcome "+steamUser.SteamID,ConsoleColor.Green);
+ if (callback.Result != EResult.OK)
+ {
+ printConsole ("Login Failed!",ConsoleColor.Red);
+ }
+ else
+ {
+ printConsole ("Successfulyl Logged In!\nWelcome "+steamUser.SteamID,ConsoleColor.Green);
//Set community status
- steamFriends.SetPersonaName(BotPersonaName);
- steamFriends.SetPersonaState(BotPersonaState);
+ steamFriends.SetPersonaName (BotPersonaName);
+ steamFriends.SetPersonaState (BotPersonaState);
}
});
@@ -196,8 +210,8 @@ public static void Main (string[] args)
//Trading
trade = null;
- trade = new TradeSystem();
- trade.initTrade(steamUser.SteamID,call.Other,WebCookies);
+ trade = new TradeSystem ();
+ trade.initTrade (steamUser.SteamID,call.Other,WebCookies);
});
#endregion
@@ -210,7 +224,7 @@ public static void Main (string[] args)
printConsole ("Trade Proposed Callback. Other: "+thing.Other+"\n");
//Accept It
- steamTrade.RequestTrade(thing.Other);
+ steamTrade.RequestTrade (thing.Other);
});
#endregion
@@ -220,14 +234,15 @@ public static void Main (string[] args)
if (callback.FriendID == steamUser.SteamID)
return;
- EFriendRelationship relationship = steamFriends.GetFriendRelationship(callback.FriendID);
+ EFriendRelationship relationship = steamFriends.GetFriendRelationship (callback.FriendID);
if (!(relationship == EFriendRelationship.RequestRecipient))
return;
- if(steamFriends.GetFriendRelationship(callback.FriendID)==EFriendRelationship.PendingInvitee){
- printConsole("[Friend] Friend Request Pending: " + callback.FriendID + "(" + steamFriends.GetFriendPersonaName(callback.FriendID) + ") - Accepted", ConsoleColor.Yellow);
- steamFriends.AddFriend(callback.FriendID);
+ if (steamFriends.GetFriendRelationship (callback.FriendID) == EFriendRelationship.PendingInvitee)
+ {
+ printConsole ("[Friend] Friend Request Pending: " + callback.FriendID + "(" + steamFriends.GetFriendPersonaName (callback.FriendID) + ") - Accepted", ConsoleColor.Yellow);
+ steamFriends.AddFriend (callback.FriendID);
}
});
@@ -243,15 +258,18 @@ public static void Main (string[] args)
//Type (emote or chat)
EChatEntryType type = callback.EntryType;
- if(type == EChatEntryType.ChatMsg){
+ if (type == EChatEntryType.ChatMsg)
+ {
//Message is a chat message
//Reply with the same message
- steamFriends.SendChatMessage(callback.Sender,EChatEntryType.ChatMsg,callback.Message);
+ steamFriends.SendChatMessage (callback.Sender,EChatEntryType.ChatMsg,callback.Message);
//Chat API coming soon
- }else if(type == EChatEntryType.Emote){
+ }
+ else if (type == EChatEntryType.Emote)
+ {
//Message is emote
//Do nothing yet
@@ -287,4 +305,4 @@ static bool FindArg( string[] args, string arg )
} //end namespace
-//Applejack is best Pony ;)
+// Get Serious.
BIN  SteamBot/SteamBot-Linux.tar.gz
View
Binary file not shown
45 SteamBot/SteamWeb.cs
View
@@ -33,7 +33,8 @@ public static HttpWebResponse Request (string url, string method, NameValueColle
request.UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11";
request.Referer = "http://steamcommunity.com/trade/1";
- if (ajax) {
+ if (ajax)
+ {
request.Headers.Add ("X-Requested-With", "XMLHttpRequest");
request.Headers.Add ("X-Prototype-Version", "1.7");
}
@@ -42,7 +43,8 @@ public static HttpWebResponse Request (string url, string method, NameValueColle
request.CookieContainer = cookies ?? new CookieContainer ();
// Request data
- if (data != null) {
+ if (data != null)
+ {
string dataString = String.Join ("&", Array.ConvertAll (data.AllKeys, key =>
String.Format ("{0}={1}", HttpUtility.UrlEncode (key), HttpUtility.UrlEncode (data [key]))
)
@@ -71,7 +73,8 @@ public static CookieCollection DoLogin (string username, string password)
// Validate
- if (rsaJSON.success != true) {
+ if (rsaJSON.success != true)
+ {
return null;
}
@@ -93,7 +96,8 @@ public static CookieCollection DoLogin (string username, string password)
CookieCollection cookies;
string steamGuardText = "";
string steamGuardId = "";
- do {
+ do
+ {
Console.WriteLine ("SteamWeb: Logging In...");
bool captcha = loginJson != null && loginJson.captcha_needed == true;
@@ -108,7 +112,8 @@ public static CookieCollection DoLogin (string username, string password)
// Captcha
string capText = "";
- if (captcha) {
+ if (captcha)
+ {
Console.WriteLine ("SteamWeb: Captcha is needed.");
System.Diagnostics.Process.Start ("https://steamcommunity.com/public/captcha.php?gid=" + loginJson.captcha_gid);
Console.WriteLine ("SteamWeb: Type the captcha:");
@@ -118,19 +123,20 @@ public static CookieCollection DoLogin (string username, string password)
data.Add ("captcha_gid", captcha ? capGID : "");
data.Add ("captcha_text", captcha ? capText : "");
// Captcha end
-
+
// SteamGuard
- if (steamGuard) {
+ if (steamGuard)
+ {
Console.WriteLine ("SteamWeb: SteamGuard is needed.");
Console.WriteLine ("SteamWeb: Type the code:");
steamGuardText = Uri.EscapeDataString (Console.ReadLine ());
steamGuardId = loginJson.emailsteamid;
}
-
+
data.Add ("emailauth", steamGuardText);
data.Add ("emailsteamid", steamGuardId);
// SteamGuard end
-
+
data.Add ("rsatimestamp", time);
HttpWebResponse webResponse = Request ("https://steamcommunity.com/login/dologin/", "POST", data, null, false);
@@ -144,14 +150,18 @@ public static CookieCollection DoLogin (string username, string password)
} while (loginJson.captcha_needed == true);
- if (loginJson.success == true) {
+ if (loginJson.success == true)
+ {
CookieContainer c = new CookieContainer ();
- foreach (Cookie cookie in cookies) {
+ foreach (Cookie cookie in cookies)
+ {
c.Add (cookie);
}
SubmitCookies (c);
return cookies;
- } else {
+ }
+ else
+ {
Console.WriteLine ("SteamWeb Error: " + loginJson.message);
return null;
}
@@ -224,17 +234,10 @@ public class SteamResult
public bool captcha_needed { get; set; }
public string captcha_gid { get; set; }
-
+
public bool emailauth_needed { get; set; }
-
+
public string emailsteamid { get; set; }
-
- /*
- emailauth_needed: true
-emaildomain: "gmail.com"
-emailsteamid: "76561198025418738"
-message: "SteamGuard"
- */
}
100 SteamBot/Trade.cs
View
@@ -98,49 +98,60 @@ public Trade (SteamID me, SteamID other, string sessionId, string token, string
baseTradeURL = String.Format (SteamTradeUrl, OtherSID.ConvertToUInt64 ());
// try to poll for the first time
- try {
+ try
+ {
Poll ();
- } catch (Exception) {
+ }
+ catch (Exception)
+ {
PrintConsole ("Failed to connect to Steam!", ConsoleColor.Red);
if (OnError != null)
OnError("There was a problem connecting to Steam Trading.");
}
- try {
+ try
+ {
// fetch the other player's inventory
OtherItems = GetInventory (OtherSID);
- if (OtherItems == null || OtherItems.success != "true") {
+ if (OtherItems == null || OtherItems.success != "true")
+ {
throw new Exception ("Could not fetch other player's inventory via Trading!");
}
// fetch our inventory
MyItems = GetInventory (MeSID);
- if (MyItems == null || MyItems.success != "true") {
+ if (MyItems == null || MyItems.success != "true")
+ {
throw new Exception ("Could not fetch own inventory via Trading!");
}
// fetch other player's inventory from the Steam API.
OtherInventory = Inventory.FetchInventory(OtherSID.ConvertToUInt64(), apiKey);
- if (OtherInventory == null) {
+ if (OtherInventory == null)
+ {
throw new Exception ("Could not fetch other player's inventory via Steam API!");
}
// fetch our inventory from the Steam API.
MyInventory = Inventory.FetchInventory(MeSID.ConvertToUInt64(), apiKey);
- if (MyInventory == null) {
+ if (MyInventory == null)
+ {
throw new Exception ("Could not fetch own inventory via Steam API!");
}
// check that the schema was already successfully fetched
- if (CurrentSchema == null) {
+ if (CurrentSchema == null)
+ {
throw new Exception ("It seems the item schema was not fetched correctly!");
}
if (OnAfterInit != null)
OnAfterInit();
- } catch (Exception e) {
+ }
+ catch (Exception e)
+ {
if (OnError != null)
OnError ("I'm having a problem getting one of our backpacks. The Steam Community might be down. Ensure your backpack isn't private.");
Console.WriteLine (e);
@@ -150,7 +161,8 @@ public Trade (SteamID me, SteamID other, string sessionId, string token, string
public void Poll ()
{
- if (!tradeStarted) {
+ if (!tradeStarted)
+ {
tradeStarted = true;
TradeStart = DateTime.Now;
LastAction = DateTime.Now;
@@ -159,17 +171,22 @@ public void Poll ()
StatusObj status = GetStatus ();
- if (status.events != null && numEvents != status.events.Length) {
+ if (status.events != null && numEvents != status.events.Length)
+ {
int numLoops = status.events.Length - numEvents;
numEvents = status.events.Length;
- for (int i = numLoops; i > 0; i--) {
+ for (int i = numLoops; i > 0; i--)
+ {
int EventID;
- if (numLoops == 1) {
+ if (numLoops == 1)
+ {
EventID = numEvents - 1;
- } else {
+ }
+ else
+ {
EventID = numEvents - i;
}
@@ -191,13 +208,15 @@ public void Poll ()
*/
ulong itemID;
- switch (status.events [EventID].action) {
+ switch (status.events [EventID].action)
+ {
case 0:
itemID = (ulong)status.events [EventID].assetid;
if (isBot)
MyOfferedItems.Add (itemID);
- else {
+ else
+ {
OtherOfferedItems.Add (itemID);
Inventory.Item item = OtherInventory.GetItem (itemID);
Schema.Item schemaItem = CurrentSchema.GetItem (item.Defindex);
@@ -210,7 +229,8 @@ public void Poll ()
if (isBot)
MyOfferedItems.Remove (itemID);
- else {
+ else
+ {
OtherOfferedItems.Remove (itemID);
Inventory.Item item = OtherInventory.GetItem (itemID);
Schema.Item schemaItem = CurrentSchema.GetItem (item.Defindex);
@@ -219,24 +239,28 @@ public void Poll ()
break;
case 2:
- if (!isBot) {
+ if (!isBot)
+ {
OtherReady = true;
OnUserSetReady (true);
}
break;
case 3:
- if (!isBot) {
+ if (!isBot)
+ {
OtherReady = false;
OnUserSetReady (false);
}
break;
case 4:
- if (!isBot) {
+ if (!isBot)
+ {
OnUserAccept ();
}
break;
case 7:
- if (!isBot) {
+ if (!isBot)
+ {
OnMessage (status.events [EventID].text);
}
break;
@@ -259,29 +283,36 @@ public void Poll ()
DateTime tradeTimeout = TradeStart.AddSeconds (MaximumTradeTime);
int untilTradeTimeout = (int) Math.Round ((tradeTimeout - now).TotalSeconds);
- if (untilActionTimeout <= 0 || untilTradeTimeout <= 0) {
- if (OnTimeout != null) {
+ if (untilActionTimeout <= 0 || untilTradeTimeout <= 0)
+ {
+ if (OnTimeout != null)
+ {
OnTimeout();
}
CancelTrade();
- } else if (untilActionTimeout <= 15 && untilActionTimeout % 5 == 0) {
+ }
+ else if (untilActionTimeout <= 15 && untilActionTimeout % 5 == 0)
+ {
SendMessage ("Are You AFK? The trade will be canceled in " + untilActionTimeout + " seconds if you don't do something.");
}
}
// Update Local Variables
- if (status.them != null) {
+ if (status.them != null)
+ {
OtherReady = status.them.ready == 1 ? true : false;
MeReady = status.me.ready == 1 ? true : false;
}
// Update version
- if (status.newversion) {
+ if (status.newversion)
+ {
version = status.version;
}
- if (status.logpos != 0) {
+ if (status.logpos != 0)
+ {
logpos = status.logpos;
}
}
@@ -300,7 +331,8 @@ public string SendMessage (string msg)
public bool AddItemByDefindex (int defindex, int slot)
{
List<Inventory.Item> items = MyInventory.GetItemsByDefindex (defindex);
- if (items[0] != null) {
+ if (items[0] != null)
+ {
AddItem (items[0].Id, slot);
return true;
}
@@ -388,10 +420,13 @@ protected dynamic GetInventory (SteamID steamid)
steamid.ConvertToUInt64 ()
);
- try {
+ try
+ {
string response = Fetch (url, "GET", null, false);
return JsonConvert.DeserializeObject (response);
- } catch (Exception) {
+ }
+ catch (Exception)
+ {
return JsonConvert.DeserializeObject ("{\"success\":\"false\"}");
}
}
@@ -399,12 +434,13 @@ protected dynamic GetInventory (SteamID steamid)
protected string Fetch (string url, string method, NameValueCollection data = null, bool sendLoginData = true)
{
var cookies = new CookieContainer();
- if (sendLoginData) {
+ if (sendLoginData)
+ {
cookies.Add (new Cookie ("sessionid", sessionId, String.Empty, SteamCommunityDomain));
cookies.Add (new Cookie ("steamLogin", steamLogin, String.Empty, SteamCommunityDomain));
}
- return SteamWeb.Fetch(url, method, data, cookies);
+ return SteamWeb.Fetch (url, method, data, cookies);
}
public abstract class TradeListener
24 SteamBot/TradeEnterTradeListener.cs
View
@@ -41,7 +41,7 @@ public override void OnTimeout ()
public override void OnError (string message)
{
// This is called when there was a Steam Trading error
- Bot.SteamFriends.SendChatMessage(trade.OtherSID, EChatEntryType.ChatMsg,
+ Bot.SteamFriends.SendChatMessage (trade.OtherSID, EChatEntryType.ChatMsg,
"Oh, there was an error: " + message + ". Maybe try again in a few minutes.");
Console.WriteLine (message);
}
@@ -74,14 +74,18 @@ public override void OnUserAccept()
public override void OnUserSetReadyState (bool ready)
{
- if (!ready) {
+ if (!ready)
+ {
// This is called when the other user is set not ready.
// Currently, it makes the bot go not ready also.
trade.SetReady (false);
- } else {
+ }
+ else
+ {
// This is called when the other user is set ready.
// You can remove the if Validate() to make the bot accept any items. the method Valiate() is down below.
- if(Validate ()) {
+ if(Validate ())
+ {
trade.SetReady(true);
}
}
@@ -116,7 +120,8 @@ public bool Validate ()
List<string> errors = new List<string> ();
- foreach (ulong id in trade.OtherOfferedItems) {
+ foreach (ulong id in trade.OtherOfferedItems)
+ {
var item = trade.OtherInventory.GetItem (id);
if (item.Defindex == 5000)
ScrapPutUp++;
@@ -124,20 +129,23 @@ public bool Validate ()
ScrapPutUp += 3;
else if (item.Defindex == 5002)
ScrapPutUp += 9;
- else {
+ else
+ {
var schemaItem = Trade.CurrentSchema.GetItem (item.Defindex);
errors.Add ("Item " + schemaItem.Name + " is not a metal.");
}
}
- if (ScrapPutUp < 1) {
+ if (ScrapPutUp < 1)
+ {
errors.Add ("You must put up at least 1 scrap.");
}
// send the errors
if (errors.Count != 0)
trade.SendMessage("There were errors in your trade: ");
- foreach (string error in errors) {
+ foreach (string error in errors)
+ {
trade.SendMessage(error);
}
Please sign in to comment.
Something went wrong with that request. Please try again.