コード例 #1
0
        public void SendPrivateMessageToUser()
        {
            LoginFile file = GetLoginInformation();

            Task.Run(async() =>
            {
                ELoginResponse response;

                User bUser = null;

                using (BotUser user = new BotUser(file.Username))
                {
                    response = await user.Login(file.Password);

                    if (response == ELoginResponse.Success)
                    {
                        bUser = user.CurrentUser;
                    }

                    Assert.IsTrue(response == ELoginResponse.Success);

                    SendPrivateMessage msg = user.CreatePrivateMessage();

                    msg.Recipient = (User)5762824; // We don't need to give all of the data for the user, just the ID.
                    msg.Body      = "Test Message, using RobloxApi.Bot.";
                    msg.Subject   = "Test Message - Title";

                    bool sendResult = await msg.Send();

                    Assert.IsTrue(sendResult);

                    Console.WriteLine("Message Send: {0}", sendResult);
                }
            }).Wait();
        }
コード例 #2
0
        public void ReplyToPrivateMessage()
        {
            LoginFile file = GetLoginInformation();

            Task.Run(async() =>
            {
                ELoginResponse response;

                User bUser = null;

                using (BotUser user = new BotUser(file.Username))
                {
                    response = await user.Login(file.Password);

                    if (response == ELoginResponse.Success)
                    {
                        bUser = user.CurrentUser;
                    }

                    Assert.IsTrue(response == ELoginResponse.Success);

                    SendPrivateMessage msg = user.CreatePrivateMessage();

                    msg.ReplyMessage           = (PrivateMessage)4952542723; // Hardcoded for now, add a way to get sent, inbox, news, and archive messages.
                    msg.IncludePreviousMessage = true;

                    msg.Recipient = (User)5762824; // We don't need to give all of the data for the user, just the ID.
                    msg.Body      = "Test Message, using RobloxApi.Bot.";
                    msg.Subject   = "Test Message - Title";

                    bool sendResult = await msg.Send();

                    Assert.IsTrue(sendResult);

                    Console.WriteLine("Message Send: {0}", sendResult);
                }
            }).Wait();
        }