Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
JustArchi committed Nov 20, 2015
1 parent c0c6191 commit a6a2e16
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 33 deletions.
5 changes: 3 additions & 2 deletions ArchiSteamFarm/ArchiWebHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ limitations under the License.

namespace ArchiSteamFarm {
internal class ArchiWebHandler {
private const int Timeout = 1000 * 15; // In miliseconds
private const int Timeout = 1000 * 30; // In miliseconds

private readonly Bot Bot;
private readonly string ApiKey;
private readonly Dictionary<string, string> SteamCookieDictionary = new Dictionary<string, string>();

private ulong SteamID;
private string VanityURL;
private readonly Dictionary<string, string> SteamCookieDictionary = new Dictionary<string, string>();

// This is required because home_process request must be done on final URL
private string GetHomeProcess() {
Expand Down
26 changes: 8 additions & 18 deletions ArchiSteamFarm/Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ internal class Bot {

private static readonly ConcurrentDictionary<string, Bot> Bots = new ConcurrentDictionary<string, Bot>();

private readonly string ConfigFile;
private readonly string SentryFile;
private readonly string ConfigFile, SentryFile;

internal readonly string BotName;

private bool IsRunning = false;
private string AuthCode, TwoFactorAuth;

internal readonly string BotName;

internal ArchiHandler ArchiHandler { get; private set; }
internal ArchiWebHandler ArchiWebHandler { get; private set; }
internal CallbackManager CallbackManager { get; private set; }
Expand Down Expand Up @@ -112,7 +111,6 @@ internal Bot(string botName) {
SteamFriends = SteamClient.GetHandler<SteamFriends>();
CallbackManager.Subscribe<SteamFriends.FriendsListCallback>(OnFriendsList);
CallbackManager.Subscribe<SteamFriends.FriendMsgCallback>(OnFriendMsg);
CallbackManager.Subscribe<SteamFriends.PersonaStateCallback>(OnPersonaState);

SteamUser = SteamClient.GetHandler<SteamUser>();
CallbackManager.Subscribe<SteamUser.AccountInfoCallback>(OnAccountInfo);
Expand Down Expand Up @@ -399,7 +397,7 @@ private void OnFriendsList(SteamFriends.FriendsListCallback callback) {
SteamID steamID = friend.SteamID;
switch (steamID.AccountType) {
case EAccountType.Clan:
//ArchiHandler.AcceptClanInvite(steamID);
ArchiHandler.DeclineClanInvite(steamID);
break;
default:
if (steamID == SteamMasterID) {
Expand Down Expand Up @@ -446,6 +444,7 @@ private async void OnFriendMsg(SteamFriends.FriendMsgCallback callback) {
await ShutdownAllBots().ConfigureAwait(false);
break;
case "!farm":
SendMessageToUser(steamID, "Please wait...");
await CardsFarmer.StartFarming().ConfigureAwait(false);
SendMessageToUser(steamID, "Done!");
break;
Expand All @@ -462,6 +461,9 @@ private async void OnFriendMsg(SteamFriends.FriendMsgCallback callback) {
} else {
string[] args = message.Split(' ');
switch (args[0]) {
case "!redeem":
ArchiHandler.RedeemKey(args[1]);
break;
case "!start":
ResponseStart(steamID, args[1]);
break;
Expand All @@ -475,18 +477,6 @@ private async void OnFriendMsg(SteamFriends.FriendMsgCallback callback) {
}
}

private void OnPersonaState(SteamFriends.PersonaStateCallback callback) {
if (callback == null) {
return;
}

SteamID steamID = callback.FriendID;
SteamID sourceSteamID = callback.SourceSteamID;
string steamNickname = callback.Name;
EPersonaState personaState = callback.State;
EClanRank clanRank = (EClanRank) callback.ClanRank;
}

private void OnAccountInfo(SteamUser.AccountInfoCallback callback) {
if (callback == null) {
return;
Expand Down
23 changes: 10 additions & 13 deletions ArchiSteamFarm/CMsgClientClanInviteAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,21 @@ limitations under the License.
using System.IO;

namespace ArchiSteamFarm {
/// <summary>
/// Message used to Accept or Decline a group(clan) invite.
/// </summary>
internal sealed class CMsgClientClanInviteAction : ISteamSerializableMessage, ISteamSerializable {
EMsg ISteamSerializableMessage.GetEMsg() {
return EMsg.ClientAcknowledgeClanInvite;
}

public CMsgClientClanInviteAction() {
}

/// <summary>
/// Group invited to.
/// </summary>
internal ulong GroupID = 0;

/// <summary>
/// To accept or decline the invite.
/// </summary>
internal bool AcceptInvite = true;

public CMsgClientClanInviteAction() { }

void ISteamSerializable.Serialize(Stream stream) {
if (stream == null) {
return;
}

try {
BinaryWriter binaryWriter = new BinaryWriter(stream);
binaryWriter.Write(GroupID);
Expand All @@ -59,6 +52,10 @@ void ISteamSerializable.Serialize(Stream stream) {
}

void ISteamSerializable.Deserialize(Stream stream) {
if (stream == null) {
return;
}

try {
BinaryReader binaryReader = new BinaryReader(stream);
GroupID = binaryReader.ReadUInt64();
Expand Down

0 comments on commit a6a2e16

Please sign in to comment.