Example #1
0
 public SkypeAdapter()
 {
     ((_ISkypeEvents_Event)skype).AttachmentStatus += status =>
     {
         if (status == TAttachmentStatus.apiAttachAvailable)
         {
             skype.Attach(Wait: false);
         }
     };
 }
Example #2
0
 private void LinkSkypeProcess_Click(object sender, EventArgs e)
 {
     try
     {
         SkypeAPI.Attach(5, true);
         try
         {
             skypeGroupbox1.Enabled   = true;
             skypeGroupbox2.Enabled   = true;
             skypeGroupbox3.Enabled   = true;
             skypeCallButton1.Visible = true;
             SendMessage.Visible      = true;
             GetContactsList();
             GetProfilInfos();
         }
         catch
         {
             MessageBox.Show("Error", "Can't Get your infos...", MessageBoxButtons.OK, MessageBoxIcon.Hand);
         }
     }
     catch
     {
         MessageBox.Show("Error", "Can't Link Process", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
 }
Example #3
0
        static void Main(string[] args)
        {
            bot = new HelloBot();
            bot.OnErrorOccured += BotOnErrorOccured;
            Task.Run(delegate
            {
                try
                {
                    skype.MessageStatus += OnMessageReceived;
                    skype.Attach(5, true);
                    chatSyncer = new SkypeChatSyncer();
                    chatSyncer.OnSendMessageRequired += ChatSyncerOnOnSendMessageRequired;
                    Console.WriteLine("skype attached");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("top lvl exception : " + ex.ToString());
                }
                while (true)
                {
                    Thread.Sleep(1000);
                }
            });

            while (true)
            {
                Thread.Sleep(1000);
            }
        }
Example #4
0
 public bool InitSkype()
 {
     try
     {
         if (IsProcessOpen("Skype"))
         {
             _skype = new Skype();
             // Use skype protocol version 7
             _skype.Attach(7, false);
             // Listen
             _skype.MessageStatus += skype_MessageStatus;
             ((_ISkypeEvents_Event)_skype).AttachmentStatus += new _ISkypeEvents_AttachmentStatusEventHandler(SkypePopDialog_AttachmentStatus);
             _chats = _skype.ActiveChats;
             RefreshActiveChats();
             if (_chats.Count > 0)
             {
                 cmbActiveChats.SelectedIndex = 0;
             }
             return true;
         }
         else
         {
             CueProvider.SetCue(txtSend, "Waiting untill Skype starts... ");
             _skypeReconnectTime.Enabled = true;
             return false;
         }
     }
     catch(Exception ex)
     {
         CueProvider.SetCue(txtSend, "Waiting untill Skype starts... ");
         _skypeReconnectTime.Enabled = true;
         return false;
     }
 }
Example #5
0
        static void Main(string[] args)
        {
            Skype _skype = new Skype();

            try
            {
                _skype.Attach(5, false);
                Console.Write("Connectie succesvol");
                if (!_skype.Client.IsRunning)
                {
                    _skype.Client.Start(false, true);
                }

                System.Threading.Thread.Sleep(5000);

                if (_skype.Client.IsRunning == true)
                {
                    string line;

                    string path = string.Join(Directory.GetCurrentDirectory(), "./config.txt");

                    StreamReader file =
                        new StreamReader(path);

                    line = file.ReadLine();

                    Call call = _skype.PlaceCall(line);
                }
            }
            catch
            {
                Console.Write("Connectie onsuccesvol");
            }
        }
        private static bool Connect()
        {
            const int maxAttempts = 30;
            bool      br          = IsSkypeRunning;

            if (!br)
            {
                // Start with no splash screen
                SkypeObj.Client.Start(false, true);
                Thread.Sleep(7000);
            }

            Exception ex = null;

            for (int i = 0; i < 3; i++)
            {
                // Mechanism to allow access
                Thread thread = thread = new Thread(new ThreadStart(() =>
                {
                    int downCount = 30 * maxAttempts;
                    SetToCompactView();
                    while (!ev.WaitOne(2000) && downCount-- > 0)
                    {
                        SetToCompactView();
                        AllowAccess();
                    }
                }));
                thread.Start();

                SetToCompactView();

                try
                {
                    SkypeObj.Attach(6, true);
                    br = true;
                }
                catch (Exception e)
                {
                    ex = e;
                }
                finally
                {
                    ev.Set();
                    thread.Join();
                }

                if (br)
                {
                    break;
                }
            }

            if (!br)
            {
                MessageBox.Show("Skype start / connection problem!\n" + ex.ToString(),
                                WF.Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(br);
        }
        public SkypeInterface()
        {
            Skype = new Skype();
            Skype.Attach();

            Chat = Skype.Chat[ConfigurationManager.AppSettings["chatname"]];
        }
Example #8
0
        public SysTrayApp()
        {
            trayMenu = new ContextMenu();
            trayMenu.MenuItems.Add("Exit", OnExit);
            var statusMenuItem = new MenuItem("Set status to");
            var dndMenuItem    = new MenuItem("Do not disturb", OnDnd)
            {
                Checked = true
            };

            statusMenuItem.MenuItems.Add(dndMenuItem);
            statusMenuItem.MenuItems.Add("Away", OnAway);
            statusMenuItem.MenuItems.Add("Invisible", OnInvisible);
            statusMenuItem.MenuItems.Add("Online", OnOnline);
            trayMenu.MenuItems.Add(statusMenuItem);


            trayIcon                 = new NotifyIcon();
            trayIcon.Text            = "SkypeAutoDND";
            trayIcon.Icon            = new Icon("skypednd.ico", 40, 40);
            trayIcon.BalloonTipTitle =
                "SkypeAutoDND is running minimized!";
            trayIcon.BalloonTipText = "Remember to accept the app in skype! :)";
            trayIcon.BalloonTipIcon = ToolTipIcon.Info;

            trayIcon.ContextMenu = trayMenu;
            trayIcon.Visible     = true;
            trayIcon.ShowBalloonTip(3000);
            skype = new Skype();
            skype.Attach();

            timer          = new Timer(2000);
            timer.Elapsed += (sender, eventArgs) => ForceStatus();
            timer.Enabled  = true;
        }
    static void Main(string[] args)
    {
        Skype skype = new Skype();

        if (!skype.Client.IsRunning)
        {
            // start minimized with no splash screen
            skype.Client.Start(true, true);
        }

        // wait for the client to be connected and ready
        skype.Attach(6, true);

        // access skype objects
        Console.WriteLine("Missed message count: {0}", skype.MissedMessages.Count);

        // do stuff
        string          username = "******";
        IUserCollection users    = skype.SearchForUsers(username);

        if (users.Count > 0)
        {
            User user = users[1];
            Console.WriteLine(user.FullName);
        }

        skype.SendMessage(username, "Hello World");
    }
Example #10
0
 private void Form1_Load(object sender, EventArgs e)
 {
     this.Visible         = false;
     notificationManager  = new NotificationManager(this);
     skype.MessageStatus += skype_MessageStatus;
     skype.Attach(8, false);
 }
Example #11
0
 private void Form1_Load(object sender, EventArgs e)
 {
     skype = new Skype();
     skype.Attach(8, false);
     // Listen
     skype.MessageStatus += new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);
 }
Example #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            SKYPE4COMLib.Skype skype = new Skype();

            try
            {
                skype.Attach();
                var usr = skype.CurrentUser;
                skype.CallStatus += Skype_CallStatus;

                var currentCall = skype.PlaceCall("echo123");//Indtast caller id her (har indtastet skypes ekko service for test)
                label1.Text = "Started: " + currentCall.Timestamp.ToString() + "";
                label2.Text = "Ended: " + currentCall.Timestamp.ToString() + "";
                Thread.Sleep(4000);

                currentCall.Finish();
                label2.Text = "Ended: " + DateTime.Now.ToString() + "";

                label3.Text = "Duration: " + (DateTime.Now - currentCall.Timestamp).TotalSeconds;
            }
            catch (COMException come)
            {
                throw;
            }
        }
    static void Main(string[] args)
    {
        Skype skype = new Skype();

        if (!skype.Client.IsRunning)
        {
            // start minimized with no splash screen
            skype.Client.Start(true, true);
        }

        // wait for the client to be connected and ready
        skype.Attach(6, true);

        // access skype objects
        Console.WriteLine("Missed message count: {0}", skype.MissedMessages.Count);

        // do some stuff
        Console.WriteLine("Enter a skype name to search for: ");
        string username = Console.ReadLine();

        foreach (User user in skype.SearchForUsers(username))
        {
            Console.WriteLine(user.FullName);
        }

        Console.WriteLine("Say hello to: ");
        username = Console.ReadLine();
        skype.SendMessage(username, "Hello World");
    }
Example #14
0
        //This method runs when the program starts up
        private void Form1_Load(object sender, EventArgs e)
        {
            //Initial Skype Desktop API
            skype = new Skype();
            skype.Attach(7, true);
            //Hookup local event method to run when Skype status changes
            skype.OnlineStatus += Skype_OnlineStatus;
            //Retrieve the current status of the skype client
            TOnlineStatus myStatus = skype.CurrentUser.OnlineStatus;

            //Turn Skype status into a String
            label1.Text = getStatusString(myStatus);

            //Setup system tray icon (making the app able to run in the background) and not on the task bar
            notifyIcon = new System.Windows.Forms.NotifyIcon();
            notifyIcon.BalloonTipText  = "located in system tray";
            notifyIcon.BalloonTipTitle = "Skype Status Monitor for Raspberry Pi";
            notifyIcon.Text            = "Skype Status Monitor for Raspberry Pi";
            notifyIcon.Icon            = SkypeMonitor.Properties.Resources.MyIcon;
            notifyIcon.Click          += new EventHandler(HandlerToMaximiseOnClick);
            if (notifyIcon != null)
            {
                notifyIcon.Visible = true;
                notifyIcon.ShowBalloonTip(2000);
            }
            //Minimize the app to the system tray (running in the background to be less obtrusive to user)
            this.WindowState = FormWindowState.Minimized;

            //setup local area network Rest Service
            //retrieve the local IP addresses to bind the HttpService to
            ArrayList   myIps = new ArrayList();
            IPHostEntry host;

            host = Dns.GetHostEntry(Dns.GetHostName());
            foreach (IPAddress ip in host.AddressList)
            {
                if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    myIps.Add(ip.ToString());
                }
            }
            //Setup Http Server
            listener = new HttpListener();
            listener.Prefixes.Add("http://localhost:" + localServerPort + "/");
            listener.Prefixes.Add("http://127.0.0.1:" + localServerPort + "/");
            foreach (String IP in myIps)
            {
                listener.Prefixes.Add("http://" + IP + ":" + localServerPort + "/");
            }
            //No Authentication needed
            listener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
            //Spawn additional thread and run HttpService in that background thread
            continueThread = true;
            listener.Start();
            this.listenThread1 = new Thread(new ParameterizedThreadStart(startlistener));
            listenThread1.Start();
            //setup closing method to dispose of thread properly
            this.Disposed += Form1_Disposed;
        }
Example #15
0
 private void Form1_Load(object sender, EventArgs e)
 {
     skype = new Skype();
     // Use skype protocol version 7
     skype.Attach(7, false);
     // Listen
     skype.MessageStatus += new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);
 }
Example #16
0
 public Form1()
 {
     InitializeComponent();
     skype = new Skype();
     skype.Attach(7, false);
     numericUpDown1.Maximum = skype.Chats.Count;
     //skype.MessageStatus+=new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);
 }
Example #17
0
 private void attachmentWaitingThreadProc(object attachmentSemaphore)
 {
     try {
         skype.Attach();
         ((Semaphore)attachmentSemaphore).Release();
     }
     catch (Exception) {}
 }
Example #18
0
        public bool Start()
        {
            if (skype == null)
            {
                return(false);
            }

            skypeWait = new Timer(arg => WaitSkypeProcess(), null, 0, 1000);

            // Start Skype if not running already and attach API
            bool skypeStarted = false;
            int  triesCount   = 0;

            while (!skypeStarted)
            {
                try
                {
                    Debug.Print("Waiting for Skype permission...");
                    while (!skypeRunning)
                    {
                        Thread.Sleep(1000);
                    }

                    skype.Timeout = 1000;
                    skype.Attach(8, true);
                    skypeStarted = true;
                    triesCount++;
                    if (triesCount > 2)
                    {
                        _lastError = "Attaching to Skype failed because of timeout. Try to restart Skype.";
                        return(false);
                    }
                }

                catch
                {
                    skype.Timeout = 60000;
                }
            }

            // Wait while user will grant access
            bool AccessForAppGranted = false;

            while (!AccessForAppGranted)
            {
                try
                {
                    var currentStatus = skype.CurrentUserStatus;
                    AccessForAppGranted = true;
                }
                catch { }
                Thread.Sleep(10);
            }
            skype.CallStatus    += OnCallStatus;
            skype.MessageStatus += OnMessageStatus;
            OnConnect(new EventArgs());
            return(true);
        }
        public SkypeHelper()
        {
            // System.Runtime.InteropServices.COMException
            _skype = new Skype();
            ((_ISkypeEvents_Event)_skype).AttachmentStatus += SkypeAttachmentStatus;
            _skype.UserStatus += SkypeUserStatus;

            _skype.Attach(SKYPE_PROTOCOL, WAIT_FOR_ATTACH);
        }
Example #20
0
        const string ytAPIKey = //removed for security reasons

        static void Main(string[] args)
        {
            //skype initialization
            sky = new SKYPE4COMLib.Skype();
            sky.Attach();

            while (true)
            {

                //autoresponse messages
                foreach (IChatMessage msg in sky.MissedMessages)
                {

                    string user = msg.Sender.Handle;
                    string[] cmds = { "!help", "!ping", "!yt [search query]" };

                    //help cmd
                    if (msg.Body.ToLower().Contains(prefix + "help") && msg.Body.IndexOf(prefix) == 0)
                    {
                        string cmdFormat = "Commands:";
                        foreach (string cmd in cmds)
                        {
                            cmdFormat += "\n\t\t" + cmd;
                        }
                        sky.SendMessage(user, "kek");
                        break;
                    }
                    //ping cmd
                    else if (msg.Body.ToLower().Contains(prefix + "ping") && msg.Body.IndexOf(prefix) == 0)
                    {
                        SendSMS(user, "pong");
                        break;
                    }
                    //youtube cmd
                    else if (msg.Body.ToLower().Contains(prefix + "yt") && msg.Body.IndexOf(prefix) == 0)
                    {
                        ytSearch = msg.Body.Remove(0, 3);
                        if (string.IsNullOrWhiteSpace(ytSearch))
                        {
                            SendSMS(user, "Incorrect syntax. Please do \"!yt <what you want to search>\" instead.");
                        }
                        else
                        {
                            new Program().YoutubeMethod().Wait();
                            SendSMS(user, ytResult);
                        }
                        break;
                        //invalid command
                    }
                    else if (msg.Body.ToLower().Contains(prefix.ToString()) && msg.Body.IndexOf(prefix) == 0)
                    {
                        SendSMS(user, "\"" + msg.Body + "\"" + " is not a valid command. Please type " + "\"!help\" for more info.");
                        break;
                    }
                }
            }
        }
Example #21
0
        public SkypeHelper()
        {
            // System.Runtime.InteropServices.COMException
            _skype = new Skype();
            ((_ISkypeEvents_Event)_skype).AttachmentStatus += SkypeAttachmentStatus;
            _skype.UserStatus += SkypeUserStatus;

            _skype.Attach(SKYPE_PROTOCOL, WAIT_FOR_ATTACH);
        }
Example #22
0
 public SkypeApi()
 {
     _skype             = new Skype();
     _vk                = new VKAPI();
     _vk.CaptchaNeeded += (sender, args) => chat.SendMessage(args.Text);
     _skype.Attach(SkypeVersion, false);
     _skype.MessageStatus += SkypeMessageEvent;
     chat = _skype.Chat["#skype2vkgate/$frodosa05;98f14bcb7d42e4c2"];
 }
        private void InitializeSkype()
        {
            s = new Skype();
            _ISkypeEvents_Event events = s;

            events.AttachmentStatus += OnAttachementStatusChanged;
            events.CallStatus       += OnCallStatusChanged;

            s.Attach();
        }
Example #24
0
        private void Form2_Load(object sender, EventArgs e)
        {
            botfactory = new ChatterBotFactory();

            bot = botfactory.Create(ChatterBotType.PANDORABOTS, PandoraBotID);

            skype = new Skype();
            skype.Attach(8, true);
            skype.MessageStatus += skype_MessageStatus;
        }
Example #25
0
 private void btnKetNoiSkype_Click(object sender, EventArgs e)
 {
     skypeInstant = new Skype();
     if (!skypeInstant.Client.IsRunning)
     {
         // start minimized with no splash screen
         skypeInstant.Client.Start(true, true);
     }
     skypeInstant.Attach(6, true);
 }
Example #26
0
 private void btnKetNoiSkype_Click(object sender, EventArgs e)
 {
     skypeInstant = new Skype();
     if (!skypeInstant.Client.IsRunning)
     {
         // start minimized with no splash screen
         skypeInstant.Client.Start(true, true);
     }
     skypeInstant.Attach(6, true);
 }
Example #27
0
        public static void Init()
        {
            if (Skype == null)
            {
                Skype = new SkypeClass();
                Skype._ISkypeEvents_Event_AttachmentStatus += Skype_AttachmentStatus;
            }

            Skype.Attach(Skype.Protocol, false);
        }
Example #28
0
 static void Main(string[] args)
 {
     skype = new Skype();
     skype.Attach(7, false);
     skype.MessageStatus += new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);
     while (Console.ReadKey(true).KeyChar != 's')
     {
         ;
     }
 }
Example #29
0
 private void Form1_Load(object sender, EventArgs e)
 {
     service = new Skype();
     if (!service.Client.IsRunning)
     {
         service.Client.Start(true, true);
     }
     service.Attach(7, true);
     service.MessageStatus += service_MessageStatus;
     listBox1.Items.Add("Skype connected...");
 }
Example #30
0
 private static void Main(string[] args)
 {
     Console.WriteLine("Loading Skype#...");
     k = new Skype();
     k.Attach(7, false);
     k.MessageStatus +=
         new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);
     Game.OnInput += Game_OnInput;
     CustomEvents.Game.OnGameLoad += Game_OnGameLoad;
     //k.SendMessage("shiver.x", "test");
 }
Example #31
0
        public void Skype_AttachmentStatus(TAttachmentStatus status)
        {
            _blnAttached = false;

            // DEBUG: Write Attachment Status to Window
            //WriteToLog("Attachment Status: " + cSkype.Convert.AttachmentStatusToText(status));
            //WriteToLog(" - " + status.ToString() + Environment.NewLine);

            if (status == TAttachmentStatus.apiAttachAvailable)
            {
                try
                {
                    // This attaches to the Skype4COM class statement
                    _clsSkype.Attach(7, true);
                }
                catch (Exception)
                {
                    // All Skype Logic uses TRY for safety
                }
            }
            else
            if (status == TAttachmentStatus.apiAttachSuccess)
            {
                try
                {
                    System.Windows.Forms.Application.DoEvents();
                    _objSkype.Attach(7, false);
                }
                catch (Exception)
                {
                    // All Skype Logic uses TRY for safety
                }

                _blnAttached    = true;
                _blnWasAttached = true;

                // If we have a queued Silent Mode request, We are attached, process it now
                if (_blnPendingSilentModeStartup)
                {
                    _blnPendingSilentModeStartup = false;
                    try
                    {
                        if (!_objSkype.SilentMode)
                        {
                            _objSkype.SilentMode = true;
                        }
                    }
                    catch (Exception)
                    {
                        // All Skype Logic uses TRY for safety
                    }
                }
            }
        }
Example #32
0
        public void BeginMonitoring()
        {
            if (!skype.Client.IsRunning)
            {
                skype.Client.Start(false, true);
            }
            skype.Attach(6);

            SetCallStatus();
            skype.CallStatus += (call, status) => SetCallStatus();
        }
Example #33
0
 public SkypeHelper()
 {
     try
     {
         _skype = new Skype();
         _skype.Attach(SkypeProtocol, true);
     }
     catch (Exception ex)
     {
         Console.WriteLine("top lvl exception : " + ex.ToString());
     }
 }
Example #34
0
        public void SetUp()
        {
            _skype = new Skype();
            if (!_skype.Client.IsRunning)
            {
                // start minimized with no splash screen
                _skype.Client.Start(true, true);
            }

            // wait for the client to be connected and ready
            _skype.Attach(7, true);
        }
Example #35
0
        public void SetUp()
        {
            _skype = new Skype();
            if (!_skype.Client.IsRunning)
            {
                // start minimized with no splash screen
                _skype.Client.Start(true, true);
            }

            // wait for the client to be connected and ready
            _skype.Attach(7, true);
        }
Example #36
0
 void OnSkypeAttachmentStatus(TAttachmentStatus status)
 {
     log.Info("Attachment Status {0}", status);
     if (status == TAttachmentStatus.apiAttachAvailable)
     {
         skype.Attach(Protocol, false);
     }
     if (status == TAttachmentStatus.apiAttachSuccess)
     {
         log.Info("AudioIn: {0}", skype.Settings.AudioIn);
         log.Info("You can now place a call");
     }
 }
Example #37
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         skype.Attach(7, false);
         loadContacts();
         indexContacts();
     }
     catch (COMException)
     {
         MessageBox.Show("Attach Request could not be sent. Try to restart Skype and the Application!");
     }
 }
        public Form1()
        {
            InitializeComponent();

            _skype = new Skype();

            _skype.Attach(Protocol: 7, Wait: true);

            _skype.OnlineStatus += OnlineStatusChanged;

            _currentStatus = this.ConvertStatusToString(_skype.CurrentUser.OnlineStatus);

            PostToService(_currentStatus);
        }
Example #39
0
        public SkypeBot(Main mainWindow, SBProperties sbproperties)
        {
            main = mainWindow;  //will this work backwords. If I change an aspect of main, will mainwindow be changed? I don't see why it would...
                                //but it does, so yay I guess.
                                //TODO: Ask Andre why.

            skype = new Skype();
            bool isrunning = false;
            do
            {
                if (skype.Client.IsRunning)
                {
                    skype.Attach(8, false);//TODO: skype attach causes hanging on consecutive runs, no idea why
                    isrunning = true;
                }
            } while (isrunning == false);

            skype.MessageStatus +=
              new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);
            sbprop = sbproperties;
            nick = sbprop._Account; //loads default value.

            #region commands
            List<string> com = new List<string>();
            com.Add("help");	//0
            com.Add("google");	//1
            com.Add("lmgtfy");	//2
            com.Add("date");	//3
            com.Add("time");	//4
            com.Add("coin");	//5
            com.Add("8ball");	//6
            com.Add("prgm");	//7
            com.Add("del");		//8
            com.Add("src");		//9
            com.Add("say");		//10
            com.Add("quote");	//11
            com.Add("wolfram");	//12
            com.Add("alpha");	//13
            com.Add("block");	//14
            com.Add("unblock");	//15
            com.Add("steam");	//16
            com.Add("bot");		//17
            com.Add("call");	//18
            commands = com.ToArray();
            #endregion

            instantiatePersonality("bot");
            refreshBlacklist();
        }
Example #40
0
        public Form1()
        {
            InitializeComponent();

            _random = new LunaRandom();

            skype = new Skype();
            if (!skype.Client.IsRunning)
            {
                // start minimized with no splash screen
                skype.Client.Start(true, true);
            }

            // wait for the client to be connected and ready
            skype.Attach(8, true);

            skype.MessageStatus += new _ISkypeEvents_MessageStatusEventHandler(skype_MessageStatus);


            var files = Directory.GetFiles("Quotes", "*", SearchOption.AllDirectories).ToList();
            if (files.Count != 0)
            {
                foreach (var file in files)
                {
                    var strings = File.ReadAllLines(file);

                    var convertedStrings = new List<string>();
                    foreach (var s in strings)
                    {
                        convertedStrings.Add(s + " - " + Path.GetFileNameWithoutExtension(file));
                    }
                    ListOfAllQuotes.AddRange(convertedStrings);
                }
                
            }

            SetupCommandProcessors();

            _pulse = new System.Timers.Timer();
            _pulse.Elapsed += Pulse;
            _pulse.Interval = 1000; // in miliseconds
            _pulse.Start();

        }
Example #41
0
        public MainWindow()
        {
            InitializeComponent();

            ActiveConferences = new ObservableCollection<Conference>();
            ActiveCalls = new ObservableCollection<Call>();
            KeyPresses = new ObservableCollection<string>();

            DataContext = this;
            HideOnMinimize.Enable(this);            

            _skype = new Skype();
            _skype.CallStatus += SkypeOnCallStatus;
            ((_ISkypeEvents_Event)_skype).AttachmentStatus += SkypeAttachmentStatus;
            _skype.Attach(SkypeProtocol, false);
            
            KeyboardHook.KeyPressed += OnKeyUp;
            KeyboardHook.SetHooks();
        }
Example #42
0
        public bool AttachToSkype()
        {
            _skypeHandler = new Skype();
            _skypeHandler.Attach(7, false);

            if (!_skypeHandler.Client.IsRunning && ((ISkype) _skypeHandler).AttachmentStatus == TAttachmentStatus.apiAttachSuccess)
                return false;

            _friends = new List<SkypeUser>();

            foreach (var usr in _skypeHandler.Friends.OfType<User>())
            {
                _friends.Add(new SkypeUser() {
                    Handle = usr.Handle,
                    Aliases = usr.Aliases,
                    DisplayName = usr.DisplayName
                });
            }

            return true;
        }
Example #43
0
        public SkypeConnector(ILog log, EffectChain effects)
        {
            this.log = log;
            InitSockets();

            skype = new Skype();
            ISkype iSkype = (ISkype)skype;

            if (!iSkype.Client.IsRunning)
            {
                log.Error("Skype is not running");
            }

            _ISkypeEvents_Event events = (_ISkypeEvents_Event)skype;

            events.AttachmentStatus += OnSkypeAttachmentStatus;
            skype.CallStatus += OnSkypeCallStatus;
            skype.Error += OnSkypeError;
            skype.Attach(Protocol, false);

            bufferStream = new SkypeBufferStream(44100);
            OutputStream = new EffectStream(effects, bufferStream);
        }
Example #44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SkypeContainer"/> class.
 /// </summary>
 public SkypeContainer()
 {
     Skype = new Skype();
     Skype.Attach(Protocol: 8, Wait: false);
 }
Example #45
0
 private void InitializeSkypeHook()
 {
     skype = new Skype();
     skype.Attach();
     skype.MessageStatus += _chatBot.ProcessCommand;
 }
Example #46
0
 private void SACForm_Load(object sender, EventArgs e)
 {
     _skype = new Skype();
     _skype.Attach();
     _skype.CallStatus += skype_CallStatus;
 }
Example #47
0
        public ConfigForm() {
            InitializeComponent();
            FormConsoleAppender.appendMethod += addLogLine;

            if (Properties.Settings.Default.Crashed) {
                DialogResult res = MessageBox.Show("SkypeBot appears to have crashed last time it was run.\nDo you wish to send a log to the developers for debugging purposes?", "SkypeBot appears to have crashed", MessageBoxButtons.YesNo);

                if (res == DialogResult.Yes) {
                    ReportForm rf = new ReportForm(from p in plugins select p.name());
                    rf.Show();
                }

                Properties.Settings.Default.Crashed = false;
                Properties.Settings.Default.Save();
            }

            plugins.Sort(
                delegate(Plugin p1, Plugin p2) {
                    return Comparer<String>.Default.Compare(p1.name(), p2.name());
                }
            );

            PluginListBox.ItemCheck += (obj, e) =>
            {
                if (e.NewValue == CheckState.Checked) {
                    log.Debug("Loading " + plugins[e.Index].name());
                    loadPlugin(plugins[e.Index]);
                } else {
                    log.Debug("Unloading " + plugins[e.Index].name());
                    unloadPlugin(plugins[e.Index]);
                }
            };

            PluginListBox.SelectedIndexChanged += (obj, e) =>
            {
                int selected = PluginListBox.SelectedIndex;
                if (selected == -1) {
                    DescriptionBox.Text = "";
                    ConfigButton.Visible = false;
                }
                else {
                    Plugin plugin = plugins[selected];
                    DescriptionBox.Text = plugin.description();
                    ConfigButton.Visible = plugin.canConfig();
                }
                
            };

            if (Properties.Settings.Default.LoadedPlugins == null) {
                log.Debug("Creating LoadedPlugins property.");
                Properties.Settings.Default.LoadedPlugins = new System.Collections.Specialized.StringCollection();
            }
            if (Properties.Settings.Default.Whitelist == null) {
                log.Debug("Creating LoadedPlugins property.");
                Properties.Settings.Default.Whitelist = new System.Collections.Specialized.StringCollection();
            }

            log.Debug("Initiating connection to Skype...");
            skype = new Skype();
            if (!skype.Client.IsRunning) {
                log.Debug("Skype is not running; starting...");
                skype.Client.Start(false, false);
            }

            bool attached = false;
            do {
                try {
                    log.Debug("Attaching to Skype...");
                    skype.Attach(9, true);
                    attached = true;
                } catch (COMException) {
                    DialogResult res = MessageBox.Show("Please remember to click \"Allow Access\" in the popup you get in Skype.", "Failed to attach to Skype", MessageBoxButtons.RetryCancel);
                    if (res == DialogResult.Cancel) {
                        System.Windows.Forms.Application.Exit();
                    }
                }
            } while (!attached);

            log.Debug("Attached to Skype.");

            skype.MessageStatus += (ChatMessage message, TChatMessageStatus status) =>
            {
                if (Properties.Settings.Default.UseWhitelist ^
                    Properties.Settings.Default.Whitelist.Contains(message.Chat.Name)) {
                    return;
                }

                Boolean isBlocked = blocked.Contains(
                        skype.CurrentUser.Handle + " :: " + message.ChatName
                    );

                if ((status.Equals(TChatMessageStatus.cmsReceived) || status.Equals(TChatMessageStatus.cmsSent) ||
                    (status.Equals(TChatMessageStatus.cmsRead) && message.Id > lastId) ) && !isBlocked) {
                    
                    log.Info(String.Format("{0}MSG: {1}", status.Equals(TChatMessageStatus.cmsRead) ? "r" :
                                                          status.Equals(TChatMessageStatus.cmsSent) ? "s" : "", message.Body));

                    lastId = message.Id;

                    // Ignore messages older than 1 hour.
                    if (message.Timestamp.CompareTo(DateTime.Now.AddHours(-1.0)) < 0) {
                        log.Debug("Message too old; not going to react.");
                    }

                    Match output = Regex.Match(message.Body, @"^!help", RegexOptions.IgnoreCase);
                    if (output.Success) {
                        String outputMsg = "Help for the bot can be found at http://mathemaniac.org/apps/skypebot/help/.";
                        message.Chat.SendMessage(outputMsg);
                        
                        return;
                    }

                    output = Regex.Match(message.Body, @"^!loaded", RegexOptions.IgnoreCase);
                    if (output.Success) {
                        String outputMsg = "";
                        foreach (Plugin p in plugins) {
                            if (isLoaded(p)) {
                                outputMsg += (outputMsg == "" ? "" : ", ");
                                outputMsg += Regex.Replace(p.name(), @"\sPlugin$", "", RegexOptions.IgnoreCase);
                            }
                        }
                        outputMsg = "The following plugins are loaded:\n" + outputMsg;

                        message.Chat.SendMessage(outputMsg);

                        return;
                    }

                    output = Regex.Match(message.Body, @"^!version", RegexOptions.IgnoreCase);
                    if (output.Success && System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) {
                        message.Chat.SendMessage(
                            "Running Dynamic Skype Bot v" + System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion
                            + " (http://mathemaniac.org/wp/dynamic-skype-bot/)"
                        );
                        return;
                    }

                    if (onSkypeMessage.GetInvocationList().Length != Properties.Settings.Default.LoadedPlugins.Count) {
                        // Let's fix up the loaded plugins list.
                        log.Info("Loaded plugin list seems to be off. Correcting...");
                        PluginListBox.Enabled = false;
                        onSkypeMessage = null;
                        Properties.Settings.Default.LoadedPlugins.Clear();
                        Properties.Settings.Default.LoadedPlugins.AddRange(
                            this.plugins.Where((p, i) => PluginListBox.CheckedIndices.Contains(i))
                                        .Select((p) => {
                                            onSkypeMessage += new _ISkypeEvents_MessageStatusEventHandler(p.Skype_MessageStatus);
                                            return p.name();
                                        })
                                        .ToArray()
                        );
                        Properties.Settings.Default.Save();
                        PluginListBox.Enabled = true;
                        log.Info("Loaded plugin list corrected.");
                    }

                    if (onSkypeMessage != null) {
                        BackgroundWorker bw = new BackgroundWorker();
                        bw.DoWork += (obj, e) => onSkypeMessage(message, status);
                        bw.RunWorkerAsync();
                    }
                }
            };

            populatePluginList();

            blocked = "";
            BackgroundWorker baw = new BackgroundWorker();
            baw.DoWork += (obj, e) => {
                log.Debug("Fetching list of blocked people/chat combinations...");
                WebRequest webReq = WebRequest.Create("http://mathemaniac.org/apps/skypebot/blocked.txt");
                try {
                    webReq.Timeout = 10000;
                    WebResponse response = webReq.GetResponse();
                    blocked = new StreamReader(response.GetResponseStream()).ReadToEnd();
                } catch (Exception ex) {
                    log.Warn("Failed to fetch list of blocked people/chat combinations.", ex);
                }
            };
            baw.RunWorkerAsync();

            // Update check
            if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed &&
                Properties.Settings.Default.UpdateCheck) {
                updateTimer = new Timer();
                updateTimer.Interval = Properties.Settings.Default.UpdateCheckInterval * 60 * 1000;
                updateTimer.Tick += (obj, e) => {
                    log.Info("Checking for updates...");
                    try {
                        if (System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CheckForUpdate()) {
                            log.Info("Update available for download!");
                            if (taskIcon.Visible) {
                                taskIcon.BalloonTipTitle = "Skype Bot";
                                taskIcon.BalloonTipText = "A new version of the Skype Bot is ready for download.";
                                taskIcon.BalloonTipIcon = ToolTipIcon.Info;
                                taskIcon.ShowBalloonTip(Properties.Settings.Default.UpdateCheckInterval * 60 * 1000);
                            } else {
                                updateTimer.Stop();
                                MessageBox.Show("A new version is ready for download!");
                            }
                        } else {
                            log.Info("No updates found.");
                        }
                    } catch(Exception ex) {
                        log.Warn("Exception arose while checking for update.", ex);
                    }
                };
                updateTimer.Start();
            }
        }
Example #48
0
        static void Main()
        {
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            coreInitialized = false;

            //create gui
            form = new FormMain();
            Thread guiThread = new Thread(GuiThread);
            guiThread.Start();
            Thread.Sleep(25);

            //init logger
            Logger.logWriter.Add(form.log);
            Logger.log(TLogLevel.logUser, "Welcome to watchasayin!");

            //create working directories
            String pathKryptonite = Environment.ExpandEnvironmentVariables(PATH_KRYPTONITE);
            String pathBottom = Environment.ExpandEnvironmentVariables(PATH_BOTTOM);
            try
            {
                System.IO.Directory.CreateDirectory(pathKryptonite);
                System.IO.Directory.CreateDirectory(pathBottom);
            }
            catch
            {
                Logger.log(TLogLevel.logUser, "Fatal Error: Failed to access working directories.");
                return;
            }

            //init bottom module
            String pathSkype = "";
            try
            {
                RegistryKey keyPathSkype = Registry.CurrentUser.OpenSubKey(SUBKEY_REGISTRY_SKYPE);
                pathSkype = (String)keyPathSkype.GetValue(VALUE_REGISTRY_SKYPE);
                keyPathSkype.Close();
            }
            catch
            {
                Logger.log(TLogLevel.logUser, "Fatal Error: Skype does not seem to be installed on the system.");
            }
            Bottom.InProcess bottomInProcess = new Bottom.InProcess(form, pathBottom, NAME_SKYPE, CLASSNAME_SKYPE, pathSkype, true);

            //connect to skype-api
            Logger.log(TLogLevel.logUser, "Connecting to Skype...");

            Skype skype;
            skype = new Skype();

            int tries = 0;
            while (tries < CONNECTION_ATTEMPTS_BEFORE_ERROR)
            {
                try
                {
                    skype.Attach(SKYPE_PROTOCOL_VERSION);
                   break;
                }

                catch
                {
                    Logger.log(TLogLevel.logUser, "Could not connect - retrying.");
                    tries++;
                }
            }

            if (tries == CONNECTION_ATTEMPTS_BEFORE_ERROR)
            {
                Logger.log(TLogLevel.logUser, "Fatal Error: Could not connect to Skype.");
                return;
            }

            //init other modules
            Logger.log(TLogLevel.logUser, "Connected.");

            APIEventHandler skypeApiEH = new APIEventHandler(skype);
            CommOverSkype surfaceCommSkype = new CommOverSkype(skype, NUMBER_OF_MESSAGES_TO_CACHE);

            Kryptonite.SharedLibrary kryptoniteShared = new Kryptonite.SharedLibrary(skype.CurrentUser.Handle, form, pathKryptonite);

            core = new Core(form, skypeApiEH, surfaceCommSkype, kryptoniteShared, bottomInProcess);
            coreInitialized = true;
        }
Example #49
0
        static void Main(string[] args)
        {
            Boolean confirm = true;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Title = "SkypeChat";
            Skype skype = new Skype();
            if (!skype.Client.IsRunning)
            {
                skype.Client.Start(true, true);
            }
            // Utilisation de la version 7 de Skype
            skype.Attach(7, false);
            write("Conversation ou discussion privée? [C/D]");
            string choix = Console.ReadLine();
            choix = choix.ToUpper();
            switch (choix)
            {
                case "D":
                    DiscuPrivée:
                    Console.Clear();
                    write("Veuillez entrer un pseudonyme: ");
            string username = Console.ReadLine();
            foreach (User user in skype.SearchForUsers(username))
            {
                write(user.FullName);
            }
            Console.Clear();
            write("La conversation avec votre contact a été lancé \n chaque message sera suivi sur Skype d'un \" - Envoyé avec SkypeChat \". \n Pour voir les commandes disponibles, tapez juste \"#menu\".");
            Chat:
            string message = Console.ReadLine();

            if (confirm == true)
            {
                write("Veuillez appuyer sur Entrée pour confirmer l'envoi de la commande ou du message.");
                Console.ReadKey();
            }
            write("[POUR] " + username + " : " + message);
                    switch (message)
                    {
                        default:
                            // MESSAGE
                            if (message.Contains("#"))
                            {

                            }
                            else
                            {
                                write("[ENVOYÉ] " + username + " : " + message);
                            }

                        case "#menu":
                            // COMMANDES
                            write("#clear        : Nettoyer le CMD.");
                            write("#menu         : Affiche ce menu.");
                            write("#leave        : Fermer la conversation.");
                            write("#exit         : Fermer le logiciel.");
                            write("#call         : Appeler l'utilisateur cible.");
                            write("#confirm      : Désactive/Active la vérification d'envoi de message. (Actuel : " + confirm + ")");
                            write("#conversation : Créer une conversation via SkypeChat avec l'utilisateur cible.");
                            write("#sendfile     : Envoyer un fichier dans la discussion");
                            MessageBox.Show("La commande #confirm ne fonctionne pas pour le moment, mais elle devrait être mis à jour pour la 2.03", "Error");

                            goto Chat;
                        case "#clear":

                            Console.Clear();
                            goto Chat;

                        case "#leave":
                            Console.Clear();
                            goto DiscuPrivée;

                        case "":
                            write("Vous ne pouvez pas envoyer un message vide.");
                            goto Chat;

                        case "#exit":
                            Environment.Exit(1);
                            break;

                        case "#call":
                            skype.PlaceCall(username);
                            write("Veuillez appuyer sur Entrée à la fin de votre appel.");
                            Console.ReadKey();
                            write("Retour au mode texte en cours..");
                            goto Chat;

                        case "#conversation":
                            skype.CreateGroup("Conversation créer par SkypeChat");
                            goto Chat;

                        case "#sendfile":
                            skype.Client.OpenFileTransferDialog(username, "C:\\");
                            goto Chat;

                        case "#confirm":
                            if (confirm == true)
                            {
                                confirm = false;
                                write("Demande de confirmation: Désactivée !");
                            }
                            goto Chat;
                            if (confirm == false)
                            {
                                confirm = true;
                                write("Demande de confirmation: Activée !");

                            }
                            goto Chat;
                    }
                    break;

                case "C":
                    MessageBox.Show("Le mode conversation n'est pas encore prêt, passage automatique en mode discussion privée","Erreur");
                    goto DiscuPrivée;
            }
        }
Example #50
0
 private void AttachToSkype(Skype skype)
 {
     skype.Attach(6, true);
 }
Example #51
0
        private void EnableThread(object sender, EventArgs e)
        {
            var skype = new Skype();

            if (metroTile1WasClicked == true)
            {
                if (skypeAttached == false)
                {
                    metroTile4.Visible = false;
                    skype.Attach(5, true);
                    skypeAttached = true;
                    Console.WriteLine(skypeAttached);
                }
                Console.WriteLine(gameRunning());
                if (gameRunning()) {
                    if (metroComboBox1.Text == "Away") {
                        skype.ChangeUserStatus(TUserStatus.cusAway);
                    } else if (metroComboBox1.Text == "Do Not Disturb") {
                        skype.ChangeUserStatus(TUserStatus.cusDoNotDisturb);
                    } else if (metroComboBox1.Text == "Invisible") {
                        skype.ChangeUserStatus(TUserStatus.cusInvisible);
                    }
                    else {
                        skype.ChangeUserStatus(TUserStatus.cusOffline);
                    }
                    if (metroToggle2.Checked == true)
                    {
                            skype.CurrentUserProfile.MoodText = metroTextBox1.Text;
                    }
                    metroTile3.Text = "Running";
                    metroTile3.Style = MetroFramework.MetroColorStyle.Blue;
                }
                else
                {
                    skype.ChangeUserStatus(TUserStatus.cusOnline);
                    if (metroToggle2.Checked == true)
                    {
                        skype.CurrentUserProfile.MoodText = "";
                    }
                    metroTile3.Text = "Enabled";
                    metroTile3.Style = MetroFramework.MetroColorStyle.Green;
                }
                //}
            }
            else
            {
                skype.ChangeUserStatus(TUserStatus.cusOnline);
                skype.CurrentUserProfile.MoodText = "";
            }
        }
        private void Window_ContentRendered(object sender, EventArgs e)
        {
            skp = new Skype();
            ThemeManager.ChangeTheme(this, new MahApps.Metro.Accent("Steel", new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Steel.xaml")), Theme.Light);
                                                                        // Change the accent of the title bar to a more fitting "Steel" color.

            rm = Languages.Text.ResourceManager;                        // Initialize the ResourceManager

            var dc = new DisclaimerWindow();                            // Display the Disclaimer Window
            dc.WindowStartupLocation = WindowStartupLocation.Manual;    // And PROPERLY center it - WindowStartupLocation.CenterOwner doesn't do it properly for some reason
            dc.Left = this.Left + ((this.Width - dc.Width) / 2);        // Basically : position + ( size difference / 2 )
            dc.Top = this.Top + ((this.Height - dc.Height) / 2);
            dc.ShowDialog();

            if (dc.DialogResult != true)                    // If the dislaimer is not confirmed (the window is "just" closed)
                Environment.Exit(0);                        // Then exit.

            if (!skp.Client.IsRunning)                      // Check if the Skype client is running
            {
                //MessageBox.Show(rm.GetString("errSkypeNotFound"), rm.GetString("titleError"), MessageBoxButton.OK, MessageBoxImage.Error);
                var mmb = new ModernMsgBox(rm.GetString("errSkypeNotFound"), MessageBoxImage.Error);    // Since MahApps.Metro doesn't contain a way to
                mmb.Left = this.Left + ((this.Width - mmb.Width) / 2);                                  // display a message box fitting into the design
                mmb.Top = this.Top + ((this.Height - mmb.Height) / 2);                                  // I made one myself, more info in its code
                mmb.ShowDialog();                                                                       // I'm including the MessageBox equivalent in comment
                Environment.Exit(0);                                                                    // every time we need to invoke it for refference...
            }

            try
            {
                skp.Attach(6, true);            // Try to attach to Skype, and prepare for problems...
            }
            catch (COMException)
            {
                //MessageBox.Show(rm.GetString("errSkypeTookTooLong"), rm.GetString("titleError"), MessageBoxButton.OK, MessageBoxImage.Error);
                var mmb = new ModernMsgBox(rm.GetString("errSkypeTookTooLong"), MessageBoxImage.Error); // If it screws up, display an error message
                mmb.Left = this.Left + ((this.Width - mmb.Width) / 2);
                mmb.Top = this.Top + ((this.Height - mmb.Height) / 2);
                mmb.ShowDialog();
                Environment.Exit(0);
            }

            statusLabel.Content = rm.GetString("statusConnected");
        }
Example #53
0
 private SkypeWrapper()
 {
     _skype = new Skype();
     _skype.MessageStatus += FireNewMessageEvent;
     _skype.Attach(7, false);
 }
Example #54
0
        private void AttachSkype()
        {
            if (_mSkype != null) return;

            _mSkype = new Skype();
            //Use mSkype protocol version 7
            _mSkype.Attach(7, false);

            //Listen
            _mSkype.MessageStatus += skype_MessageStatus;
        }