Exemple #1
0
        public static TwitterItem writeDirectMessage(AccountTwitter account, string receiver, string text)
        {
            try
            {
                SendDirectMessageOptions options = new SendDirectMessageOptions();
                options.Text       = text;
                options.ScreenName = receiver;
                TwitterDirectMessage status = account.twitterService.SendDirectMessage(options);

                if (status != null)
                {
                    return(API.TweetSharpConverter.getItemFromDirectMessage(status, account));
                }
                else
                {
                    System.Windows.MessageBox.Show("Failed", "Sending of dm failed");
                    return(null);
                }
            }
            catch (Exception exp)
            {
                System.Windows.MessageBox.Show(exp.Message, "Sending of dm failed");
                return(null);
            }
        }
Exemple #2
0
        private static void writeTwitterDMS()
        {
            Requester requester = new Requester();
            string    response  = requester.makeGetHttpRequest("https://api.twitter.com/1.1/followers/ids.json");


            SendDirectMessageOptions options = new SendDirectMessageOptions();

            //options.UserId = J
            options.Text = "dm messages";
            TwitterService       service = new TwitterService(ConsumerKey, ConsumerKeySecret, AccessToken, AccessTokenSecret);
            TwitterDirectMessage dm      = service.SendDirectMessage(options);
        }
        static void SendDM(long id, string msg)
        {
            SendDirectMessageOptions msgOpt = new SendDirectMessageOptions();

            msgOpt.Recipientid = id;
            msgOpt.Text        = msg;
            var result = service.SendDirectMessage(msgOpt, (DirectMessage, response) =>
            {
                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine($"<{DateTime.Now}> - DM Sent!");
                    Console.ResetColor();
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine($"<{DateTime.Now}> - DM Not Sent!");
                    Console.WriteLine(response.StatusCode + " " + response.StatusDescription + " " + response.Error);
                    Console.ResetColor();
                }
            });
        }
Exemple #4
0
        // Discord to DM
        public static async void SendDMAsync(long user, string message)
        {
            string curDir    = Directory.GetCurrentDirectory();
            string credsfile = File.ReadAllText(curDir + "/botsettings.json");

            staticcreds = JsonConvert.DeserializeObject <Config>(credsfile);

            // Pass your credentials to the service
            TwitterService service = new TwitterService(staticcreds.TwitterOauthKey, staticcreds.TwitterOauthSecret);

            // Step 1 - Retrieve an OAuth Request Token
            OAuthRequestToken requestToken = service.GetRequestToken();

            // Step 4 - User authenticates using the Access Token
            service.AuthenticateWith(staticcreds.TwitterAccessToken, staticcreds.TwitterAccessSecret);
            SendDirectMessageOptions dm;

            dm = new SendDirectMessageOptions()
            {
                Recipientid = user, Text = message
            };

            await service.SendDirectMessageAsync(dm);
        }