Beispiel #1
0
 internal async void OnFriendMessage(SteamFriends.FriendMsgCallback callback)
 {
     if (callback.EntryType == EChatEntryType.ChatMsg)
     {
         Response(callback.Message, callback.Sender);
     }
 }
Beispiel #2
0
 private static void RecognizeMessage(SteamFriends.FriendMsgCallback obj)
 {
     Console.Write("\t\tCommand recognized ");
     Console.ForegroundColor = ConsoleColor.Blue;
     Console.WriteLine(obj.Message);
     Console.ResetColor();
 }
Beispiel #3
0
        public void OnChatMessage(SteamFriends.FriendMsgCallback callback)
        {
            if (callback.Message == ".trade")
            {
            }
            if (callback.Message == ".sleep")
            {
                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "hehe xd bye");
                steamClient.Disconnect();
                Environment.Exit(0);
            }
            if (callback.Message == ".ping")
            {
                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "pong!:chocola3:");
            }
            if (callback.Message == ".help")
            {
                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "\n.ping:chocola3:\n.sleep:chocola3:\n.say (text):chocola3:");
            }
            if (callback.Message.Contains(".say"))
            {
                string xd = callback.Message.Replace(".say ", "");
                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, xd);
            }
            UInt64 IDD = 76561198058269957;

            if (callback.Message != String.Empty)
            {
                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "am at work, so afking nekopara");
            }
        }
Beispiel #4
0
 private void OnFriendMsg(SteamFriends.FriendMsgCallback callback)
 {
     if (callback.EntryType != EChatEntryType.ChatMsg)
     {
         ModuleManager.FriendMessageSent(callback, MessageToArgs(callback.Message));
     }
 }
Beispiel #5
0
        /// <summary>
        /// When a private message is received, signal the modules.
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="args"></param>
        public void FriendMessageSent(SteamFriends.FriendMsgCallback callback, string[] args)
        {
            var modules = _globalModules.Values.ToList();

            // Get all modules
            foreach (var chatKV in _chatroomModules)
            {
                modules.AddRange(chatKV.Value.Values);
            }

            foreach (var module in modules)
            {
                module.OnFriendMessage(callback, args);

                var command = module.FindCommand(args);

                // If FindCommand returned something, execute it.
                if (command.HasValue)
                {
                    try
                    {
                        command.Value.Callback(callback, args);
                    }
                    catch (Exception e)
                    {
                        PrintStackFrame(e);
                    }
                }
            }
        }
Beispiel #6
0
 static void OnFriendMsg(SteamFriends.FriendMsgCallback callback)
 {
     if (callback.EntryType == EChatEntryType.ChatMsg)
     {
         CommandHandler.AddTask(callback.Sender, callback.Message);
     }
 }
Beispiel #7
0
 private void OnSteamFriendMessage(SteamFriends.FriendMsgCallback callback)
 {
     if (callback.EntryType == EChatEntryType.ChatMsg)
     {
         steamchatHandler.HandleMessage(callback.Sender, callback.Message);
     }
 }
 private void chatMessageCallback(SteamFriends.FriendMsgCallback callback)
 {
     if (base.listenCallback != null && callback.Sender == this.id && callback.EntryType == EChatEntryType.ChatMsg)
     {
         base.ListenCallback(base.createMessageLabel(this.getPrifix(callback.Sender) + callback.Message));
     }
 }
Beispiel #9
0
        private void OnFriendMsg(SteamFriends.FriendMsgCallback callback)
        {
            if (callback == null)
            {
                return;
            }

            if (callback.EntryType != EChatEntryType.ChatMsg)
            {
                return;
            }

            ulong steamID = callback.Sender;

            if (steamID != SteamMasterID)
            {
                return;
            }

            string message = callback.Message;

            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            if (message.Length == 17 && message[5] == '-' && message[11] == '-')
            {
                ArchiHandler.RedeemKey(message);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Fires when the bot receives a steam chat message from someone on their friendlist
        /// </summary>
        /// <param name="callback"></param>
        private void OnFriendMsgCallback(SteamFriends.FriendMsgCallback callback)
        {
            if (callback.EntryType == EChatEntryType.ChatMsg)
            {
                /*Log the message we just received*/
                string friendUserName = mSteam.friends.GetFriendPersonaName(callback.Sender);
                mLogChat.Write(Log.LogLevel.Text, $"Msg from {friendUserName}: {callback.Message}");

                /*Clear blocked users that are older than 10 minutes
                 * This is to avoid responding every time a user is spamming us in the chat*/
                mSteamChatBlockList.RemoveAll(data => DateTime.Now.Subtract(data.DateReceived) > TimeSpan.FromMinutes(10));

                /*Only send a response if one is set in the settings file*/
                if (!string.IsNullOrWhiteSpace(mAccountSettings.ChatResponse))
                {
                    /*Set up ChatMessageData object*/
                    var msgData = new ChatMessageData()
                    {
                        AccountId    = callback.Sender.AccountID,
                        DateReceived = DateTime.Now
                    };

                    /*Check if the list of blocked users contains the sender*/
                    if (mSteamChatBlockList.Any(o => o.AccountId == msgData.AccountId))
                    {
                        return;
                    }

                    /*Respond to user*/
                    mSteam.friends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, mAccountSettings.ChatResponse);
                    mLogChat.Write(Log.LogLevel.Info, $"Responded to {friendUserName}");
                    mSteamChatBlockList.Add(msgData);
                }
            }
        }
Beispiel #11
0
 private void OnChatMessage(SteamFriends.FriendMsgCallback callback)
 {
     if (callback.EntryType == EChatEntryType.ChatMsg)
     {
         AsyncCompleter(this.EventForwarder.OnChatMessage(this, callback.Sender, callback.Message));
     }
 }
Beispiel #12
0
        private static void OnFriendMsg(SteamFriends.FriendMsgCallback obj)
        {
            string[] ParamsSepearator = obj.Message.Split(' ');

            if (Commands.ContainsKey(ParamsSepearator[0]))
            {
                for (int i = 1; i < ParamsSepearator.Length; i++)
                {
                    for (int a = 0; a < Argument.Length; a++)
                    {
                        try
                        {
                            Argument[a] = ParamsSepearator[i];
                        }
                        catch { }
                        i += 1;
                    }
                }
                steamIDMemory = obj.Sender;
                ExecuteCommand(ParamsSepearator[0]);
            }
            else
            {
                //checkpoint2525
                steamIDMemory = obj.Sender;

                ReloadMemoria();
                if (bManager.getResponse(obj.Message).Replace("#", String.Empty).Replace("-", String.Empty).Length > 1)
                {
                    steamFriends.SendChatMessage(steamIDMemory, EChatEntryType.ChatMsg, bManager.getResponse(obj.Message).Replace("#", String.Empty).Replace("-", String.Empty));
                }
            }
        }
Beispiel #13
0
        private static void OnChatMsg(SteamFriends.FriendMsgCallback callback)
        {
            string mate    = callback.Message.ToLower();
            string command = "";
            string value   = "";

            if (callback.EntryType == EChatEntryType.ChatMsg)
            {
                if (mate.Length > 1)
                {
                    if (mate.Remove(1) == "!")
                    {
                        command = mate.Substring(1, mate.Length - 1);
                        if (mate.Contains(" "))
                        {
                            value   = command.Substring(command.IndexOf(' ') + 1, command.Length - command.IndexOf(' ') - 1);
                            command = command.Remove(command.IndexOf(' '));
                            Console.WriteLine(command);
                            Console.WriteLine(value);
                        }
                        CommandResolver(command, value, callback.Sender.ConvertToUInt64().ToString(), callback.Sender);
                    }
                }
                friends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, respondmsg);
                Console.WriteLine("[{2}] MSR - SteamID {0} :  {1}", callback.Sender, respondmsg, DateTime.Now.ToString());
                respondmsg = "Hello, Tôi đéo hiểu bạn nói gì";
            }
        }
Beispiel #14
0
 static void OnFriendMsg(SteamFriends.FriendMsgCallback callback)
 {
     if (callback.EntryType == EChatEntryType.ChatMsg)
     {
         UserHandler.steamBotCommandsHandling(callback.Message, callback.Sender, 0);
     }
 }
Beispiel #15
0
 static void OnMsgReceived(SteamFriends.FriendMsgCallback callback)
 {
     Console.WriteLine("Message from {0}: {1}",
                       Steam3.SteamFriends.GetFriendPersonaName(callback.Sender),
                       callback.Message
                       );
 }
Beispiel #16
0
        void OnFriendMessage(SteamFriends.FriendMsgCallback cb)
        {
            Log.WriteLine("Msg from {0} {1} {2} \"{3}\"", cb.Sender, cb.EntryType, (int)cb.EntryType, cb.Message);

            var room_id = cb.Sender;

            var room = ChatRoom.Active.FindOrCreate(room_id);

            room.Messages.Add(new ChatMessage {
                Message = cb.Message, Sender = cb.Sender, Type = cb.EntryType
            });

            // TODO: Thread safety
            var message_index = room.Messages.Count - 1;

            var b = new Core.Util.Buffer();

            b.SetAlignment(4);

            b.WriteULong(cb.Sender);
            b.WriteULong(cb.Sender);
            b.Write((byte)cb.EntryType);
            b.Write((byte)(cb.FromLimitedAccount ? 1 : 0));
            // b.Write((byte)0);
            b.Write((uint)message_index);

            Instance.PostCallback(Common.CallbackId(Common.CallbackType.ClientFriends, 5), b);
        }
Beispiel #17
0
        static void OnChatMessage(SteamFriends.FriendMsgCallback callback)

        {
            if (callback.EntryType == EChatEntryType.ChatMsg)
            {
                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "А вы знаете, насколько сложно было выполнить эту лабораторную работу человеку, который вообще не шарит в программировании? А? А? А? А?");
            }
        }
Beispiel #18
0
 static void OnFriendMsg(SteamFriends.FriendMsgCallback callback)
 {
     if (callback.EntryType == EChatEntryType.ChatMsg)
     {
         // use the factory to get an appropriate object correlating to the action
         commandFactory.ParseChatText(new BotContext(null, callback.Sender, callback.Message.Trim(), steamFriends));
     }
 }
Beispiel #19
0
 public override void OnFriendMsg(SteamFriends.FriendMsgCallback callback)
 {
     if (SteamNerd.Chatrooms.Count != 0)
     {
         var chat = SteamNerd.Chatrooms.First();
         SteamNerd.SteamFriends.InviteUserToChat(callback.Sender, chat.Key);
     }
 }
Beispiel #20
0
 static void OnFriendMsg(SteamFriends.FriendMsgCallback callback)
 {
     Log.Instance.Info("Friend Msg " + callback.EntryType + " " + callback.Sender + ": " + callback.Message);
     foreach (BaseTrigger trigger in triggers)
     {
         trigger.OnFriendMessage(callback.Sender, callback.Message, true);
     }
 }
Beispiel #21
0
 static void OnChatMessage(SteamFriends.FriendMsgCallback callback)
 {
     if (callback.EntryType == EChatEntryType.ChatMsg)
     {
         fObject.updateChatLog(new Friend()
         {
             steamFrindsID = callback.Sender.ConvertToUInt64().ToString()
         }, callback.Message.ToString(), false);
     }
 }
        //TODO Lets Turn the following four into events, so errors aren't thrown if a userhandler doesn't exist
        private void ReceivePrivateMessage(SteamFriends.FriendMsgCallback callback)
        {
            MessageEventArgs NewMessageData = new MessageEventArgs(this);

            NewMessageData.ReceivedMessage    = callback.Message;
            NewMessageData.Sender             = new ChatroomEntity(callback.Sender.ConvertToUInt64(), this);
            NewMessageData.Destination        = NewMessageData.Sender;
            NewMessageData.Sender.DisplayName = SteamFriends.GetFriendPersonaName(callback.Sender);
            NewMessageData.Sender.UserURL     = "http://steamcommunity.com/profiles/" + callback.Sender.ConvertToUInt64();
            base.PrivateMessageProcessEvent(NewMessageData);
        }
            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);
                }
            }
Beispiel #24
0
        public void HandleCallback(CallbackMsg msg)
        {
            if (msg.IsType <SteamUser.LoginKeyCallback>())
            {
                GetClient().Friends.SetPersonaState(EPersonaState.Online);

                Friend.Me      = new Friend(GetClient().User.GetSteamID());
                Friend.Me.Name = "me";

                SteamAlerts.ShowToast("Connected to Steam");
            }
            else if (msg.IsType <SteamUser.LogOnCallback>())
            {
                SteamUser.LogOnCallback callback = (SteamUser.LogOnCallback)msg;

                if (callback.Result == EResult.OK)
                {
                    EnableAutoReconnect();
                }
                else
                {
                    DisableAutoReconnect();
                }
            }
            else if (msg.IsType <SteamFriends.FriendMsgCallback>())
            {
                SteamFriends.FriendMsgCallback callback = (SteamFriends.FriendMsgCallback)msg;

                if (callback.EntryType == EChatEntryType.ChatMsg)
                {
                    Friend friend = Friend.GetFriendBySteamId(callback.Sender.ToString());

                    if (friend != activeChat)
                    {
                        Intent intent = new Intent(SteamAlerts.GetContext(), typeof(Chat));
                        intent.SetAction("chat_notification_" + DateTime.Now.Ticks);
                        intent.PutExtra("steam_id", friend.SteamId.ToString());

                        SteamAlerts.Notification("Message from " + friend.Name, friend.Name + ": " + callback.Message, callback.Message, intent, "steam_id", friend.SteamId.ToString());
                        SteamAlerts.PlaySound();
                        SteamAlerts.Vibrate(400);
                    }
                }
            }
            else if (msg.IsType <SteamClient.ConnectCallback>())
            {
                SteamAlerts.Notification("Steam Droid", "Connected to Steam", "Connected to Steam", new Intent(SteamAlerts.GetContext(), typeof(Main)), null, null);
            }
            else if (msg.IsType <SteamClient.DisconnectCallback>())
            {
                SteamAlerts.Notification("Steam Droid", "Disconnected from Steam", "Connected to Steam", new Intent(SteamAlerts.GetContext(), typeof(Main)), null, null);
                SteamAlerts.ShowToast("Disconnected from Steam");
            }
        }
Beispiel #25
0
        public void HandleCallback(CallbackMsg msg)
        {
            if (msg.IsType <SteamClient.ConnectCallback>())
            {
                Logger.Get().Log("[Callback] Connected");
            }
            else if (msg.IsType <SteamClient.DisconnectCallback>())
            {
                Logger.Get().Log("[Callback] Disconnected");
                IsAuthorized = false;
                Send(Protocol.Server.LoggedOut);
            }
            else if (msg.IsType <SteamUser.LogOnCallback>())
            {
                SteamUser.LogOnCallback callback = (SteamUser.LogOnCallback)msg;

                Logger.Get().Log("[Callback] Logon: " + callback.Result + "/" + callback.ExtendedResult);

                if (callback.Result == EResult.AccountLogonDenied || callback.Result == EResult.InvalidLoginAuthCode)
                {
                    Send(Protocol.Server.AuthRequest);
                    IsAuthorized = true;
                }

                if (callback.Result == EResult.OK)
                {
                    IsAuthorized = true;
                }
            }
            else if (msg.IsType <SteamUser.LoginKeyCallback>())
            {
                Logger.Get().Log("[Callback] Logged in, setting persona state to online");

                steam.Friends.SetPersonaState(SteamKit2.EPersonaState.Online);

                Send(Protocol.Server.LoggedIn);
            }
            else if (msg.IsType <SteamFriends.FriendMsgCallback>())
            {
                SteamFriends.FriendMsgCallback chat = (SteamFriends.FriendMsgCallback)msg;
                if (chat.EntryType == EChatEntryType.ChatMsg)
                {
                    Send(Protocol.Server.ChatReceived, chat.Sender.ToString(), chat.Message);
                }
            }
            else if (msg.IsType <SteamFriends.PersonaStateCallback>())
            {
                SteamFriends.PersonaStateCallback friend = (SteamFriends.PersonaStateCallback)msg;
                Send(Protocol.Server.FriendStateChanged, friend.FriendID.ToString(), friend.State.ToString(), friend.GameName);
            }
        }
Beispiel #26
0
        static void OnFriendMsg(SteamFriends.FriendMsgCallback callback)
        {
            if (callback.EntryType == EChatEntryType.ChatMsg)
            {
                var Settingslist = JsonConvert.DeserializeObject <ChatLoggerSettings>(File.ReadAllText(Program.SettingsJsonFile));


                ulong  FriendID = callback.Sender;
                string Message  = callback.Message;

                string FriendName = steamFriends.GetFriendPersonaName(FriendID);
                string nameClean  = Regex.Replace(FriendName, "[^A-Za-z0-9 _]", "");

                string FriendIDName = @"\[" + FriendID + "] - " + nameClean + ".txt";
                string pathLog      = Settingslist.PathLogs + @"\" + steamClient.SteamID.ConvertToUInt64() + FriendIDName;

                string FinalMsg = "[" + DateTime.Now + "] " + FriendName + ": " + Message;

                // Console.WriteLine("\nYou received a message by " + FriendName + "\n Telling you: " + Message);

                LastMessageReceived = "[" + DateTime.Now.ToString("HH:mm:ss") + "] " + FriendName.Replace(":", "") + ": " + Message;

                if (!Directory.Exists(Settingslist.PathLogs + @"\" + steamClient.SteamID.ConvertToUInt64()))
                {
                    Directory.CreateDirectory(Settingslist.PathLogs + @"\" + steamClient.SteamID.ConvertToUInt64());
                }

                string[] files = Directory.GetFiles(Settingslist.PathLogs + @"\" + steamClient.SteamID.ConvertToUInt64(), "[" + FriendID + "]*.txt");

                if (files.Length > 0)//file exist
                {
                    string[] LastDate = File.ReadLines(files[0]).Last().Split(' '); LastDate[0] = LastDate[0].Substring(1);

                    using (var tw = new StreamWriter(files[0], true))
                        if (LastDate[0] != DateTime.Now.Date.ToShortDateString())
                        {
                            tw.WriteLine(Settingslist.Separator + "\n" + FinalMsg);
                        }
                        else
                        {
                            tw.WriteLine(FinalMsg);
                        }
                }
                else
                {
                    FileInfo file = new FileInfo(pathLog);
                    file.Directory.Create();
                    File.WriteAllText(pathLog, FinalMsg + "\n");
                }
            }
        }
Beispiel #27
0
 public void OnFriendMessage(SteamFriends.FriendMsgCallback callback, string[] args)
 {
     if (FriendMessage != null)
     {
         try
         {
             FriendMessage(callback, args);
         }
         catch (Exception e)
         {
             ModuleManager.PrintStackFrame(e);
         }
     }
 }
Beispiel #28
0
        public void HandleCallback(CallbackMsg msg)
        {
            if (msg.IsType <SteamFriends.FriendMsgCallback>())
            {
                SteamFriends.FriendMsgCallback callback = (SteamFriends.FriendMsgCallback)msg;

                if (callback.EntryType == EChatEntryType.ChatMsg && callback.Sender == friend.SteamId)
                {
                    ChatMessage message = new ChatMessage(friend, callback.Message);
                    Add(message);
                    NotifyDataSetChanged();
                }
            }
        }
Beispiel #29
0
        private void OnFriendMsg(SteamFriends.FriendMsgCallback callback)
        {
            if (callback.EntryType == EChatEntryType.ChatMsg)
            {
                var sender = callback.Sender;

                Friend currentChatter = Chatters.FirstOrDefault(chatter => chatter.SteamID.AccountID == sender.AccountID);

                if (currentChatter == null)
                {
                    currentChatter = new Friend()
                    {
                        WelcomedDate       = DateTime.Now,
                        ChatState          = ChatState.NoInteraction,
                        SteamID            = sender,
                        IsReceivingAdvInfo = false
                    };

                    Chatters.Add(currentChatter);
                }

                TimeSpan timeSpan = DateTime.Now - currentChatter.WelcomedDate;
                if (timeSpan.Minutes >= 5)
                {
                    currentChatter.ChatState = ChatState.NoInteraction;
                }

                string responseMessage = String.Empty;
                if (BasicCommands.ContainsKey(callback.Message))
                {
                    responseMessage          = BasicCommands[callback.Message];
                    currentChatter.ChatState = ChatState.Welcomed;
                }
                else if (currentChatter.ChatState == ChatState.NoInteraction)
                {
                    currentChatter.ChatState = ChatState.Welcomed;
                    responseMessage          = WelcomeMessage;
                }
                else if (currentChatter.ChatState == ChatState.Welcomed)
                {
                    responseMessage = CommandNotFoundMessage;
                }

                SteamFriends.SendChatMessage(sender, EChatEntryType.ChatMsg, responseMessage);

                Console.WriteLine($"{SteamFriends.GetFriendPersonaName(sender)}: {callback.Message}");
                Console.WriteLine($"BOT: {responseMessage}");
            }
        }
Beispiel #30
0
 private static void OnFriendMsg(SteamFriends.FriendMsgCallback callback)
 {
     if (callback.EntryType == EChatEntryType.ChatMsg)
     {
         Log.Instance.Info("Friend Msg " + callback.EntryType + " " + callback.Sender + ": " + callback.Message);
         foreach (BaseTrigger trigger in triggers)
         {
             trigger.OnFriendMessage(callback.Sender, callback.Message, true);
         }
     }
     else
     {
         Log.Instance.Silly("Friend Msg " + callback.EntryType + " " + callback.Sender + ": " + callback.Message);
     }
 }