Esempio n. 1
0
        internal async Task <bool> SendMessage(ulong chatGroupID, ulong chatID, string message)
        {
            if ((chatGroupID == 0) || (chatID == 0) || string.IsNullOrEmpty(message))
            {
                ArchiLogger.LogNullError(nameof(chatGroupID) + " || " + nameof(chatID) + " || " + nameof(message));
                return(false);
            }

            CChatRoom_SendChatMessage_Request request = new CChatRoom_SendChatMessage_Request {
                chat_group_id = chatGroupID,
                chat_id       = chatID,
                message       = message
            };

            SteamUnifiedMessages.ServiceMethodResponse response;

            try {
                response = await UnifiedChatRoomService.SendMessage(x => x.SendChatMessage(request));
            } catch (Exception e) {
                ArchiLogger.LogGenericWarningException(e);
                return(false);
            }

            if (response == null)
            {
                ArchiLogger.LogNullError(nameof(response));
                return(false);
            }

            return(response.Result == EResult.OK);
        }
        internal async Task <EResult> SendMessage(ulong chatGroupID, ulong chatID, string message)
        {
            if ((chatGroupID == 0) || (chatID == 0) || string.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException(nameof(chatGroupID) + " || " + nameof(chatID) + " || " + nameof(message));
            }

            if (!Client.IsConnected)
            {
                return(EResult.NoConnection);
            }

            CChatRoom_SendChatMessage_Request request = new CChatRoom_SendChatMessage_Request {
                chat_group_id = chatGroupID,
                chat_id       = chatID,
                message       = message
            };

            SteamUnifiedMessages.ServiceMethodResponse response;

            try {
                response = await UnifiedChatRoomService.SendMessage(x => x.SendChatMessage(request)).ToLongRunningTask().ConfigureAwait(false);
            } catch (Exception e) {
                ArchiLogger.LogGenericWarningException(e);

                return(EResult.Timeout);
            }

            return(response.Result);
        }
Esempio n. 3
0
        private static async Task SendMessageToGroupChat(string message)
        {
            CChatRoom_SendChatMessage_Request request = new CChatRoom_SendChatMessage_Request {
                chat_group_id = myGroupId,
                chat_id       = defualtChatId,
                message       = message
            };

            await chatRoomService.SendMessage(x => x.SendChatMessage(request));
        }
Esempio n. 4
0
        static void OnLoggedOn()
        {
            // now that we're logged onto Steam, lets query the IPlayer service for our badge levels

            // first, build our request object, these are autogenerated and can normally be found in the SteamKit2.Unified.Internal namespace
            //CPlayer_GetGameBadgeLevels_Request req = new CPlayer_GetGameBadgeLevels_Request {
            //    // we want to know our 440 (TF2) badge level
            //    appid = 440,
            //};

            bool send_chat = true;

            if (send_chat)
            {
                {
                    // ha ezt küldöd, akkor fogsz notificationoket kapni
                    uint chatMode = 2;
                    ClientMsgProtobuf <CMsgClientUIMode> request = new ClientMsgProtobuf <CMsgClientUIMode>(EMsg.ClientCurrentUIMode)
                    {
                        Body = { chat_mode = chatMode }
                    };
                    steamClient.Send(request);
                }



                CChatRoom_SendChatMessage_Request req = new CChatRoom_SendChatMessage_Request {
                    message                = "Bot logged in.",
                    messageSpecified       = true,
                    chat_group_id          = myGroupId,
                    chat_group_idSpecified = true,
                    chat_id                = defualtChatId,
                    chat_idSpecified       = true
                };
                chatRoomService.SendMessage(x => x.SendChatMessage(req));
            }
            else
            {
                CChatRoom_GetMyChatRoomGroups_Request req = new CChatRoom_GetMyChatRoomGroups_Request {
                    // empty message
                };


                // now lets send the request, this is done by building an expression tree with the IPlayer interface
                myJobID = chatRoomService.SendMessage(x => x.GetMyChatRoomGroups(req));
            }



            // alternatively, the request can be made using SteamUnifiedMessages directly, but then you must build the service request name manually
            // the name format is in the form of <Service>.<Method>#<Version>
            //steamUnifiedMessages.SendMessage("Player.GetGameBadgeLevels#1", req);
        }
Esempio n. 5
0
        protected override void OnMessage(MessageDetails msgDetails)
        {
            // TODO: Do the thing
            var request = new CChatRoom_SendChatMessage_Request
            {
                chat_group_id = 17013,  // must be valid
                chat_id       = 289194, // must be valid
                message       = $"<{msgDetails.Sender}> {msgDetails.Message}"
            };

            Steam.Instance.Unified.SendMessage("ChatRoom.SendChatMessage#1", request);
        }
Esempio n. 6
0
        private static async Task OnIncomingChatMessage(CChatRoom_IncomingChatMessage_Notification notification)
        {
            Console.WriteLine($"from: {notification.steamid_sender}\n message : {notification.message} \n");

            if (notification.message == "ping")
            {
                CChatRoom_SendChatMessage_Request request = new CChatRoom_SendChatMessage_Request {
                    chat_group_id = notification.chat_group_id,
                    chat_id       = notification.chat_id,
                    message       = "pong"
                };

                await chatRoomService.SendMessage(x => x.SendChatMessage(request));
            }

            pipeHandler.RelayMessage(notification);
        }