Пример #1
0
        static void Main(string[] args)
        {
            Contact   owner     = new Contact("grupo3");
            Phonebook phonebook = new Phonebook(owner);

            Contact nacho = phonebook.AddContact("nacho");

            nacho.TwitterId = "1203382413524688896";
            nacho.Phone     = "+59891026239";

            Contact jero = phonebook.AddContact("jero");

            jero.Phone = "+59899382129";

            Contact rodri = phonebook.AddContact("rodri");

            rodri.Phone = "+59895032980";

            IMessageChannel channel = new TwitterChannel();

            //channel = new WhatsappChannel();
            phonebook.SendMessage(new string[1] {
                "nacho"
            }, "Prueba twitter", channel);
        }
Пример #2
0
        public IMessage GetTweet(EditNull n, IMessage m, string tweetID)
        {
            long id = Convert.ToInt64(tweetID.Split('/').Last().Split('?').First());

            var channel = new TwitterChannel(Program.twitterService.GetTweet(new GetTweetOptions()
            {
                Id = id, IncludeEntities = true
            }), Program.twitterService);

            return(channel.InitialMessage);
        }
Пример #3
0
        static void Main(string[] args)
        {
            Phonebook ContactList = new Phonebook(new Contact("Martin"));

            ContactList.AddNewContact("Test", "+59891611429", "3645352517");

            List <Contact> FoundContacts = ContactList.Search(new string [] { "Test" });

            Console.WriteLine(FoundContacts[0].Name + " " + FoundContacts[0].TwitterID);

            IMessageChannel TwitterChannel = new TwitterChannel();
            IMessageChannel WppChannel     = new WppChannel();

            ContactList.Send(FoundContacts[0], "BLABLA", TwitterChannel);
            ContactList.Send(FoundContacts[0], "Hey there! I'm using WhatsAppUCU", WppChannel);
        }
        static void StartTwitterLoop()
        {
            long lastMentionId = twitterService.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions()
            {
                Count = 1
            }).Last().Id;

            TweetSharpWrapper.PrintTwitterRateLimitStatus(twitterService);

            while (true)
            {
                var mentions = twitterService.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions()
                {
                    SinceId = lastMentionId
                });
                if (mentions != null)
                {
                    foreach (var m in mentions.Reverse())
                    {
                        ConsoleWrapper.WriteLine($"{DateTime.Now.ToLongTimeString()} Recieved Tweet: " + m.Text);

                        try
                        {
                            TwitterChannel c = new TwitterChannel(m, twitterService);
                            TweetSharpWrapper.PrintTwitterRateLimitStatus(twitterService);
                            if (c.InitialMessage.Content.StartsWith(Program.Prefix))
                            {
                                Task.Run(() => Program.ParallelMessageReceived(c.InitialMessage));
                            }
                        }
                        catch (Exception e)
                        {
                            ConsoleWrapper.WriteLine("Error handling Tweet: " + e);
                        }

                        lastMentionId = m.Id;
                    }
                }

                Thread.Sleep(45000); // 48 seconds times 75 hourly allowed hits would exactly be one hour
            }
        }
Пример #5
0
        private static void Main()
        {
            var appSettings = GetAppStore(APP_PREFIX).Load();
            var userStore   = GetUserStore(FILENAME);

            var loader     = new DefaultTokenLoader(appSettings, userStore);
            var authorizer = new ConsoleAuthorizer(appSettings);

            var safeLoader     = new AuthorizingTokenLoader(loader, authorizer, userStore);
            var tokens         = safeLoader.Load();
            var channel        = new TwitterChannel(tokens);
            var channelAdapter = new TwitterChannelAdapter(channel, new NullAccountRepository());

            var interpreter = new Interpreter(new FakeCommandParser());
            var monitor     = new ChannelMonitor(interpreter);

            Console.WriteLine("Monitoring...");
            monitor.Monitor(channelAdapter);
            Console.ReadLine();
        }
Пример #6
0
        static void Main(string[] args)
        {
            Contact dueño     = new Contact("NombreDueño", "0999999", "dueñ[email protected]");
            Contact contacto1 = new Contact("Nombre1", "+59899742172", "*****@*****.**");

            contacto1.TwitterID = "13960658118";
            Contact contacto2 = new Contact("Nombre2", "+59899742172", "*****@*****.**");

            contacto2.TwitterID = "2230668516";

            Phonebook lista = new Phonebook(dueño);

            lista.AddContact(contacto1);
            lista.AddContact(contacto2);

            Message mensajeW = new Message(contacto1, contacto2);

            mensajeW.Text = "Hola";
            WhatsAppChannel wpp = new WhatsAppChannel();

            wpp.Send(mensajeW);

            Message mensajeT = new Message(contacto1, contacto2);

            mensajeT.Text = "Hola";
            TwitterChannel twitter = new TwitterChannel();

            twitter.Send(mensajeT);

            // Crear el contacto dueño

            // Crear la lista de contactos

            // Agregar contactos a la lista

            // Enviar un correo a algunos contactos

            // Enviar un WhatsApp a algunos contactos

            // Enviar un SMS a algunos contactos
        }
Пример #7
0
        static void Main(string[] args)
        {
            // Crear el contacto dueño
            Contact contact = new Contact("Test");

            // Crear la lista de contactos
            Phonebook phonebook = new Phonebook(contact);

            // Agregar contactos a la lista
            phonebook.AddContact("Gms", null, "+11111111111");

            // Enviar un correo a algunos contactos


            // Enviar un WhatsApp a algunos contactos
            Message wppMsg = new Message("Gms", "+11111111111");

            wppMsg.Text = "Mensaje de prueba2";

            const string    accountSid = "";
            const string    authToken  = "";
            IMessageChannel wppChannel = new WhatsAppMessageChanel(accountSid, authToken);

            phonebook.SendMessage(wppChannel, wppMsg, new string[] { "Gms" });

            // Enviar un mensaje por Twitter a algunos contactos

            string         consumerKey       = "";
            string         consumerKeySecret = "";
            string         accessToken       = "";
            string         accessTokenSecret = "";
            TwitterChannel twitter           = new TwitterChannel(consumerKey, consumerKeySecret, accessToken, accessTokenSecret);

            phonebook.AddContact("Gio", "809185528457338880");
            Message twittermessage = new Message("PooUcu", "809185528457338880");

            twittermessage.Text = "Hola! Todo bien?";
            phonebook.SendMessage(twitter, twittermessage, new string[] { "Gio" });
        }
Пример #8
0
        public static void CallObserverPattern()
        {
            var myYouTubeChannel = new YouTubeChannel();
            var myTwitterChannel = new TwitterChannel();

            //subscriber list
            ISubscriber prem1 = new PremiumSubscriber();
            ISubscriber prem2 = new PremiumSubscriber();
            ISubscriber prem3 = new PremiumSubscriber();
            ISubscriber reg1  = new RegularSubscriber();
            ISubscriber reg2  = new RegularSubscriber();
            ISubscriber mod1  = new Moderator();
            ISubscriber mod2  = new Moderator();

            //register subscribers  YouTube Channel
            myYouTubeChannel.registerSubscriber(prem1);
            myYouTubeChannel.registerSubscriber(prem2);
            myYouTubeChannel.registerSubscriber(prem3);
            myYouTubeChannel.registerSubscriber(reg1);
            myYouTubeChannel.registerSubscriber(reg2);
            myYouTubeChannel.registerSubscriber(mod1);
            myYouTubeChannel.registerSubscriber(mod2);
            //register subscribers  YouTube Channel
            myTwitterChannel.registerSubscriber(prem1);
            myTwitterChannel.registerSubscriber(reg1);
            myTwitterChannel.registerSubscriber(reg2);
            myTwitterChannel.registerSubscriber(mod1);

            Console.WriteLine("----------------------------------- registered youtube");
            Console.WriteLine("prem1 registered for youtube channel");
            Console.WriteLine("prem2 registered for youtube channel");
            Console.WriteLine("prem3 registered for youtube channel");
            Console.WriteLine("reg1 registered for youtube channel");
            Console.WriteLine("reg2 registered for youtube channel");
            Console.WriteLine("mod1 registered for youtube channel");
            Console.WriteLine("mod2 registered for youtube channel");

            Console.WriteLine("----------------------------------- notify subscribers - youtube");
            myYouTubeChannel.notifySubscribers();

            Console.WriteLine("----------------------------------- registered twitter");
            Console.WriteLine("prem1 registered for twitter channel");
            Console.WriteLine("reg1 registered for twitter channel");
            Console.WriteLine("reg2 registered for twitter channel");
            Console.WriteLine("mod1 registered for twitter channel");

            //notify subscribers
            Console.WriteLine("----------------------------------- notify subscribers - twitter");
            myTwitterChannel.notifySubscribers();

            //pause
            Console.WriteLine("-------------------------------");
            Console.WriteLine("Click button to continue");
            Console.ReadKey();

            //unregister some of the subscribers  YouTube Channel
            myYouTubeChannel.unregisterSubscriber(prem1);
            myYouTubeChannel.unregisterSubscriber(prem3);
            myYouTubeChannel.unregisterSubscriber(reg2);
            myYouTubeChannel.unregisterSubscriber(mod2);
            Console.WriteLine("----------------------------------- unregistered youtube");
            Console.WriteLine("prem1 unregistered for youtube channel");
            Console.WriteLine("prem3 unregistered for youtube channel");
            Console.WriteLine("reg2 unregistered for youtube channel");
            Console.WriteLine("mod2 unregistered for youtube channel");

            Console.WriteLine("----------------------------------- notify subscribers - youtube");
            myYouTubeChannel.notifySubscribers();

            Console.WriteLine("-----------------------------------");

            myTwitterChannel.unregisterSubscriber(prem1);
            myTwitterChannel.unregisterSubscriber(prem2);
            myTwitterChannel.unregisterSubscriber(reg1);
            myTwitterChannel.unregisterSubscriber(mod1);
            Console.WriteLine("----------------------------------- unregistered twitter");
            Console.WriteLine("prem1 unregistered for twitter channel");
            Console.WriteLine("prem2 unregistered for twitter channel");
            Console.WriteLine("reg1 unregistered for twitter channel");
            Console.WriteLine("mod1 unregistered for twitter channel");

            //notify subscribers
            Console.WriteLine("----------------------------------- notify subscribers - twitter");
            myTwitterChannel.notifySubscribers();

            Console.WriteLine("-----------------------------------");
        }