Permalink
Browse files

Adds CONTRIBUTING.md

  • Loading branch information...
1 parent 09c845e commit 0681fb8c8898a865d6c0a46df4b68a6b1809ddf1 @medcat medcat committed Oct 25, 2012
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.
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.
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;
}
@@ -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();
}
}
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);
}
}
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,35 +85,36 @@ 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
#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.
Binary file not shown.
Oops, something went wrong.

0 comments on commit 0681fb8

Please sign in to comment.