Пример #1
0
 public void OnGroupChatMessage(SteamFriends.ChatMsgCallback e)
 {
     Bot._getUserHandler(e.ChatterID).OnChatRoomMessage(
         e.ChatRoomID, e.ChatterID, e.Message);
     Log.Info("Group chat message from {0}: {1}", Bot.SteamFriends
              .GetFriendPersonaName(e.ChatterID), e.Message);
 }
Пример #2
0
            public void OnFriendMessage(SteamFriends.FriendMsgCallback e)
            {
                EChatEntryType type = e.EntryType;

                if (e.EntryType == EChatEntryType.ChatMsg)
                {
                    Log.Info("Chat Message from {0}: {1}", Bot.SteamFriends.
                             GetFriendPersonaName(e.Sender), e.Message);
                    Bot._getUserHandler(e.Sender).OnMessageHandler(e.Message, type);
                }
            }
Пример #3
0
            public void OnTradeProposed(SteamTrading.TradeProposedCallback e)
            {
                if (!Bot._checkCookies())
                {
                    Bot.SteamTrade.RespondToTrade(e.TradeID, false);
                    Log.Warn("Trade proposal cookie check failed.");
                    return;
                }

                try
                {
                    Bot._tradeManager.InitializeTrade(Bot.SteamUser.SteamID, e.OtherClient);
                    Log.Debug("Trade proposal initialized");
                }
                catch (WebException we)
                {
                    Bot.SteamFriends.SendChatMessage(e.OtherClient, EChatEntryType.ChatMsg,
                                                     "Trade error: " + we.Message);
                    Log.Error("WebException occurred during trade: " + we.ToString());

                    Bot.SteamTrade.RespondToTrade(e.TradeID, false);
                    return;
                }
                catch (Exception ex)
                {
                    Bot.SteamFriends.SendChatMessage(e.OtherClient, EChatEntryType.ChatMsg,
                                                     "Trade declined. Could not correctly fetch your backpack.");
                    Log.Error("Exception occurred during trade: " + ex.ToString());

                    Bot.SteamTrade.RespondToTrade(e.TradeID, false);
                    return;
                }

                if (Bot._tradeManager.OtherInventory.IsPrivate)
                {
                    Bot.SteamFriends.SendChatMessage(e.OtherClient, EChatEntryType.ChatMsg,
                                                     "Trade declined. Your backpack cannot be private.");
                    Log.Warn("Trade declined as other backpack was private.");

                    Bot.SteamTrade.RespondToTrade(e.TradeID, false);
                    return;
                }

                if (Bot.CurrentTrade == null && Bot._getUserHandler(e.OtherClient).OnTradeRequest())
                {
                    Bot.SteamTrade.RespondToTrade(e.TradeID, true);
                }
                else
                {
                    Bot.SteamTrade.RespondToTrade(e.TradeID, false);
                }
            }
Пример #4
0
 public void OnTradeResult(SteamTrading.TradeResultCallback e)
 {
     if (e.Response == EEconTradeResponse.Accepted)
     {
         Log.Debug("Trade Status: {0}", e.Response);
         Log.Success("Trade Accepted!");
         Bot._getUserHandler(e.OtherClient).OnTradeRequestReply(true, e.Response.ToString());
     }
     else
     {
         Log.Warn("Trade failed: {0}", e.Response);
         Bot.CloseTrade();
         Bot._getUserHandler(e.OtherClient).OnTradeRequestReply(false, e.Response.ToString());
     }
 }
Пример #5
0
            public void OnLoginKey(SteamUser.LoginKeyCallback e)
            {
                Bot._myUniqueId = e.UniqueID.ToString();

                Bot._userWebLogOn();

                if (Trade.CurrentSchema == null)
                {
                    Log.Info("Downloading Schema...");
                    Trade.CurrentSchema = Schema.FetchSchema(Bot.ApiKey, Bot.schemaLang);
                    Log.Success("Schema Downloaded!");
                }

                Bot.SteamFriends.SetPersonaName(Bot.DisplayNamePrefix + Bot.DisplayName);
                Bot.SteamFriends.SetPersonaState(EPersonaState.Online);

                Log.Success("Steam Bot Logged In Completely!");

                Bot._getUserHandler(Bot.SteamClient.SteamID).OnLoginCompleted();
            }
Пример #6
0
            public void OnFriendsList(SteamFriends.FriendsListCallback e)
            {
                foreach (SteamFriends.FriendsListCallback.Friend friend in e.FriendList)
                {
                    if (Bot.Admins.Contains(friend.SteamID))
                    {
                        Bot.SteamFriends.SendChatMessage(friend.SteamID, EChatEntryType.ChatMsg, "Hello, sir.");
                        Log.Info("Sent admin startup message to admin '{0}'.", Bot.SteamFriends
                                 .GetFriendPersonaName(friend.SteamID));
                    }

                    switch (friend.SteamID.AccountType)
                    {
                    case EAccountType.Clan:
                        if (friend.Relationship == EFriendRelationship.RequestRecipient)
                        {
                            if (Bot._getUserHandler(friend.SteamID).OnGroupAdd())
                            {
                                Bot.AcceptGroupInvite(friend.SteamID);
                                Log.Success("Accepted group invite from {0}.", friend.SteamID);
                            }
                            else
                            {
                                Bot.DeclineGroupInvite(friend.SteamID);
                                Log.Info("Declined group invite from {0}.", friend.SteamID);
                            }
                        }
                        break;

                    default:
                        Bot._createFriendsListIfNecessary();
                        if (friend.Relationship == EFriendRelationship.None)
                        {
                            Log.Warn("Friend already removed. Removing friend {0}.", friend.SteamID);
                            Bot._friends.Remove(friend.SteamID);
                            Bot._getUserHandler(friend.SteamID).OnFriendRemove();
                            Bot.RemoveUserHandler(friend.SteamID);
                        }
                        else if (friend.Relationship == EFriendRelationship.RequestRecipient)
                        {
                            if (Bot._getUserHandler(friend.SteamID).OnFriendAdd())
                            {
                                if (!Bot._friends.Contains(friend.SteamID))
                                {
                                    Bot._friends.Add(friend.SteamID);
                                }
                                else
                                {
                                    Log.Error("Friend was added who was already in friends list: " + friend.SteamID);
                                }
                                Bot.SteamFriends.AddFriend(friend.SteamID);
                            }
                            else
                            {
                                Log.Warn("Friend add failed. Removing friend {0}.", friend.SteamID);
                                Bot.SteamFriends.RemoveFriend(friend.SteamID);
                                Bot.RemoveUserHandler(friend.SteamID);
                            }
                        }
                        break;
                    }
                }
            }