コード例 #1
0
        /// <summary>
        /// Called whenever a message is sent to the bot.
        /// This is limited to regular and emote messages.
        /// </summary>
        public override void OnMessage(string message, EChatEntryType type)
        {
            if (type != EChatEntryType.ChatMsg)
            {
                return;
            }

            if (message.StartsWith("!") ||
                message.StartsWith("/") ||
                message.StartsWith("#"))
            {
                List <string> args    = message.Split(' ').ToList();
                string        cmdName = args[0].Substring(1);
                args.RemoveAt(0);

                ChatHandler.RunCommand(cmdName, args, this);
            }
            else if (ChatHandler.ChatCommands.Exists((cmd) => message.ToLower().StartsWith(cmd.CommandName)))
            {
                List <string> args    = message.Split(' ').ToList();
                string        cmdName = args[0];
                args.RemoveAt(0);

                ChatHandler.RunCommand(cmdName, args, this);
            }
        }
コード例 #2
0
        public override void OnMessage(string message, EChatEntryType type)
        {
            if (IsAdmin)
            {
                //creating a new trade offer
                var offer = Bot.NewTradeOffer(OtherSID);

                //offer.Items.AddMyItem(0, 0, 0);
                if (offer.Items.NewVersion)
                {
                    string newOfferId;
                    if (offer.Send(out newOfferId))
                    {
                        Bot.AcceptAllMobileTradeConfirmations();
                        Log.Success("Trade offer sent : Offer ID " + newOfferId);
                    }
                }

                //creating a new trade offer with token
                var offerWithToken = Bot.NewTradeOffer(OtherSID);

                //offer.Items.AddMyItem(0, 0, 0);
                if (offerWithToken.Items.NewVersion)
                {
                    string newOfferId;
                    // "token" should be replaced with the actual token from the other user
                    if (offerWithToken.SendWithToken(out newOfferId, "token"))
                    {
                        Bot.AcceptAllMobileTradeConfirmations();
                        Log.Success("Trade offer sent : Offer ID " + newOfferId);
                    }
                }
            }
        }
コード例 #3
0
ファイル: LogManager.cs プロジェクト: elitak/open-steamworks
        void ChatMsg( FriendChatMsg_t chatMsg )
        {
            byte[] msgData = new byte[ 1024 * 4 ];
            EChatEntryType type = EChatEntryType.k_EChatEntryTypeChatMsg;

            CSteamID reciever = new CSteamID( chatMsg.m_ulReceiver );

            int msgLength = steamFriends.GetChatMessage( chatMsg.m_ulReceiver, ( int )chatMsg.m_iChatID, msgData, msgData.Length, ref type );

            if ( type == EChatEntryType.k_EChatEntryTypeTyping )
                return;

            msgLength = Clamp( msgLength, 1, msgData.Length );

            LogMessage log = new LogMessage();

            log.Sender = new CSteamID( chatMsg.m_ulSender );
            log.SenderName = steamFriends.GetFriendPersonaName( log.Sender );

            log.Reciever = reciever;
            log.RecieverName = steamFriends.GetFriendPersonaName( log.Reciever );

            log.Message = Encoding.UTF8.GetString( msgData, 0, msgLength );
            log.Message = log.Message.Substring( 0, log.Message.Length - 1 );
            log.MessageTime = DateTime.Now;
            log.MessageType = type;

            AddLog( log );
        }
コード例 #4
0
ファイル: LogManager.cs プロジェクト: elitak/open-steamworks
        void ChatRoomMsg( ChatRoomMsg_t chatMsg )
        {
            if ( !groupChatEnabled || !sets.GroupChatEnabled )
                return;

            byte[] msgData = new byte[ 1024 * 4 ];
            EChatEntryType chatType = EChatEntryType.k_EChatEntryTypeInvalid;
            ulong chatter = 0;

            int len = getChatMsg( clientFriends.Interface, chatMsg.m_ulSteamIDChat, ( int )chatMsg.m_iChatID, ref chatter, msgData, msgData.Length, ref chatType );

            len = Clamp( len, 1, msgData.Length );

            LogMessage log = new LogMessage();

            log.IsGroupMsg = true;
            log.ChatRoom = chatMsg.m_ulSteamIDChat;
            log.ChatRoomName = getChatName( clientFriends.Interface, log.ChatRoom );

            log.Sender = new CSteamID( chatMsg.m_ulSteamIDUser );
            log.SenderName = steamFriends.GetFriendPersonaName( log.Sender );

            log.Reciever = log.Sender;
            log.RecieverName = log.SenderName;

            log.Message = Encoding.UTF8.GetString( msgData, 0, len );
            log.Message = log.Message.Substring(0, log.Message.Length - 1);
            log.MessageTime = DateTime.Now;
            log.MessageType = chatType;

            AddLog( log );
        }
コード例 #5
0
        public override void OnMessage(string message, EChatEntryType type)
        {
            if (IsAdmin)
            {
                //creating a new trade offer
                var offer = Bot.NewTradeOffer(OtherSID);

                //offer.Items.AddMyItem(0, 0, 0);
                if (offer.Items.NewVersion)
                {
                    string newOfferId;
                    if (offer.Send(out newOfferId))
                    {
                        Bot.AcceptAllMobileTradeConfirmations();
                        Log.Success("Trade offer sent : Offer ID " + newOfferId);
                    }
                }

                //creating a new trade offer with token
                var offerWithToken = Bot.NewTradeOffer(OtherSID);

                //offer.Items.AddMyItem(0, 0, 0);
                if (offerWithToken.Items.NewVersion)
                {
                    string newOfferId;
                    // "token" should be replaced with the actual token from the other user
                    if (offerWithToken.SendWithToken(out newOfferId, "token"))
                    {
                        Bot.AcceptAllMobileTradeConfirmations();
                        Log.Success("Trade offer sent : Offer ID " + newOfferId);
                    }
                }
            }
        }
コード例 #6
0
        public override void SendMessage(IClient C, IMessage m, bool toSender)
        {
            if (C.GetType().Equals(typeof(IRCLib.Interfaces.Steam.SteamClient)))
            {
                base.SendMessage(C, m, toSender);
                return;
            }

            if (m.IsCommand)
            {
                if (m.Command == "PRIVMSG")
                {
                    byte[]         msg  = Encoding.UTF8.GetBytes(m.Params[1]);
                    EChatEntryType send = EChatEntryType.k_EChatEntryTypeChatMsg;

                    if (m.Params[1][0] == '' && m.Params[1][1] == 'A')
                    {
                        msg  = Encoding.UTF8.GetBytes(m.Params[1].Substring(8, m.Params[1].Length - 9));
                        send = EChatEntryType.k_EChatEntryTypeEmote;
                    }

                    Server.clientFriends.SendChatMsg(chatID, send, msg, msg.Length + 1);
                }
            }

            base.SendMessage(C, m, toSender);
        }
コード例 #7
0
 public override void OnMessage(string message, EChatEntryType type)
 {
     message = message.ToLower();
     if (IsAdmin)
     {
         if (message == "retrieve")
         {
             var tradeOffer = TradeOffers.CreateTrade(OtherSID);
             var myInventory = CSGOInventory.FetchInventory(MySID, Bot.apiKey);
             foreach (var item in myInventory.Items)
             {
                 tradeOffer.AddMyItem(item.AppId, item.ContextId, item.Id);
             }
             var tradeId = tradeOffer.SendTrade("");
             if (tradeId > 0)
             {
                 Bot.log.Success("Successfully sent a trade offer for all my items.");
             }
         }                
     }
     else
     {
         Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, Bot.ChatResponse);
     }
 }
コード例 #8
0
 public void OnMessageHandler(string message, EChatEntryType type)
 {
     if (!HandleWaitingOnUserResponse(message))
     {
         OnMessage(message, type);
     }
 }
コード例 #9
0
        public void SendMessage(IMessage m)
        {
            if (m.IsCommand)
            {
                if (m.Command == "PRIVMSG" || m.Command == "NOTICE")
                {
                    byte[]         msg  = Encoding.UTF8.GetBytes(m.Params[1]);
                    EChatEntryType send = EChatEntryType.k_EChatEntryTypeChatMsg;

                    if (m.Params[1][0] == '' && m.Params[1][1] == 'A')
                    {
                        msg  = Encoding.UTF8.GetBytes(m.Params[1].Substring(8, m.Params[1].Length - 9));
                        send = EChatEntryType.k_EChatEntryTypeEmote;
                    }

                    Server.clientFriends.SendMsgToFriend(steamID, send, msg, msg.Length + 1);
                }
            }
            else if (m.IsReply)
            {
                if (m.Reply == Reply.ERR_NICKNAMEINUSE)
                {
                    failedNicks++;
                    AddMessage(m.CreateMessage(this, this.UserString, "NICK", new string[] { Server.StripString(Server.clientFriends.GetFriendPersonaName(steamID)) + "[" + failedNicks + "]" }));
                }
            }
        }
コード例 #10
0
        public void HandleCallback(CallbackMsg msg)
        {
            if (!msg.IsType <SteamFriends.FriendMsgCallback>())
            {
                return;
            }

            msg.Handle <SteamFriends.FriendMsgCallback>(friendMsg =>
            {
                EChatEntryType type = friendMsg.EntryType;

                if (type == EChatEntryType.ChatMsg || type == EChatEntryType.Emote || type == EChatEntryType.InviteGame)
                {
                    ChatDialog cd = GetChat(friendMsg.Sender);
                    cd.HandleChat(friendMsg);
                }
            });

            msg.Handle <SteamFriends.PersonaStateCallback>(personaState =>
            {
                if (personaState.FriendID == Steam3.SteamClient.SteamID)
                {
                    return;
                }

                ChatDialog cd = GetChat(personaState.FriendID);
                cd.HandleState(personaState);
            });
        }
コード例 #11
0
ファイル: Message.cs プロジェクト: Sharparam/SteamLib
 internal Message(CSteamID sender, CSteamID receiver, EChatEntryType type, string content)
 {
     Sender   = sender;
     Receiver = receiver;
     Type     = type;
     Content  = content;
 }
コード例 #12
0
 private void OnInviteTimerElapsed(object source, ElapsedEventArgs e, EChatEntryType type)
 {
     Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "Hello!  Send me a trade invite to begin trading!");
     Bot.log.Success("Sent welcome message.");
     inviteMsgTimer.Enabled = false;
     inviteMsgTimer.Stop();
 }
コード例 #13
0
 private void OnInviteTimerElapsed(object source, ElapsedEventArgs e, EChatEntryType type)
 {
     Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "Hi. You have added Keybanking bot! Just trade me, and add your keys or metal to begin! ");
     Bot.log.Success("Sent welcome message.");
     inviteMsgTimer.Enabled = false;
     inviteMsgTimer.Stop();
 }
コード例 #14
0
ファイル: SteamFriends.cs プロジェクト: ealexeyja/XFSteamKit
        /// <summary>
        /// Sends a message to a chat room.
        /// </summary>
        /// <param name="steamIdChat">The SteamID of the chat room.</param>
        /// <param name="type">The message type.</param>
        /// <param name="message">The message.</param>
        public void SendChatRoomMessage(SteamID steamIdChat, EChatEntryType type, string message)
        {
            if (steamIdChat == null)
            {
                throw new ArgumentNullException(nameof(steamIdChat));
            }

            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            SteamID chatId = steamIdChat.ConvertToUInt64(); // copy the steamid so we don't modify it

            if (chatId.IsClanAccount)
            {
                // this steamid is incorrect, so we'll fix it up
                chatId.AccountInstance = ( uint )SteamID.ChatInstanceFlags.Clan;
                chatId.AccountType     = EAccountType.Chat;
            }

            var chatMsg = new ClientMsg <MsgClientChatMsg>();

            chatMsg.Body.ChatMsgType     = type;
            chatMsg.Body.SteamIdChatRoom = chatId;
            chatMsg.Body.SteamIdChatter  = Client.SteamID;

            chatMsg.WriteNullTermString(message, Encoding.UTF8);

            this.Client.Send(chatMsg);
        }
コード例 #15
0
 public override void OnMessage(string message, EChatEntryType type)
 {
     message = message.ToLower();
     if (IsAdmin)
     {
         if (message == "retrieve")
         {
             var tradeOffer  = TradeOffers.CreateTrade(OtherSID);
             var myInventory = CSGOInventory.FetchInventory(MySID, Bot.apiKey);
             foreach (var item in myInventory.Items)
             {
                 tradeOffer.AddMyItem(item.AppId, item.ContextId, item.Id);
             }
             var tradeId = tradeOffer.SendTrade("");
             if (tradeId > 0)
             {
                 Bot.log.Success("Successfully sent a trade offer for all my items.");
             }
         }
     }
     else
     {
         Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, Bot.ChatResponse);
     }
 }
コード例 #16
0
ファイル: KeyUserHandler.cs プロジェクト: webinvoker/test
 private void OnInviteTimerElapsed(object source, ElapsedEventArgs e, EChatEntryType type)
 {
     Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "Hi. You have added The CTS Community's keybanking bot! Just trade me, and add your keys or metal to begin! I also accept donations of either keys or metal. To donate, type \"donate\" in the trade window!");
     Bot.log.Success("Sent welcome message.");
     inviteMsgTimer.Enabled = false;
     inviteMsgTimer.Stop();
 }
コード例 #17
0
        public override void OnTradeInit()
        {
            Bot.log.Success("Trade started!");
            Bot.SteamFriends.SetPersonaState(EPersonaState.Busy);
            FileToCreate = "Donation\\" + System.DateTime.Today.ToString("MM-dd-yyyy") + ".log";

            if (!File.Exists(FileToCreate))
            {
                Bot.log.Success("File created!");
                File.Create(FileToCreate);
            }
            if (!IsAdmin)
            {
                EChatEntryType type = EChatEntryType.ChatMsg;
                Bot.SteamFriends.SendChatMessage(OtherSID, type, "Thank you for donating to Gamem's Trading Service!");
            }
            else
            {
                foreach (var item in Trade.MyInventory.Items)
                {
                    if (!item.IsNotTradeable)
                    {
                        Trade.AddItem(item.Id);
                    }
                }
            }
        }
コード例 #18
0
ファイル: MessageForm.cs プロジェクト: bmk10/hl2sb-src-1
        private void SendText(string text)
        {
            string         input = text;
            EChatEntryType type  = EChatEntryType.k_EChatEntryTypeChatMsg;

            if (input.Length > 3 && input.IndexOf("/me", StringComparison.OrdinalIgnoreCase) == 0)
            {
                input = input.Substring(4, input.Length - 4);
                type  = EChatEntryType.k_EChatEntryTypeEmote;
            }

            byte[] inputBytes = Encoding.ASCII.GetBytes(input);

            context.SteamFriends.SendMsgToFriend(FriendID.SteamID, type, inputBytes, inputBytes.Length + 1);

            chatBox.Invoke((MethodInvoker) delegate
            {
                if (type == EChatEntryType.k_EChatEntryTypeChatMsg)
                {
                    chatBox.AppendText(context.SteamFriends.GetPersonaName() + ": " + input + Environment.NewLine);
                }
                else
                {
                    chatBox.AppendText("* " + context.SteamFriends.GetPersonaName() + " " + input + Environment.NewLine);
                }

                chatBox.ScrollToCaret();
            });
        }
コード例 #19
0
 private void OnInviteTimerElapsed(object source, ElapsedEventArgs e, EChatEntryType type)
 {
     Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "Hi. You have added The CTS Community's scrapbanking bot! I buy two weapons for one scrap and sell two weapons for one scrap. Check my backpack if you are buying weapons, and then trade me to begin!");
     Bot.log.Success("Sent welcome message.");
     inviteMsgTimer.Enabled = false;
     inviteMsgTimer.Stop();
 }
コード例 #20
0
ファイル: SimpleUserHandler.cs プロジェクト: xaustinx/Mist
 public override void OnMessage(string message, EChatEntryType type)
 {
     Bot.main.Invoke((Action)(() =>
     {
         var other = Bot.SteamFriends.GetFriendPersonaName(OtherSID);
         var opened = OpenChat(OtherSID);
         string date = "[" + DateTime.Now + "] ";
         string name = other + ": ";
         foreach (TabPage tab in Friends.chat.ChatTabControl.TabPages)
         {
             if ((SteamID)tab.Tag == OtherSID)
             {
                 foreach (var item in tab.Controls)
                 {
                     Friends.chat.chatTab = (ChatTab)item;
                 }
             }
         }
         int islink;
         islink = 0;
         if (message.Contains("http://") || (message.Contains("https://")) || (message.Contains("www.")) || (message.Contains("ftp.")))
         {
             string[] stan = message.Split(' ');
             foreach (string word in stan)
             {
                 if (word.Contains("http://") || (word.Contains("https://")) || (word.Contains("www.")) || (word.Contains("ftp.")))
                 {
                     if (word.Contains("."))
                     {
                         islink = 1;
                     }
                 }
             }
         }
         if (islink == 1)
         {
             Friends.chat.chatTab.UpdateChat("[INFO] ", "WARNING: ", "Be cautious when clicking unknown links.");
         }
         Friends.chat.chatTab.UpdateChat(date, name, message);
         new Thread(() =>
         {
             if (opened || !Chat.hasFocus)
             {
                 int duration = 3;
                 FormAnimator.AnimationMethod animationMethod = FormAnimator.AnimationMethod.Slide;
                 FormAnimator.AnimationDirection animationDirection = FormAnimator.AnimationDirection.Up;
                 string title = Bot.SteamFriends.GetFriendPersonaName(OtherSID);
                 Notification toastNotification = new Notification(title, Util.GetColorFromPersonaState(Bot, OtherSID), message, duration, animationMethod, animationDirection, Friends.chat.chatTab.avatarBox, new Action(() =>
                 {
                     Friends.chat.BringToFront();
                 }));
                 Bot.main.Invoke((Action)(() =>
                 {
                     toastNotification.Show();
                 }));
             }
         }).Start();
     }));
 }
コード例 #21
0
 public override void OnMessage(string message, EChatEntryType type)
 {
     Bot.main.Invoke((Action)(() =>
     {
         var other = Bot.SteamFriends.GetFriendPersonaName(OtherSID);
         var opened = OpenChat(OtherSID);
         string date = "[" + DateTime.Now + "] ";
         string name = other + ": ";
         foreach (TabPage tab in Friends.chat.ChatTabControl.TabPages)
         {
             if ((SteamID)tab.Tag == OtherSID)
             {
                 foreach (var item in tab.Controls)
                 {
                     Friends.chat.chatTab = (ChatTab)item;
                 }
             }
         }
         int islink;
         islink = 0;
         if (message.Contains("http://") || (message.Contains("https://")) || (message.Contains("www.")) || (message.Contains("ftp.")))
         {
             string[] stan = message.Split(' ');
             foreach (string word in stan)
             {
                 if (word.Contains("http://") || (word.Contains("https://")) || (word.Contains("www.")) || (word.Contains("ftp.")))
                 {
                     if (word.Contains("."))
                     {
                         islink = 1;
                     }
                 }
             }
         }
         if (islink == 1)
         {
             Friends.chat.chatTab.UpdateChat("[INFO] ", "WARNING: ", "Be cautious when clicking unknown links.");
         }
         Friends.chat.chatTab.UpdateChat(date, name, message);
         new Thread(() =>
         {
             if (opened || !Chat.hasFocus)
             {
                 int duration = 3;
                 FormAnimator.AnimationMethod animationMethod = FormAnimator.AnimationMethod.Slide;
                 FormAnimator.AnimationDirection animationDirection = FormAnimator.AnimationDirection.Up;
                 string title = Bot.SteamFriends.GetFriendPersonaName(OtherSID);
                 Notification toastNotification = new Notification(title, Util.GetColorFromPersonaState(Bot, OtherSID), message, duration, animationMethod, animationDirection, Friends.chat.chatTab.avatarBox, new Action(() =>
                 {
                     Friends.chat.BringToFront();
                 }));
                 Bot.main.Invoke((Action)(() =>
                 {
                     toastNotification.Show();
                 }));
             }
         }).Start();
     }));
 }
コード例 #22
0
        void FriendChatMsg_OnRun(FriendChatMsg_t param)
        {
            if (context.SteamUser.GetSteamID() == param.m_ulSender)
            {
                return;
            }

            EChatEntryType type = EChatEntryType.k_EChatEntryTypeChatMsg;

            context.SteamFriends.GetChatMessage(param.m_ulSender, ( int )param.m_iChatID, new byte[0], 0, ref type);

            foreach (MessageForm msgForm in this.OwnedForms)
            {
                if (msgForm.FriendID.SteamID == param.m_ulSender)
                {
                    msgForm.RecievedMessage(param);

                    if (chkNoEscape.Checked)
                    {
                        if (type == ( EChatEntryType )6)
                        {
                            msgForm.AwayMsg(param, awayMessageBox.Text);
                            return;
                        }
                    }

                    if (isAway && type != EChatEntryType.k_EChatEntryTypeTyping && type != ( EChatEntryType )6)
                    {
                        msgForm.AwayMsg(param, awayMessageBox.Text);
                        return;
                    }

                    return;
                }
            }

            if (type == EChatEntryType.k_EChatEntryTypeTyping || type == ( EChatEntryType )6)
            {
                return;
            }

            Friend friend = new Friend();

            friend.SteamID     = param.m_ulSender;
            friend.PersonaName = context.SteamFriends.GetFriendPersonaName(friend.SteamID);

            MessageForm mf = new MessageForm(context, friend, sets);

            this.Invoke((MethodInvoker) delegate
            {
                mf.Show(this);
                mf.RecievedMessage(param);

                if (isAway)
                {
                    mf.AwayMsg(param, awayMessageBox.Text);
                }
            });
        }
コード例 #23
0
ファイル: Friend.cs プロジェクト: Sharparam/SteamLib
 public void SendMessage(string message, EChatEntryType type = EChatEntryType.k_EChatEntryTypeChatMsg)
 {
     if (type == EChatEntryType.k_EChatEntryTypeEmote)
     {
         _log.Warn("Steam no longer supports sending emotes to chat");
     }
     _steam.SendMessage(Id, message, type);
 }
コード例 #24
0
ファイル: UserHandler.cs プロジェクト: Noobgam/MarketBot
 public void OnMessageHandler(string message, EChatEntryType type)
 {
     _lastMessageWasFromTrade = false;
     if (!HandleWaitingOnUserResponse(message))
     {
         OnMessage(message, type);
     }
 }
コード例 #25
0
        public override void OnMessage(string message, EChatEntryType type)
        {
            bool stopThread = message == "stop";

            CurrentMarketThread = new Thread(t =>
            {
                while (!stopThread)
                {
                    bool cancel = false;
                    int start   = 0;
                    int amount  = 100;
                    while (!cancel)
                    {
                        try
                        {
                            var mResp            = Bot.GetMarketResponse(message, start, amount);
                            var inexpensiveSkins = mResp.Listings.Where(v => v.SubTotal <= 5);
                            Log.Success("Found " + inexpensiveSkins.Count() + " in the range from " + start + " to " + (start + amount));
                            if (!inexpensiveSkins.Any())
                            {
                                cancel = true;
                            }
                            else
                            {
                                foreach (var listing in inexpensiveSkins)
                                {
                                    if (stopThread)
                                    {
                                        return;
                                    }
                                    if (ReplyReceived)
                                    {
                                        ReplyReceived = false;
                                        BuyIfLowerThan(listing, 0.01f);
                                        Log.Info("Sleeping 2 secs");
                                        Thread.Sleep(2000);
                                    }
                                    else
                                    {
                                        Log.Info("No reply, sleeping 10 secs");
                                        Thread.Sleep(10000);
                                        BuyIfLowerThan(listing, 0.01f);
                                        Log.Info("Sleeping 2 secs");
                                        Thread.Sleep(2000);
                                    }
                                }
                                start = start + amount;
                            }
                        }
                        catch (Exception e)
                        {
                            Log.Warn("Error occurred in buy thread: " + e);
                        }
                    }
                }
            });
            CurrentMarketThread.Start();
        }
コード例 #26
0
        /// <summary>
        /// Sends a chat message to a friend.
        /// </summary>
        /// <param name="target">The target to send to.</param>
        /// <param name="type">The type of message to send.</param>
        /// <param name="message">The message to send.</param>
        public void SendChatMessage(SteamID target, EChatEntryType type, string message)
        {
            var chatMsg = new ClientMsgProtobuf <CMsgClientFriendMsg>(EMsg.ClientFriendMsg);

            chatMsg.Body.steamid         = target;
            chatMsg.Body.chat_entry_type = ( int )type;
            chatMsg.Body.message         = Encoding.UTF8.GetBytes(message);

            this.Client.Send(chatMsg);
        }
コード例 #27
0
ファイル: Steam.cs プロジェクト: Sharparam/SteamLib
        public void SendMessage(CSteamID receiver, string message, EChatEntryType type = EChatEntryType.k_EChatEntryTypeChatMsg)
        {
            if (type == EChatEntryType.k_EChatEntryTypeEmote)
            {
                _log.Warn("Steam no longer supports sending emotes to chat");
            }
            var msgData = Encoding.UTF8.GetBytes(message);

            SteamFriends002.SendMsgToFriend(receiver, type, msgData);
        }
コード例 #28
0
        public override void OnMessage(string message, EChatEntryType type)
        {
            message = message.ToLower();

            //REGULAR chat commands
            if ((message.Contains("love") || message.Contains("luv") || message.Contains("<3")) && (message.Contains("y") || message.Contains("u")))
            {
                Bot.SteamFriends.SendChatMessage(OtherSID, type, "I love you lots. <3");
            }
            else if (message.Contains("<3"))
            {
                Bot.SteamFriends.SendChatMessage(OtherSID, type, "<3");
            }
            else if (message.Contains("f**k") || message.Contains("suck") || message.Contains("dick") || message.Contains("c**k") || message.Contains("tit") || message.Contains("boob") || message.Contains("pussy") || message.Contains("v****a") || message.Contains("c**t") || message.Contains("penis"))
            {
                Bot.SteamFriends.SendChatMessage(OtherSID, type, "Sorry, but as a robot I cannot perform sexual functions.");
            }
            else if (message.Contains("thank"))
            {
                Bot.SteamFriends.SendChatMessage(OtherSID, type, "You're welcome!");
            }
            else if (message == "buy")
            {
                Bot.SteamFriends.SendChatMessage(OtherSID, type, "Please type that into the TRADE WINDOW, not here!");
            }
            else if (message.Contains("help"))
            {
                Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "If you are selling weapons, simply add 2 weapons and the bot will automatically add 1 scrap. If you want to buy weapons, first you must type \"buy\" INTO THE TRADE WINDOW and then type in what weapon you want. For example, if you wanted to buy The Original, type \"original\" INTO THE TRADE WINDOW and the bot will automatically add it for you if he has one in stock. To add multiple weapons at once, you can separate each search term with a comma. For example, you can type \"original, black\" INTO THE TRADE WINDOW to tell the bot to add The Original and a Black Box.");
            }
            // ADMIN commands
            else if (message == "self.restart")
            {
                if (IsAdmin)
                {
                    // Starts a new instance of the program itself
                    var filename = System.Reflection.Assembly.GetExecutingAssembly().Location;
                    System.Diagnostics.Process.Start(filename);

                    // Closes the current process
                    Environment.Exit(0);
                }
            }
            else if (message == ".canceltrade")
            {
                if (IsAdmin)
                {
                    Trade.CancelTrade();
                    Bot.SteamFriends.SendChatMessage(currentSID, EChatEntryType.ChatMsg, "My creator has forcefully cancelled the trade. Whatever you were doing, he probably wants you to stop.");
                }
            }
            else
            {
                Bot.SteamFriends.SendChatMessage(OtherSID, type, Bot.ChatResponse);
            }
        }
コード例 #29
0
ファイル: Message.cs プロジェクト: Sharparam/SteamLib
        public Message(Steam steam, CSteamID sender, CSteamID receiver, EChatEntryType type, int chatId)
        {
            var data    = new byte[4096];
            var length  = steam.SteamFriends002.GetChatMessage(receiver, chatId, data, ref type);
            var content = Encoding.UTF8.GetString(data, 0, length).Replace("\0", "");

            Sender   = sender;
            Receiver = receiver;
            Type     = type;
            Content  = content;
        }
コード例 #30
0
        /*public void Join(CSteamID lobbyId, APIDispatchDelegate<LobbyEnter_t> callResult)
         * {
         *      //IL_0017: Unknown result type (might be due to invalid IL or missing references)
         *      //IL_0018: Unknown result type (might be due to invalid IL or missing references)
         *      //IL_001d: Unknown result type (might be due to invalid IL or missing references)
         *      //IL_0024: Unknown result type (might be due to invalid IL or missing references)
         *      if (State == LobbyState.Inactive)
         *      {
         *              State = LobbyState.Connecting;
         *              _lobbyEnterExternalCallback = callResult;
         *              SteamAPICall_t val = SteamMatchmaking.JoinLobby(lobbyId);
         *              _lobbyEnter.Set(val, (APIDispatchDelegate<LobbyEnter_t>)null);
         *      }
         * }*/

        public byte[] GetMessage(int index)
        {
            //IL_0001: Unknown result type (might be due to invalid IL or missing references)
            CSteamID       val            = default(CSteamID);
            EChatEntryType val2           = default(EChatEntryType);
            int            lobbyChatEntry = SteamMatchmaking.GetLobbyChatEntry(Id, index, out val, _messageBuffer, _messageBuffer.Length, out val2);

            byte[] array = new byte[lobbyChatEntry];
            Array.Copy(_messageBuffer, array, lobbyChatEntry);
            return(array);
        }
コード例 #31
0
        public override void OnMessage(string message, EChatEntryType type)
        {
            Console.WriteLine("message:" + message + "type:" + type);
            SendChatMessage(Bot.ChatResponse);


            if (message == "test")
            {
                OnTradeInit();
            }
        }
コード例 #32
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);
                }
            }
コード例 #33
0
        private void FriendMessage(FriendChatMsg_t message)
        {
            if (message.m_ulSender == clientUser.GetSteamID())
            {
                return;
            }
            IClient cl = GetSteamClient(message.m_ulSender);

            if (cl == null)
            {
                if (clientList.Clients.ContainsKey(message.m_ulSender))
                {
                    cl = clientList.Clients[message.m_ulSender];
                }
                else
                {
                    cl = new SteamClient(message.m_ulSender);
                }

                clients.Add(cl);
                GetChannel("&Friends").AddClient(cl);
            }

            byte[]         msg     = new byte[4096];
            EChatEntryType type    = EChatEntryType.k_EChatEntryTypeInvalid;
            ulong          chatter = 0;

            int len = clientFriends.GetChatMessage(message.m_ulSender, (int)message.m_iChatID, msg, 4096, ref type, ref chatter);

            len--;

            if (type != EChatEntryType.k_EChatEntryTypeChatMsg && type != EChatEntryType.k_EChatEntryTypeEmote)
            {
                return;
            }

            byte[] a = new byte[len];
            Array.Copy(msg, a, len);

            string[] Messs = Encoding.UTF8.GetString(a).Split(new char[] { '\n' });

            foreach (string Mess in Messs)
            {
                foreach (IClient cli in clients)
                {
                    if (cli.GetType().Equals(typeof(IRCClient)))
                    {
                        cl.AddMessage(IRCMessage.GetStatic().CreateMessage(cl, cl.UserString, "PRIVMSG", new string[] { cli.NickName, (type == EChatEntryType.k_EChatEntryTypeEmote ? "ACTION " : "") + Mess + (type == EChatEntryType.k_EChatEntryTypeEmote ? "" : "") }));
                    }
                }
            }
            //cl.SendMessage(Message.CreateMessage(GetClient(message.m_ulSender), GetClient(message.m_ulSender).UserString, "PRIVMSG", new string[] { client.NickName, "" + (type == EChatEntryType.k_EChatEntryTypeEmote ? "ACTION " : "") + Mess + (type == EChatEntryType.k_EChatEntryTypeEmote ? "" : "" ) }));
        }
コード例 #34
0
ファイル: SimpleUserHandler.cs プロジェクト: Jamyn/Mist
 public override void OnMessage(string message, EChatEntryType type)
 {
     if (Bot.main.InvokeRequired)
     {
         Bot.main.Invoke((Action)(() =>
         {
             var other = Bot.SteamFriends.GetFriendPersonaName(OtherSID);
             Console.WriteLine(OtherSID);
             OpenChat(OtherSID);
             string update = "[" + DateTime.Now + "] - " + other + ": " + message + "\r\n";
             foreach (TabPage tab in Friends.chat.ChatTabControl.TabPages)
             {
                 if (tab.Text == other)
                 {
                     foreach (var item in tab.Controls)
                     {
                         Friends.chat.chatTab = (ChatTab)item;
                     }
                 }
             }
             Friends.chat.chatTab.UpdateChat(update);
             if (!Chat.hasFocus)
             {
                 int duration = 3;
                 FormAnimator.AnimationMethod animationMethod = FormAnimator.AnimationMethod.Slide;
                 FormAnimator.AnimationDirection animationDirection = FormAnimator.AnimationDirection.Up;
                 string title = Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " says:";
                 Notification toastNotification = new Notification(title, message, duration, animationMethod, animationDirection, Friends.chat.chatTab.avatarBox);
                 toastNotification.Show();
             }
         }));
     }
     else
     {
         var other = Bot.SteamFriends.GetFriendPersonaName(OtherSID);
         OpenChat(OtherSID);
         string update = "[" + DateTime.Now + "] - " + other + ": " + message + "\r\n";
         foreach (TabPage tab in Friends.chat.ChatTabControl.TabPages)
         {
             if (tab.Text == other)
             {
                 foreach (var item in tab.Controls)
                 {
                     Friends.chat.chatTab = (ChatTab)item;
                 }
             }
         }
         Friends.chat.chatTab.UpdateChat(update);
     }
 }
コード例 #35
0
ファイル: KeyUserHandler.cs プロジェクト: ck-pasta/SteamBot
        public void Advertise(EChatEntryType type)
        {
            if (TimerEnabled == true)
            {
                adTimer.Enabled = true;
                TimerDisabled = false;

            }
            if (TimerEnabled == false)
            {
                adTimer.Enabled = false;
                adTimer.Stop();
                TimerDisabled = true;
            }
        }
コード例 #36
0
ファイル: ChatDialog.cs プロジェクト: hekar/Vaporized
        public void HandleChat( SteamID sender, EChatEntryType type, string msg )
        {
            string friendName = Steam3.SteamFriends.GetFriendPersonaName( sender );
            string time = DateTime.Now.ToString( "h:mm tt" );

            var friend = new Friend( sender );
            var status = new StatusColor(settings);
            var statusColor = status.GetStatusColor(friend);

            switch ( type )
            {
                case EChatEntryType.ChatMsg:

                    this.AppendText( statusColor, string.Format( "{0} - {1}", time, friendName ) );
                    this.AppendText( Color.Black, ": " + msg );

                    if ( sender != Steam3.SteamClient.SteamID )
                        FlashWindow();

                    break;

                case EChatEntryType.Emote:

                    this.AppendText( statusColor, string.Format( "{0} - {1}", time, friendName ) );
                    this.AppendText( statusColor, " " + msg );

                    if ( sender != Steam3.SteamClient.SteamID )
                        FlashWindow();

                    break;

                case EChatEntryType.InviteGame:
                    this.AppendText( statusColor, string.Format( "{0} - {1}", time, friendName ) );
                    this.AppendText( statusColor, " has invited you to play a game." );

                    if ( sender != Steam3.SteamClient.SteamID )
                        FlashWindow();

                    break;

                default:
                    return;

            }

            this.AppendText( Environment.NewLine );
            this.ScrollLog();
        }
コード例 #37
0
 public override void OnMessage(string message, EChatEntryType type)
 {
     message = message.ToLower();
     if (IsAdmin)
     {
         if (message == "test")
         {
             var rand = new Random();
             var inventory = MyInventory.GetInventory(440, 2);
             var randomItem = inventory[rand.Next(inventory.Count)];
             var tradeOffer = TradeOffers.CreateTrade(OtherSID);
             tradeOffer.AddMyItem(randomItem.AppId, randomItem.ContextId, randomItem.Id);
             tradeOffer.SendTrade("test");
         }
     }
 }
コード例 #38
0
ファイル: TradeUserHandler.cs プロジェクト: norgalyn/SteamBot
 public override void OnMessage(string message, EChatEntryType type)
 {
     if (Bot.currentRequest.User != null)
     {
         if (OtherSID == Bot.currentRequest.User)
         {
             if (message == "help" && Bot.currentRequest.TradeType == Bot.TradeTypes.Sell)
             {
                 Bot.SteamFriends.SendChatMessage(OtherSID, type, "Just open trade and put up almost any amount of hats. Type \"metal\" for more info. In case something goes wrong add:  http://steamcommunity.com/id/norgalyn/ .");
             }
             else if (message == "help" && Bot.currentRequest.TradeType == Bot.TradeTypes.BuySpecific)
             {
                 Bot.SteamFriends.SendChatMessage(OtherSID, type, "Just open trade and I will put up hats you have requested. I expect " + Bot.scrapToString(HatsPutUp * Bot.hatSellPrice) + " metal. In case something goes wrong add:  http://steamcommunity.com/id/norgalyn/ .");
             }
             else if (message == "ready" && Bot.currentRequest.TradeType == Bot.TradeTypes.Sell && Trade != null)
             {
                 foreach (int DefIndex in Bot.priceToDefIndex((Bot.hatBuyPrice * OtherHatsPutUp) - ScrapPutUp))
                 {
                     Trade.AddItemByDefindex(DefIndex);
                 }
                 ScrapPutUp += (Bot.hatBuyPrice * OtherHatsPutUp) - ScrapPutUp;
             }
             else if (message == "metal" && Bot.currentRequest.TradeType == Bot.TradeTypes.Sell)
             {
                 int refined = Bot.myInventory.GetItemsByDefindex(5002).Count;
                 int scrap =  Bot.myInventory.GetItemsByDefindex(5000).Count;
                 int count = 0;
                 while(true)
                 {
                     if (refined > 0 && scrap >1)
                     {
                         count++;
                         refined--;
                         scrap-=2;
                     }
                     else
                         break;
                 }
                 Bot.SteamFriends.SendChatMessage(OtherSID, type, "I can currently buy " + count + " hats.");
             }
         }
         else
             Bot.SteamFriends.SendChatMessage(OtherSID, type, "Sorry, but you have to use our web to trade with me. http://www.hatbank.tf .");
     }
     else
         Bot.SteamFriends.SendChatMessage(OtherSID, type, "Sorry, but you have to use our web to trade with me. http://www.hatbank.tf .");
 }
コード例 #39
0
ファイル: SteamEPHandler.cs プロジェクト: Elinea/SteamBot
 public override void OnMessage(string message, EChatEntryType type)
 {
     if (IsAdmin) {
         switch (message.ToLower()) {
             case "status":
                 Bot.SteamFriends.SendChatMessage (OtherSID, type, "NO STATUS LOL");
                 break;
             case "sup":
                 Bot.SteamFriends.SendChatMessage (OtherSID, type, "WADUP BRO");
                 break;
         }
     }
     if (messageResponses.ContainsKey (message)) {
         string[] response = messageResponses [message].Split ('|');
         Bot.SteamFriends.SendChatMessage (OtherSID, type, response [rnd.Next (1, response.Length + 1) - 1]);
     } else {
         Bot.SteamFriends.SendChatMessage(OtherSID, type, Bot.ChatResponse);
     }
 }
コード例 #40
0
        public override void OnMessage(string message, EChatEntryType type)
        {
            //var inventory = OtherInventory;
            //var jsonIventory = JsonConvert.SerializeObject(inventory);
            //var inventory2 = JsonConvert.DeserializeObject<TF2Inventory>(jsonIventory);
            //Log.Info(jsonIventory);
            //Console.WriteLine("test");
            //SendChatMessage(Bot.ChatResponse);
            /**                         **/
            //var rand = new Random();
            //Bot.GetInventory();
            //var inventory = Bot.MyInventory.Items;
            //var randomItem = inventory[rand.Next(inventory.Length)];
            //var tradeOffer = Bot.NewTradeOffer(OtherSID);
            //tradeOffer.Items.AddMyItem(randomItem.AppId, randomItem.ContextId, (long) randomItem.Id);

            //string tradeId;
            //tradeOffer.Send(out tradeId);

            var rand = new Random();

            List<long> contextId = new List<long>();
            //contextId.Add(6);
            contextId.Add(2);

            var genericInv = new GenericInventory(Bot.SteamWeb);
            genericInv.load(730, contextId, OtherSID);

            var inventory = genericInv.items;
            foreach (var item in genericInv.items)
            {
                Log.Info(genericInv.getDescription(item.Key).name);

            }

            //var randomItem = inventory[rand.Next(inventory.Length)];
            //var tradeOffer = Bot.NewTradeOffer(OtherSID);
            //tradeOffer.Items.AddMyItem(randomItem.AppId, randomItem.ContextId, (long)randomItem.Id);

            //string tradeId;
            //tradeOffer.Send(out tradeId);
        }
コード例 #41
0
        public override void OnMessage(string message, EChatEntryType type)
        {
            Bot.SteamFriends.SendChatMessage(OtherSID, type, Bot.ChatResponse);
            if (message.StartsWith("+"))
            {
                string[] args = message.Split(' ');
                string command = args[0];

                switch (command)
                {
                    case "+help":
                        Bot.SteamFriends.SendChatMessage(OtherSID, type, "command stuff");
                        break;
                    case "+info":
                        Bot.SteamFriends.SendChatMessage(OtherSID, type, "info stuff goes here");
                        break;
                    case "+withdraw":
                        Bot.SteamFriends.SendChatMessage(OtherSID, type, "add transaction here");
                        break;
                    case "+tip":
                        Bot.SteamFriends.SendChatMessage(OtherSID, type, "movefromaccounts here");
                        break;
                    case "+accept":
                        Bot.SteamFriends.SendChatMessage(OtherSID, type, "create account here");
                        break;
                    case "+reject":
                        Bot.SteamFriends.SendChatMessage(OtherSID, type, "do nothing here");
                        break;
                    case "+register":
                        Bot.SteamFriends.SendChatMessage(OtherSID, type, "register here");
                        break;

                }

            }
        }
コード例 #42
0
        public override void OnMessage(string message, EChatEntryType type)
        {
            if (IsAdmin)
            {
                //creating a new trade offer
                var tradeOffer = TradeOffers.CreateTrade(OtherSID);

                //tradeOffer.AddMyItem(0, 0, 0);

                var tradeOfferId = tradeOffer.SendTrade("message");
                if (tradeOfferId > 0)
                {
                    Log.Success("Trade offer sent : Offer ID " + tradeOfferId);
                }

                // sending trade offer with token
                // "token" should be replaced with the actual token from the other user
                var tradeOfferIdWithToken = tradeOffer.SendTradeWithToken("message", "token");
                if (tradeOfferIdWithToken > 0)
                {
                    Log.Success("Trade offer sent : Offer ID " + tradeOfferIdWithToken);
                }
            }
        }
コード例 #43
0
		public static extern int ISteamFriends_GetFriendMessage(CSteamID steamIDFriend, int iMessageID, IntPtr pvData, int cubData, out EChatEntryType peChatEntryType);
コード例 #44
0
        public override void OnMessage(string message, EChatEntryType type)
        {
            System.Threading.Thread.Sleep(100);
            Log.Debug("Message Received: " + message);

            switch(message)
            {
                case "initialized":
                    OtherInit = true;
                    if (MeInit)
                    {
                        AddItems();
                    }
                    break;

                case "failed":
                    CancelTrade();
                    break;
            }
        }
コード例 #45
0
 public override void OnMessage(string message, EChatEntryType type)
 {
     Bot.SteamFriends.SendChatMessage(OtherSID, type, Bot.ChatResponse);
 }
コード例 #46
0
ファイル: SteamFriends.cs プロジェクト: katsalap/SteamKit
        /// <summary>
        /// Sends a message to a chat room.
        /// </summary>
        /// <param name="steamIdChat">The SteamID of the chat room.</param>
        /// <param name="type">The message type.</param>
        /// <param name="message">The message.</param>
        public void SendChatRoomMessage( SteamID steamIdChat, EChatEntryType type, string message )
        {
            SteamID chatId = steamIdChat.ConvertToUInt64(); // copy the steamid so we don't modify it

            if ( chatId.IsClanAccount )
            {
                // this steamid is incorrect, so we'll fix it up
                chatId.AccountInstance = ( uint )SteamID.ChatInstanceFlags.Clan;
                chatId.AccountType = EAccountType.Chat;
            }

            var chatMsg = new ClientMsg<MsgClientChatMsg>();

            chatMsg.Body.ChatMsgType = type;
            chatMsg.Body.SteamIdChatRoom = chatId;
            chatMsg.Body.SteamIdChatter = Client.SteamID;

            chatMsg.WriteNullTermString( message, Encoding.UTF8 );

            this.Client.Send( chatMsg );
        }
コード例 #47
0
ファイル: UserHandler.cs プロジェクト: kevalane/SteamBot
 public void OnMessageHandler(string message, EChatEntryType type)
 {
     _lastMessageWasFromTrade = false;
     if(!HandleWaitingOnUserResponse(message))
     {
         OnMessage(message, type);
     }
 }
コード例 #48
0
ファイル: KeyUserHandler.cs プロジェクト: aleksasavic3/KeyBot
 public override void OnMessage(string message, EChatEntryType type)
 {
     message = message.ToLower();
     if (message == "price")
     {
         SendChatMessage("I buy keys for " + BuyPricePerKey.ToRefString() + ", and sell keys for " + SellPricePerKey.ToRefString() + ".");
     }
     else if ((message.Contains("love") || message.Contains("luv") || message.Contains("<3")) && (message.Contains("y") || message.Contains("u")))
     {
         if (message.Contains("do"))
         {
             SendChatMessage("I love you lots. <3");
         }
         else
         {
             SendChatMessage("I love you too!");
         }
     }
     else if (message.Contains("<3"))
     {
         SendChatMessage("<3");
     }
     else if (message.Contains("thank"))
     {
         SendChatMessage("You're welcome!");
     }
     else if (message == "donate")
     {
         SendChatMessage("Please type that command into the trade window. And thanks!");
     }
     else if (message == "buy")
     {
         SendChatMessage("That's not a command. Please trade to begin and add keys or metal. Type 'help' for more info.");
     }
     else if (message == "sell")
     {
         SendChatMessage("That's not a command. Please trade to begin and add keys or metal. Type 'help' for more info.");
     }
     else if (message == "trade")
     {
         SendChatMessage("That's not a command. Please trade to begin and add keys or metal. Type 'help' for more info.");
     }
     else if (message.Contains("stupid") || message.Contains("f**k") || message.Contains("can't") || message.Contains("cant") || message.Contains("what"))
     {
         SendChatMessage("Hey, do you need help? Type \"help\" for more info. Or else, are trades failing? Chances are that Steam is having the issues -- not me!");
     }
     else if (message.Contains("help"))
     {
         SendChatMessage("Type \"price\" to see my current prices. Type \"stock\" to see what I have. Then trade me, and put up your keys or metal and I will add my keys or exact price in metal automatically. You MUST put up exact metal if buying keys. Not having a private inventory is often helpful when trades fail. I also accept donations of either keys or metal. To donate, type \"donate\" in the trade window!");
     }
     else if (message == "commands")
     {
         SendChatMessage("Type \"price\" to see my current prices. Type \"stock\" to see what I have. Type \"info\" for more information on this bot via a link to the bot's TF2Outpost page. Type \"help\" for a guide on how to trade with the bot.  To donate, type \"donate\" in the trade window!");
     }
     else if (message == "info")
     {
         SendChatMessage("More information about this bot can be found here: http://www.tf2outpost.com/trade/25788259 .");
     }
     else if (message == "stock" || message == "inventory")
     {
         HasNonTradeCounted = false;
         CountInventory(true);
         if (NonTradeInventoryKeys == 0 && HasNonTradeCounted)
         {
             SendChatMessage("I don't have any keys to sell at the moment.");
             SendChatMessage("I can afford to buy " + NonTradeKeysCanBuy + " key(s). I am buying for " + BuyPricePerKey.ToRefString() + " each.");
         }
         else if (NonTradeInventoryKeys > 0 && HasNonTradeCounted)
         {
             if (NonTradeInventoryMetal < BuyPricePerKey)
             {
                 SendChatMessage("Currently I have " + NonTradeInventoryKeys + " key(s) for " + SellPricePerKey.ToRefString() + " each, but unfortunately I can not afford to buy keys from you at this time.");
             }
             else
             {
                 SendChatMessage("Currently I have " + NonTradeInventoryKeys + " key(s) for " + SellPricePerKey.ToRefString() + " each.");
                 SendChatMessage("I can afford to buy " + NonTradeKeysCanBuy + " key(s). I am buying for " + BuyPricePerKey.ToRefString() + " each.");
             }
         }
         else if (InventoryFailed)
         {
             SendChatMessage("Unable to check inventory due to being unable to get it from Steam. You can probably try again in a few moments if you like.");
             Bot.Log.Warn("Bot notified user of failure to count inventory due to failed Web Request.");
         }
         else
         {
             SendChatMessage("Oh no, I'm broke!");
         }
         if (NonTradeKeysCanBuy > 0 && BuyPricePerKey.ScrapPart > NonTradeScrap && BuyPricePerKey.ReclaimedPart > NonTradeReclaimed + (NonTradeScrap - BuyPricePerKey.ScrapPart) / 3)
         {
             SendChatMessage("I do not have exact change! Open and close a trade with me if you'd like me to make scrap/rec for you.");
             Bot.Log.Warn("Bot warned a user of a lack of scrap or rec during a stock request.");
         }
     }
     else if (IsAdmin)
     {
         if (message.StartsWith(".sell"))
         {
             double NewSellPrice = 0.0;
             SendChatMessage("Current selling price: " + SellPricePerKey.ToRefString() + ".");
             SellPricePerKey = TF2Value.Zero;
             if (message.Length >= 6)
             {
                 double.TryParse(message.Substring(5), out NewSellPrice);
                 Bot.Log.Success("Admin has requested that I set the new selling price to " + NewSellPrice + " ref.");
                 SellPricePerKey = TF2Value.FromRef(NewSellPrice);
                 SendChatMessage("Setting new selling price to: " + SellPricePerKey.ToRefString() + ".");
                 Bot.Log.Success("Successfully set new price.");
             }
             else
             {
                 SendChatMessage("I need more arguments. Current selling price: " + SellPricePerKey.ToRefString() + ".");
             }
         }
         else if (message.StartsWith(".buy"))
         {
             double NewBuyPrice = 0.0;
             SendChatMessage("Current buying price: " + BuyPricePerKey.ToRefString() + ".");
             BuyPricePerKey = TF2Value.Zero;
             if (message.Length >= 5)
             {
                 double.TryParse(message.Substring(4), out NewBuyPrice);
                 Bot.Log.Success("Admin has requested that I set the new buying price to " + NewBuyPrice + " ref.");
                 BuyPricePerKey = TF2Value.FromRef(NewBuyPrice);
                 SendChatMessage("Setting new buying price to: " + BuyPricePerKey.ToRefString() + ".");
                 Bot.Log.Success("Successfully set new price.");
             }
             else
             {
                 SendChatMessage("I need more arguments. Current buying price: " + BuyPricePerKey.ToRefString() + ".");
             }
         }
         else if (message.StartsWith(".play"))
         {
             if (message.Length >= 7)
             {
                 if (message.Substring(6) == "tf2")
                 {
                     Bot.SetGamePlaying(440);
                     Bot.Log.Success("Successfully simulated in-game status for TF2.");
                 }
                 Bot.SetGamePlaying(0);
                 Bot.Log.Success("Exited game simulation.");
             }
         }
         if (message.StartsWith(".removefriend"))
         {
             if (message.Substring(14) == "all")
             {
                 int friendCount = Bot.SteamFriends.GetFriendCount();
                 for (int x = 0; x < friendCount; x++)
                 {
                     SteamID DeletingFriendID = Bot.SteamFriends.GetFriendByIndex(x);
                     if (!Bot.Admins.Contains(DeletingFriendID))
                     {
                         Bot.SteamFriends.RemoveFriend(DeletingFriendID);
                     }
                     else
                     {
                         Bot.Log.Success("Skipped Admin " + Bot.SteamFriends.GetFriendPersonaName(DeletingFriendID) + ".");
                     }
                 }
                 Bot.Log.Success("Deleted all friends.");
             }
             else
             {
                 var EnteredID = Convert.ToUInt64(message.Substring(14));
                 var DeleteID = new SteamID(EnteredID);
                 if (InFriendsList(DeleteID))
                 {
                     Bot.SteamFriends.RemoveFriend(DeleteID);
                     Bot.Log.Success("Deleted " + Bot.SteamFriends.GetFriendPersonaName(DeleteID) + ".");
                 }
                 else
                 {
                     Bot.Log.Error("Failed to remove friend. You typed " + EnteredID + ".");
                 }
             }
         }
         else if (message == ".canceltrade")
         {
             if (Bot.CurrentTrade != null)
             {
                 SteamID LastTradedSID = Trade.OtherSID;
                 Trade.CancelTrade();
                 Bot.SteamFriends.SendChatMessage(LastTradedSID, EChatEntryType.ChatMsg, "Trade forcefully closed. Please retry as soon as you are ready to trade instead of whatever you were doing.");
                 Bot.Log.Warn("Trade with " + Bot.SteamFriends.GetFriendPersonaName(LastTradedSID) + " cancelled.");
                 Bot.SteamFriends.SetPersonaState(EPersonaState.LookingToTrade);
             }
             SendChatMessage("There is no current trade to cancel.");
         }
     }
     else
     {
         SendChatMessage(Bot.ChatResponse);
     }
 }
コード例 #49
0
ファイル: SteamFriends.cs プロジェクト: katsalap/SteamKit
        /// <summary>
        /// Sends a chat message to a friend.
        /// </summary>
        /// <param name="target">The target to send to.</param>
        /// <param name="type">The type of message to send.</param>
        /// <param name="message">The message to send.</param>
        public void SendChatMessage( SteamID target, EChatEntryType type, string message )
        {
            var chatMsg = new ClientMsgProtobuf<CMsgClientFriendMsg>( EMsg.ClientFriendMsg );

            chatMsg.Body.steamid = target;
            chatMsg.Body.chat_entry_type = ( int )type;
            chatMsg.Body.message = Encoding.UTF8.GetBytes( message );

            this.Client.Send( chatMsg );
        }
コード例 #50
0
		/// <summary>
		/// <para> Get a chat message as specified in a LobbyChatMsg_t callback</para>
		/// <para> iChatID is the LobbyChatMsg_t::m_iChatID value in the callback</para>
		/// <para> *pSteamIDUser is filled in with the CSteamID of the member</para>
		/// <para> *pvData is filled in with the message itself</para>
		/// <para> return value is the number of bytes written into the buffer</para>
		/// </summary>
		public static int GetLobbyChatEntry(CSteamID steamIDLobby, int iChatID, out CSteamID pSteamIDUser, byte[] pvData, int cubData, out EChatEntryType peChatEntryType) {
			InteropHelp.TestIfAvailableClient();
			return NativeMethods.ISteamMatchmaking_GetLobbyChatEntry(steamIDLobby, iChatID, out pSteamIDUser, pvData, cubData, out peChatEntryType);
		}
コード例 #51
0
 public override void OnMessage(string message, EChatEntryType type)
 {
     SendChatMessage(Bot.ChatResponse);
 }
コード例 #52
0
		public MsgClientChatMsg()
		{
			steamIdChatter = 0;
			steamIdChatRoom = 0;
			ChatMsgType = 0;
		}
コード例 #53
0
 /// <summary>
 /// Called whenever a message is sent to the bot.
 /// This is limited to regular and emote messages.
 /// </summary>
 public override void OnMessage(string message, EChatEntryType type)
 {
     // TODO: magic command system
 }
コード例 #54
0
		public void Deserialize( Stream stream )
		{
			BinaryReader br = new BinaryReader( stream );

			steamIdChatter = br.ReadUInt64();
			steamIdChatRoom = br.ReadUInt64();
			ChatMsgType = (EChatEntryType)br.ReadInt32();
		}
コード例 #55
0
 /// <summary>
 /// Called whenever a message is sent to the bot.
 /// This is limited to regular and emote messages.
 /// </summary>
 public abstract void OnMessage(string message, EChatEntryType type);
コード例 #56
0
		public static extern int ISteamFriends_GetClanChatMessage(CSteamID steamIDClanChat, int iMessage, IntPtr prgchText, int cchTextMax, out EChatEntryType peChatEntryType, out CSteamID psteamidChatter);
コード例 #57
0
		public static extern int ISteamMatchmaking_GetLobbyChatEntry(CSteamID steamIDLobby, int iChatID, out CSteamID pSteamIDUser, [In, Out] byte[] pvData, int cubData, out EChatEntryType peChatEntryType);
コード例 #58
0
ファイル: AutoTrader.cs プロジェクト: enthdegree/EnthSteamBot
 public override void OnMessage(string message, EChatEntryType type)
 {
     Bot.SteamFriends.SendChatMessage(OtherSID, type, Bot.ChatResponse);
     Bot.SteamFriends.SendChatMessage(OtherSID, type, "Send a trade request and this bot will accept if it is not busy with another user!");
 }
コード例 #59
0
 public void OnMessageHandler(string message, EChatEntryType type)
 {
     if(!HandleWaitingOnUserResponse(message))
     {
         OnMessage(message, type);
     }
 }
コード例 #60
0
 public void ToggleAPICommand(string[] cmd, string search, EChatEntryType type)
 {
     UseGoogleAPI = !UseGoogleAPI;
     if (UseGoogleAPI)
     {
         Bot.SteamFriends.SendChatMessage(OtherSID, type, "The use of Google search API is now enabled.");
     }
     else
     {
         Bot.SteamFriends.SendChatMessage(OtherSID, type, "The use of Google search API is now disabled.");
     }
 }