Пример #1
0
 //Auto admin status detector
 void StAdddddmin(object sender, EventArgs e)
 {
     //in this child bot, we didnot use it.
     try
     {
         bool isonline = false;
         for (int i = 0; i < listBox1.Items.Count; i++)
         {
             if (admins.Text.Contains("#"))
             {
                 if (listBox1.Items[i].ToString().ToLower() == admins.Text.Split('#').ElementAt(0).ToLower() + "@nimbuzz.com")
                 {
                     isonline = true;
                 }
             }
             else
             {
                 if (listBox1.Items[i].ToString().ToLower() == admins.Text.ToLower() + "@nimbuzz.com")
                 {
                     isonline = true;
                 }
             } if (isonline)
             {
                 x.Status = sts.Text.Replace("%admin%", "[Owner: " + admins.Text.Split('#').ElementAt(0) + " is online]");
                 x.SendMyPresence();
             }
             else
             {
                 x.Status = sts.Text.Replace("%admin%", "[Owner: " + admins.Text.Split('#').ElementAt(0) + " is offline]");
                 x.SendMyPresence();
             }
         }
     }
     catch { }
 }
Пример #2
0
 /// <summary>
 /// Pings the HipChat server to ensure the client stays logged in.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Timers.ElapsedEventArgs"/> instance containing the event data.</param>
 void timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (LoggedIn)
     {
         connection.SendMyPresence();
     }
 }
Пример #3
0
        private void xmpp_OnLogin(object sender)
        {
            _logger.Info("OnLogin : Connection established and sending prescence");

            _xmpp.SendMyPresence();

            DisposeConnectionTimer();
            _sockWasConnected = true;
        }
Пример #4
0
 private void JoinChatRoom()
 {
     _chatJid  = new Jid(string.Format("pu~{0}@lvl.pvp.net", Hasher.Hash(_room)));
     _chatroom = new MucManager(_connection);
     _chatroom.AcceptDefaultConfiguration(_chatJid);
     _chatroom.JoinRoom(_chatJid, _connection.Username);
     _connection.SendMyPresence();
     SendMessage("Benebot V3 Alpha 8^)");
 }
Пример #5
0
        void xmppCon_OnRosterEnd(object sender)
        {
            osae.AddToLog("OnRosterEnd", true);

            // Send our own presence to teh server, so other epople send us online
            // and the server sends us the presences of our contacts when they are
            // available
            xmppCon.SendMyPresence();
        }
Пример #6
0
 private static void OnLogin(object sender)
 {
     try
     {
         _mCon.SendMyPresence();
         //Log("Logged in");
     }
     catch (Exception e)
     {
         LogManager.GetLogger("Debug").Error(e.Message);
     }
 }
Пример #7
0
        void xmppCon_OnRosterEnd(object sender)
        {
            if (gDebug)
            {
                Log.Debug("OnRosterEnd");
            }

            // Send our own presence to teh server, so other epople send us online
            // and the server sends us the presences of our contacts when they are
            // available
            xmppCon.SendMyPresence();
        }
Пример #8
0
 private void connected(object sender)
 {
     try
     {
         string[] mc = Messages.Lines;
         // Form1.optim++;
         x.Show = ShowType.NONE;
         x.SendMyPresence();
         x1.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(sender1 + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, mc[18].Replace("[MESSAGE]$", "").Replace("%ID%", this.ID).Replace("%L%", Environment.NewLine)));
     }
     catch (Exception m)
     {
     }
 }
Пример #9
0
 private void OnConnected2(object sender)
 {
     if (invalid != "disco")
     {
         y.Show   = ShowType.away;
         y.Status = sts;
         y.SendMyPresence();
         Send(sender1, "ID2: Connected.");
         Send(sender1, "ID2: Please wait while loading Add-Lists...");
     }
     else
     {
         y.Close();
     }
 }
Пример #10
0
 private void cboStatus_SelectedValueChanged(object sender, System.EventArgs e)
 {
     if (XmppCon != null && XmppCon.Authenticated)
     {
         if (cboStatus.Text == "online")
         {
             XmppCon.Show = ShowType.NONE;
         }
         else
         {
             XmppCon.Show = (ShowType)Enum.Parse(typeof(ShowType), cboStatus.Text, true);
         }
         XmppCon.SendMyPresence();
     }
 }
Пример #11
0
 public void AcceptFriendship(Jid user)
 {
     Xmpp.PresenceManager.ApproveSubscriptionRequest(user);
     Xmpp.PresenceManager.Subscribe(user);
     Xmpp.SendMyPresence();
     if (OnDataRecieved != null)
     {
         OnDataRecieved.Invoke(this, DataRecType.FriendList, Friends);
     }
     //Xmpp.RequestRoster();
 }
Пример #12
0
        void xmppCon_OnRosterEnd(object sender)
        {
            if (InvokeRequired)
            {
                // Windows Forms are not Thread Safe, we need to invoke this :(
                // We're not in the UI thread, so we need to call BeginInvoke
                BeginInvoke(new ObjectHandler(xmppCon_OnRosterEnd), new object[] { sender });
                return;
            }
            listEvents.Items.Add("OnRosterEnd");
            listEvents.SelectedIndex = listEvents.Items.Count - 1;

            // Send our own presence to teh server, so other epople send us online
            // and the server sends us the presences of our contacts when they are
            // available
            xmppCon.SendMyPresence();
        }
Пример #13
0
        private void OnLogin(object sender)
        {
            robot.Log.Debug("XMPP login success");
            client.Status = "BadaBingBot!";
            client.Show   = ShowType.chat;
            client.SendMyPresence();
            AddIgnore(client.MyJID.ToString());

            foreach (var room in config.Rooms)
            {
                var nickname = room.Nickname ?? config.Username;
                var roomJid  = new Jid(room.Jid);
                AddIgnore(room.Jid + "/" + nickname);

                chatManager.JoinRoom(roomJid, nickname, room.Password, true);
                chatManager.AcceptDefaultConfiguration(roomJid);
            }
        }
Пример #14
0
 public void Post()
 {
     _connection.SendMyPresence();
 }
Пример #15
0
 void timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     _xmppCon.SendMyPresence();
 }
Пример #16
0
        static void Main(string[] args)
        {
            Console.Title = "XMPPduino";

            xmppCon = new XmppClientConnection();

            System.ComponentModel.IContainer components = new System.ComponentModel.Container();
            serialPort = new System.IO.Ports.SerialPort(components);

            serialPort.PortName = Config.COM_PORT;
            serialPort.BaudRate = Config.Baud_Rate;

            xmppCon                          = new XmppClientConnection();
            xmppCon.Username                 = Config.Username;
            xmppCon.Password                 = Config.Password;
            xmppCon.SocketConnectionType     = agsXMPP.net.SocketConnectionType.Direct;
            xmppCon.ConnectServer            = "talk.google.com";
            xmppCon.Port                     = 5222;
            xmppCon.UseStartTLS              = true;
            xmppCon.AutoResolveConnectServer = false;
            xmppCon.Show                     = ShowType.chat;
            xmppCon.Server                   = Config.Server;

            xmppCon.AutoAgents   = false;
            xmppCon.AutoPresence = true;
            xmppCon.AutoRoster   = true;

            try {
                xmppCon.OnRosterStart += new ObjectHandler(xmppCon_OnRosterStart);
                xmppCon.OnRosterItem  += new XmppClientConnection.RosterHandler(xmppCon_OnRosterItem);
                xmppCon.OnRosterEnd   += new ObjectHandler(xmppCon_OnRosterEnd);
                xmppCon.OnPresence    += new PresenceHandler(xmppCon_OnPresence);
                xmppCon.OnMessage     += new MessageHandler(xmppCon_OnMessage);
                xmppCon.OnLogin       += new ObjectHandler(xmppCon_OnLogin);
                xmppCon.Open();
            }
            catch (Exception e) {
                Console.WriteLine(e.Message);
            }

            Wait("Login to server, please wait");
            bool bQuit = false;

            while (!bQuit)
            {
                string   command  = Console.ReadLine();
                string[] commands = command.Split(' ');

                switch (commands[0].ToLower())
                {
                case "quit":
                    bQuit = true;
                    break;

                case "msg":
                    string msg = command.Substring(command.IndexOf(commands[2]));
                    xmppCon.Send(new Message(new Jid(commands[1]), MessageType.chat, msg));
                    break;

                case "status":
                    switch (commands[1])
                    {
                    case "online":
                        xmppCon.Show = ShowType.NONE;
                        break;

                    case "away":
                        xmppCon.Show = ShowType.away;
                        break;

                    case "xa":
                        xmppCon.Show = ShowType.xa;
                        break;

                    case "chat":
                        xmppCon.Show = ShowType.chat;
                        break;
                    }
                    string status = command.Substring(command.IndexOf(commands[2]));
                    xmppCon.Status = status;
                    xmppCon.SendMyPresence();
                    break;
                }
            }
            xmppCon.Close();
        }
Пример #17
0
 public static void SendMyPresence()
 {
     XmppClientSingleton.SendMyPresence();
 }
Пример #18
0
 public static void SendMyPresence()
 {
     ThreadPool.QueueUserWorkItem(delegate { XmppClient.SendMyPresence(); });
 }
Пример #19
0
        static void Main(string[] args)
        {
            XmppClientConnection xmppCon = new XmppClientConnection();

            Console.Title = "Console Client";

            // read the jid from the console
            PrintHelp("Enter you Jid ([email protected]): ");
            Jid jid = new Jid("*****@*****.**");

            PrintHelp(String.Format("Enter password for '{0}': ", jid.ToString()));

            xmppCon.Password                 = "******";
            xmppCon.Username                 = jid.User;
            xmppCon.Server                   = "127.0.0.1";
            xmppCon.AutoAgents               = false;
            xmppCon.AutoPresence             = true;
            xmppCon.AutoRoster               = true;
            xmppCon.AutoResolveConnectServer = false;

            // Connect to the server now
            // !!! this is asynchronous !!!
            try
            {
                xmppCon.OnRosterStart += new ObjectHandler(xmppCon_OnRosterStart);
                xmppCon.OnRosterItem  += new XmppClientConnection.RosterHandler(xmppCon_OnRosterItem);
                xmppCon.OnRosterEnd   += new ObjectHandler(xmppCon_OnRosterEnd);
                xmppCon.OnPresence    += new PresenceHandler(xmppCon_OnPresence);
                xmppCon.OnMessage     += new MessageHandler(xmppCon_OnMessage);
                xmppCon.OnLogin       += new ObjectHandler(xmppCon_OnLogin);


                xmppCon.Open();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Wait("Login to server, please wait");

            PrintCommands();

            Console.WriteLine(xmppCon.Authenticated);

            bool bQuit = false;

            while (!bQuit)
            {
                string   command  = Console.ReadLine();
                string[] commands = command.Split(' ');

                switch (commands[0].ToLower())
                {
                case "help":
                    PrintCommands();
                    break;

                case "quit":
                    bQuit = true;
                    break;

                case "msg":
                    string msg = command.Substring(command.IndexOf(commands[2]));
                    xmppCon.Send(new Message(new Jid(commands[1]), MessageType.chat, msg));
                    break;

                case "status":
                    switch (commands[1])
                    {
                    case "online":
                        xmppCon.Show = ShowType.NONE;
                        break;

                    case "away":
                        xmppCon.Show = ShowType.away;
                        break;

                    case "xa":
                        xmppCon.Show = ShowType.xa;
                        break;

                    case "chat":
                        xmppCon.Show = ShowType.chat;
                        break;
                    }
                    string status = command.Substring(command.IndexOf(commands[2]));
                    xmppCon.Status = status;
                    xmppCon.SendMyPresence();
                    break;
                }
            }

            // close connection
            xmppCon.Close();
        }
Пример #20
0
        private void OnMessage(object sender, agsXMPP.protocol.client.Message NewMessage)
        {
            if (NewMessage.Type == MessageType.error || NewMessage.Type == null)
            {
                return;
            }
            else
            {
                Thread thre = new Thread(() =>
                {
                    try
                    {
                        string[] mc = Messages.Lines;
                        if (NewMessage.Type == MessageType.chat)
                        {
                            if (NewMessage.Body.Trim() != string.Empty)
                            {
                                if (NewMessage.From.User.ToLower().Trim() != owner.ToLower().Trim())
                                {
                                    x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(owner + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, mc[35].Replace("[MESSAGE]$", "").Replace("%L%", Environment.NewLine).Replace("%from%", NewMessage.From.User).Replace("%msg%", NewMessage.Body).Replace("%to%", NewMessage.From.User).Replace("%masters%", owner).Replace("%time%", DateTime.Now.ToString())));
                                }
                                if (NewMessage.From.User.ToLower().Trim() == owner.ToLower().Trim() && Selftesting)
                                {
                                    x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(owner + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, mc[35].Replace("[MESSAGE]$", "").Replace("%L%", Environment.NewLine).Replace("%from%", NewMessage.From.User).Replace("%msg%", NewMessage.Body).Replace("%to%", NewMessage.From.User).Replace("%masters%", owner).Replace("%time%", DateTime.Now.ToString())));
                                }
                            }
                            if (NewMessage.From.User == owner)
                            {
                                //stop
                                if (NewMessage.Body.ToLower().StartsWith("#logout"))
                                {
                                    reconnectable = false;
                                    x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(NewMessage.From.User + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, mc[27].Replace("[MESSAGE]$", "")));
                                    x.Close();
                                }
                                if (NewMessage.Body.Trim().ToLower().StartsWith("add#"))
                                {
                                    PresenceManager presx = new PresenceManager(x);
                                    string[] sp           = NewMessage.Body.Split('#');
                                    try
                                    {
                                        if (sp[1].Trim() != string.Empty)
                                        {
                                            Jid jid = new Jid(sp[1] + "@nimbuzz.com");
                                            x.RosterManager.AddRosterItem(jid);
                                            presx.Subscribe(jid);
                                            Message(owner, "Friend request was sent to '" + jid + "' and you will be notified he/she acceptes.");
                                        }
                                        else
                                        {
                                            Message(owner, "Command syntax error!");
                                        }
                                    }
                                    catch
                                    {
                                        Message(owner, "Command syntax error!");
                                    }
                                }
                                if (NewMessage.Body.Trim().ToLower().StartsWith("del#"))
                                {
                                    PresenceManager presx = new PresenceManager(x);
                                    string[] sp           = NewMessage.Body.Split('#');
                                    try
                                    {
                                        if (sp[1].Trim() != string.Empty)
                                        {
                                            Jid jid = new Jid(sp[1] + "@nimbuzz.com");
                                            x.RosterManager.RemoveRosterItem(jid);
                                            presx.Unsubscribe(jid);
                                            Message(owner, "'" + jid + "' is deleted.");
                                            Userslist.Items.Remove(jid);
                                            x.RequestRoster();
                                        }
                                        else
                                        {
                                            Message(owner, "Command syntax error!");
                                        }
                                    }
                                    catch
                                    {
                                        Message(owner, "Command syntax error!");
                                    }
                                }
                                //reply
                                if (NewMessage.Body.ToLower().StartsWith("chat/"))
                                {
                                    if (NewMessage.From.User == owner)
                                    {
                                        string[] sp = NewMessage.Body.Split('/');
                                        try
                                        {
                                            x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(sp[1] + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, sp[2]));
                                            x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(NewMessage.From.User + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, mc[36].Replace("[MESSAGE]$", "").Replace("%to%", sp[1]).Replace("%L%", Environment.NewLine)));
                                        }
                                        catch { Message(NewMessage.From.User, "Command syntax error!"); }
                                    }
                                    else
                                    {
                                        x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(owner + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, NewMessage.Body));
                                    }
                                }
                                //status
                                if (NewMessage.Body.Trim() != string.Empty && NewMessage.From.User.ToLower() == owner.ToLower())
                                {
                                    switch (NewMessage.Body.ToLower().Trim())
                                    {
                                    case "#online":
                                        {
                                            x.Status = sts;
                                            x.SendMyPresence();
                                            x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(owner + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, mc[42].Replace("[MESSAGE]$", "").Replace("%from%", NewMessage.From.User).Replace("%msg%", NewMessage.Body).Replace("%L%", Environment.NewLine).Replace("%sts%", "online").Replace("%thisid%", ID)));
                                            break;
                                        }

                                    case "#away":
                                        {
                                            x.Show   = ShowType.away;
                                            x.Status = sts;
                                            x.SendMyPresence();
                                            x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(owner + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, mc[42].Replace("[MESSAGE]$", "").Replace("%from%", NewMessage.From.User).Replace("%msg%", NewMessage.Body).Replace("%L%", Environment.NewLine).Replace("%sts%", "away").Replace("%thisid%", ID).Replace("%to%", NewMessage.From.User.Remove(0))));
                                            break;
                                        }

                                    case "#busy":
                                        {
                                            x.Show   = ShowType.dnd;
                                            x.Status = sts;
                                            x.SendMyPresence();
                                            x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(owner + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, mc[42].Replace("[MESSAGE]$", "").Replace("%from%", NewMessage.From.User).Replace("%msg%", NewMessage.Body).Replace("%L%", Environment.NewLine).Replace("%sts%", "busy").Replace("%thisid%", ID).Replace("%to%", NewMessage.From.User.Remove(0))));
                                            break;
                                        }

                                    case "+test":
                                        {
                                            Selftesting = true;
                                            Message(owner, "Self Testing is turned on");
                                            break;
                                        }

                                    case "-test":
                                        {
                                            Selftesting = false;
                                            Message(owner, "Self Testing is turned off");
                                            break;
                                        }

                                    case "+autoaccept":
                                        {
                                            AutoAccept = true;
                                            Message(owner, "Auto friend request accept is turned on");
                                            break;
                                        }

                                    case "-autoaccept":
                                        {
                                            AutoAccept = false;
                                            Message(owner, "Auto friend request accept is turned off");
                                            break;
                                        }

                                    case "+notify":
                                        {
                                            NotifyOnline = true;
                                            Message(owner, "Online Notifier is turned on");
                                            break;
                                        }

                                    case "-notify":
                                        {
                                            NotifyOnline = false;
                                            Message(owner, "Online Notifier is turned off");
                                            break;
                                        }

                                    case "#cpanel":
                                        {
                                            Message(owner, Form1.Fhelp.Replace("%master%", owner));
                                            break;
                                        }

                                    case "#users":
                                        {
                                            Message(owner, "\nOnline users list:\n" + Listout());
                                            break;
                                        }

                                    case "#accept":
                                        {
                                            int count = 0;
                                            if (addeduserlist.Text.Trim() != string.Empty)
                                            {
                                                PresenceManager presx = new PresenceManager(x);
                                                foreach (string l in addeduserlist.Lines)
                                                {
                                                    if (l.Trim() != string.Empty)
                                                    {
                                                        try
                                                        {
                                                            Jid jid = new Jid(l + "@nimbuzz.com");
                                                            x.RosterManager.AddRosterItem(jid);
                                                            presx.Subscribe(jid);
                                                            presx.ApproveSubscriptionRequest(jid);
                                                            count++;
                                                            Message(owner, jid + " is accepted");
                                                        }
                                                        catch { }
                                                    }
                                                }
                                                addeduserlist.Clear();
                                            }
                                            else
                                            {
                                                Message(owner, "No friend request sent.");
                                            }
                                            break;
                                        }

                                    default:
                                        {
                                            break;
                                        }
                                    }
                                }
                                if (NewMessage.Body.ToLower().StartsWith("stm#") && NewMessage.From.User == owner)
                                {
                                    string[] sp = NewMessage.Body.Split('#');
                                    x.Status    = sp[1];
                                    sts         = sp[1];
                                    x.SendMyPresence();
                                    x.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(owner + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, mc[43].Replace("[MESSAGE]$", "").Replace("%from%", NewMessage.From.User).Replace("%msg%", NewMessage.Body).Replace("%L%", Environment.NewLine).Replace("%stm%", sts).Replace("%thisid%", ID).Replace("%to%", NewMessage.From.User)));
                                }
                            }
                        }
                    }
                    catch (Exception v) {  }
                }); thre.IsBackground = true; thre.Start();
            }
        }
        private void OnLogin(object sender)
        {
            _xmpp.SendMyPresence();

            // Join rooms now
        }