VB.NET ALEXIA-IM FREE PROJECT SOURCE CODE

HI GUYS,DID YOU WAIT FOR THE FINAL CODES OF ALEXIA-IM.DLL V4?


TODAY I WILL POST THE CODES THAT I USE ON MY ALEXIA-IM CLIENT USING OUR LIBRARIES.








NOW ON MAIN FORM CODES




Imports SuperSocket.ClientEngine.Proxy
Imports WebSocket4Net
Imports System.Net
Imports System.Security.Authentication
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports ALEXIA_IM.alexia
Imports ALEXIA_IM

Imports System.Drawing.Drawing2D
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Reflection
Imports System.Text
Imports System.Threading
Imports System.Threading.Tasks
Imports System.Windows.Forms
Imports ALEXIA_IM.Shaping
Imports ALEXIA_IM.alexia.MultiUserChat
Imports ALEXIA_IM.alexia.ChatMessage
Imports ALEXIA_IM.alexia.User

Public Class MainForm

    Public ryu As Rub
    Public set_account As setting_account
    Public configure_room As conf_room
    Private inf As inifile
    Public paths As String
    Public profilepath As String
    Private Delegate Sub SetControlPropertyThreadSafeDelegate(ByVal control As Control, ByVal propertyName As String, ByVal propertyValue As Object)
    Private Shared _instance As MainForm
    Private chatFormList As Dictionary(Of String, ChatMessageForm)
    Private roomFormList As Dictionary(Of String, RoomMessageForm)
    Private publicRoomSearchCompleted As Boolean = True, joinedRoomSearchCompleted As Boolean = True



    Private Sub SetControlPropertyThreadSafe(ByVal control As Control, ByVal propertyName As String, ByVal propertyValue As Object)
        If control.InvokeRequired Then
            control.Invoke(New SetControlPropertyThreadSafeDelegate(AddressOf SetControlPropertyThreadSafe), New Object() {control, propertyName, propertyValue})
        Else
            control.[GetType]().InvokeMember(propertyName, BindingFlags.SetProperty, Nothing, control, New Object() {propertyValue})
        End If
    End Sub


    Public Sub log()
        Application.DoEvents()
        Task.Factory.StartNew(
     Sub()
         ryu = New Rub
         '  ryu.Host = "wss://chatp.net:5333/server"
         ryu.Host = txthost.Text
         ryu.AutoReconnect = True
         ryu.ReconnectInterval = 10000

         SetControlPropertyThreadSafe(lblstatus, "Text", "Connecting....")
         AddHandler ryu.OnLogin, Function(reu, authCode)

                                     Select Case authCode
                                         Case alexia.User.AuthCode.Success
                                             ' ryu.GetMucList(alexia.MultiUserChat.MucType.favourite)
                                             ryu.GetMucList(MucType.public)
                                             ryu.GetMucList(MucType.private)
                                             Panel1.Hide()
                                             Button1.Text = "Logout"
                                             lblstatus.Text = "Online"
                                             ' ryu.UpdateStatus("ALEXIA-IM Beta Version")
                                             ryu.GetProfile()
                                         Case alexia.User.AuthCode.Failed
                                             SetControlPropertyThreadSafe(txtusername, "Enabled", True)
                                             SetControlPropertyThreadSafe(txtpassword, "Enabled", True)
                                             SetControlPropertyThreadSafe(Button1, "Text", "Login")
                                             SetControlPropertyThreadSafe(lblstatus, "Text", "Wrong Password.")
                                         Case alexia.User.AuthCode.Disabled
                                             SetControlPropertyThreadSafe(txtusername, "Enabled", True)
                                             SetControlPropertyThreadSafe(txtpassword, "Enabled", True)
                                             SetControlPropertyThreadSafe(Button1, "Text", "Login")
                                             SetControlPropertyThreadSafe(lblstatus, "Text", "Account has been disabled.")

                                         Case alexia.User.AuthCode.[Error]
                                             SetControlPropertyThreadSafe(txtusername, "Enabled", True)
                                             SetControlPropertyThreadSafe(txtpassword, "Enabled", True)
                                             SetControlPropertyThreadSafe(Button1, "Text", "Login")
                                             SetControlPropertyThreadSafe(lblstatus, "Text", "Unable to login.")

                                     End Select
#Disable Warning BC42105
                                 End Function
#Enable Warning BC42105

         AddHandler ryu.OnLogout, Function(reu)
                                      SetControlPropertyThreadSafe(txtusername, "Enabled", True)
                                      SetControlPropertyThreadSafe(txtpassword, "Enabled", True)
                                      SetControlPropertyThreadSafe(Button1, "Text", "Login")
                                      contactPanel.Controls.Clear()
                                      publicLayoutPanel.Controls.Clear()
                                      favLayoutPanel.Controls.Clear()
                                      joinedLayoutPanel.Controls.Clear()
                                      myPic.ImageLocation = Nothing
                                      lblidnum.Text = ""
                                      lblstatus.Text = ""
                                      Panel1.Show()
                                      MessageBox.Show("LogOut!")
#Disable Warning BC42105
                                  End Function
#Enable Warning BC42105
         AddHandler ryu.OnClose, Function(reu)
                                     SetControlPropertyThreadSafe(txtusername, "Enabled", True)
                                     SetControlPropertyThreadSafe(txtpassword, "Enabled", True)
                                     SetControlPropertyThreadSafe(Button1, "Text", "Login")
                                     SetControlPropertyThreadSafe(Button1, "BackColor", Color.Green)
                                     Panel1.Show()
                                     MessageBox.Show("Close!")
                                     If ryu.AutoReconnect Then
                                         SetControlPropertyThreadSafe(lblstatus, "Text", "Reconnecting...")
                                     Else
                                         SetControlPropertyThreadSafe(lblstatus, "Text", "Disconnected.")
                                     End If
#Disable Warning BC42105
                                 End Function
#Enable Warning BC42105

         AddHandler ryu.OnError, Function(reu, [error])

                                     SetControlPropertyThreadSafe(txtusername, "Enabled", True)
                                     SetControlPropertyThreadSafe(txtpassword, "Enabled", True)
                                     SetControlPropertyThreadSafe(Button1, "Text", "Login")
                                     SetControlPropertyThreadSafe(lblstatus, "Text", [error])
#Disable Warning BC42105
                                 End Function
#Enable Warning BC42105

         AddHandler ryu.OnMucJoined, AddressOf ryu_OnMucJoined
         AddHandler ryu.OnMucError, AddressOf ryu_OnMucError
         AddHandler ryu.OnChatMessageSent, AddressOf ryu_OnChatMessageSent
         AddHandler ryu.OnChatMessageAck, AddressOf ryu_OnChatMessageAck
         AddHandler ryu.OnChatMessageStateChanged, AddressOf ryu_OnChatMessageStateChanged
         AddHandler ryu.OnGetMucInfo, AddressOf ryu_OnGetMucInfo
         AddHandler ryu.OnChatMessage, AddressOf ryu_OnChatMessage
         AddHandler ryu.OnMucSearchComplete, AddressOf ryu_OnMucSearchComplete
         AddHandler ryu.OnRoster, AddressOf ryu_OnRoster
         AddHandler ryu.OnUserPresence, AddressOf ryu_OnUserPresence
         AddHandler ryu.OnUserActivityResult, AddressOf ryu_OnUserActivityResult
         AddHandler ryu.OnFriendRequest, AddressOf ryu_OnFriendRequest
         AddHandler ryu.OnGetBlockedList, AddressOf ryu_OnGetBlockedList
         ryu.GetBlockedList()
         AddHandler ryu.OnUserProfileUpdates, AddressOf ryu_OnUserProfileUpdates
         AddHandler ryu.OnGetUserProfile, AddressOf ryu_OnGetUserProfile
         AddHandler ryu.OnMucCreate, AddressOf ryu_OnMucCreate

         If Not String.IsNullOrWhiteSpace(txtusername.Text) AndAlso Not String.IsNullOrWhiteSpace(txtpassword.Text) Then
             ryu.Login(txtusername.Text, txtpassword.Text)
         End If
     End Sub)
    End Sub

    Private Sub addJoinedRooms(ByVal info As MucInfo)
        If joinedLayoutPanel.Controls.ContainsKey(info.Name) Then
            Dim item As RoomItem = CType(joinedLayoutPanel.Controls(info.Name), RoomItem)
            item.Tag = info.CurrentUsers
            item.RoomUsers = "(" & info.CurrentUsers & "/" + info.MaxUsers & ")"
            item.IsRoomLocked = info.IsLocked
            item.IsRoomMemberOnly = info.IsMemberOnly
        Else
            Dim item As RoomItem = New RoomItem(info.Name)
            item.Tag = info.CurrentUsers
            item.RoomName = info.Name
            item.RoomPicText = info.Name(0)
            item.RoomUsers = "(" & info.CurrentUsers & "/" + info.MaxUsers & ")"
            item.IsRoomLocked = info.IsLocked
            item.IsRoomMemberOnly = info.IsMemberOnly
            joinedLayoutPanel.UIThread(Function()
                                           joinedLayoutPanel.Controls.Add(item)
                                       End Function)
        End If

        joinedLayoutPanel.UIThread(Function()
                                       Dim itemArray As RoomItem() = joinedLayoutPanel.Controls.Cast(Of RoomItem)().OrderBy(Function(x) x.Key).ToArray()
                                       itemArray = joinedLayoutPanel.Controls.Cast(Of RoomItem)().OrderByDescending(Function(x) x.Tag).ToArray()
                                       joinedLayoutPanel.Controls.AddRange(itemArray)
                                   End Function)
    End Sub
    Private Sub ryu_OnMucJoined(reu As Rub, muc As Muc)
        If muc IsNot Nothing Then
            Dim form As RoomMessageForm = MainForm.Instance.getRoomForm(muc.Name)

            If form IsNot Nothing Then
                form.roomJoined(muc)
            Else
                Me.UIThread(Function()
                                form = New RoomMessageForm()
                                MainForm.Instance.addRoomForm(muc.Name, form)
                                form.Show()
                                form.RoomName = muc.Name
                                form.RoomSuject = muc.SubjectMessage
                                form.CurrentUsers = muc.CurrentUsers.Count
                                form.roomJoined(muc)
#Disable Warning BC42105
                            End Function)
#Enable Warning BC42105
            End If
        End If
    End Sub
    Public Sub addRoomForm(ByVal key As String, ByVal form As RoomMessageForm)
        If roomFormList Is Nothing Then
            roomFormList = New Dictionary(Of String, RoomMessageForm)()
        End If

        If Not roomFormList.ContainsKey(key) Then
            roomFormList.Add(key, form)
        End If
    End Sub
    Private Sub ryu_OnMucCreate(reu As Rub, mucName As String, resultType As ResultType)
        Select Case resultType
            Case ResultType.Success
                MessageBox.Show("New ChatRoom Succesfully Created!")
            Case ResultType.AlreadyExists
                MessageBox.Show("ChatRoom Already Exists!")
            Case ResultType.[Error]
                MessageBox.Show("Creating ChatRoom Error!")
            Case ResultType.NonLatinError
                MessageBox.Show("Unable to Create ChatRoom")
            Case ResultType.NullBalance
                MessageBox.Show("You Dont Have able to create New ChatRoom")
            Case ResultType.LimitOver
                MessageBox.Show("You Have Reach Creating ChatRoom")
        End Select
    End Sub

    Private Sub ryu_OnChatMessageSent(reu As Rub, messageId As String, timestamp As Long)
        CheckForIllegalCrossThreadCalls = False
        Me.UIThread(Function()
                        Dim formList As Dictionary(Of String, ChatMessageForm) = MainForm.Instance.getChatFormList()
                        If formList Is Nothing Then
                            Return (formList)
                        Else
                            For i As Integer = 0 To formList.Count - 1
                                Dim form As ChatMessageForm = formList.ElementAt(i).Value
                                form.sentMsg(messageId, timestamp)
                            Next
                        End If
                    End Function)
    End Sub
    Public Function getChatFormList() As Dictionary(Of String, ChatMessageForm)
        If chatFormList Is Nothing Then
            chatFormList = New Dictionary(Of String, ChatMessageForm)()
        End If
#Disable Warning BC42105
    End Function
#Enable Warning BC42105
    Public cf As CaptchaForm
    Public Sub capmsg(ByVal muc As String, ByVal capt As String)
        ryu.JoinMucCap(muc, capt, Rub.url)
    End Sub

    Private Sub ryu_OnMucError(reu As Rub, mucName As String, [error] As MucError)
        Dim errorMsg As String = ""

        Select Case [error]
            Case MucError.Outcast
                errorMsg = "You are banned in this room."
                txtlog.AppendText(mucName + " » " + errorMsg + vbNewLine)
            Case MucError.RequiredMembership
                errorMsg = "Room is members only."
                txtlog.AppendText(mucName + " » " + errorMsg + vbNewLine)
            Case MucError.RequiredPassword
                errorMsg = "Room is locked."
                txtlog.AppendText(mucName + " » " + errorMsg + vbNewLine)
            Case MucError.RequiredCaptcha
                errorMsg = "Room Required Captcha"
                txtlog.AppendText(mucName + " » " + errorMsg + vbNewLine)
                Me.UIThread(Function()
                                cf = New CaptchaForm()
                                cf.Show()
                                cf.Text = mucName
                                cf.PictureBox1.LoadAsync(Rub.url)
#Disable Warning BC42105
                            End Function)
#Enable Warning BC42105
            Case MucError.ErrorNotDefined
                errorMsg = "error-not-defined."
                txtlog.AppendText(mucName + " » " + errorMsg + vbNewLine)
            Case MucError.MaxUsers
                errorMsg = "Room has maximum users."
                txtlog.AppendText(mucName + " » " + errorMsg + vbNewLine)
            Case MucError.NotInMuc
                errorMsg = "You are not in room."
                txtlog.AppendText(mucName + " » " + errorMsg + vbNewLine)
            Case MucError.InsufficientPrivilege
                errorMsg = "You have insufficent privilege."
                txtlog.AppendText(mucName + " » " + errorMsg + vbNewLine)
            Case MucError.Unauthorized
                errorMsg = "Room banned your IP."
                txtlog.AppendText(mucName + " » " + errorMsg + vbNewLine)
            Case MucError.AlreadyJoined
                errorMsg = "You are already in room"
                txtlog.AppendText(mucName + " » " + errorMsg + vbNewLine)
            Case Else
                errorMsg = "Unable to join room."
                txtlog.AppendText(mucName + " » " + errorMsg + vbNewLine)
        End Select

        Dim form As RoomMessageForm = MainForm.Instance.getRoomForm(mucName)

        If form IsNot Nothing Then
            form.showRoomError(mucName, errorMsg)
        Else
            ' txtlog.AppendText(mucName + " » " + errorMsg + vbNewLine)
            '   Me.UIThread(Function() MessageBox.Show(errorMsg, mucName, MessageBoxButtons.OK, MessageBoxIcon.[Error]))
        End If
    End Sub
    Public Function getRoomForm(ByVal key As String) As RoomMessageForm
        If roomFormList IsNot Nothing AndAlso roomFormList.ContainsKey(key) Then
            Return roomFormList(key)
        Else
            Return Nothing
        End If
    End Function
    Private Sub ryu_OnChatMessageAck(reu As Rub, ack As MessageAck)
        If ack IsNot Nothing Then
            Dim form As ChatMessageForm = MainForm.Instance.getChatForm(ack.From)
            If form IsNot Nothing Then
                form.msgAck(ack)
            End If
        End If
    End Sub

    Private Sub ryu_OnChatMessageStateChanged(reu As Rub, state As MessageState)
        If state IsNot Nothing Then
            Dim form As ChatMessageForm = MainForm.Instance.getChatForm(state.From)

            If form IsNot Nothing Then
                Dim mode As String = "offline"

                If contactPanel.Controls.ContainsKey(state.From) Then
                    Dim item As ContactItem = CType(contactPanel.Controls(state.From), ContactItem)
                    mode = item.Mode
                End If

                form.msgState(state, mode)
            End If
        End If
    End Sub

    Private Sub ryu_OnUserProfileUpdates(ByVal reu As Rub, ByVal user As UserStatus)
        If user.From = ryu.Username Then
            myPic.LoadAsync(user.PhotoUrl)
        Else
            Dim contact As ContactItem = CType(contactPanel.Controls(user.From), ContactItem)
            contact.Username = user.From
            contact.Message = user.Message
            contact.Tag = If(user.Mode = Mode.online, 1, 0)
            contact.IsOnline = user.Mode = Mode.online
            contact.Mode = If(user.Mode = Mode.online, "online", "offline")
            contact.PicUrl = user.PhotoUrl
        End If
    End Sub

    Private Sub ryu_OnGetUserProfile(ByVal reu As Rub, ByVal profile As UserProfile)
        If profile.Username = ryu.Username Then
            myPic.ImageLocation = (profile.PhotoUrl)
            lblidnum.Text = profile.AccountID
        End If


    End Sub
    Private Sub addFriendRequest(ByVal roster As Roster)
        For i As Integer = 0 To roster.Users.Count - 1
            Dim status As UserStatus = roster.Users(i)

            If status IsNot Nothing Then

                If Not String.IsNullOrWhiteSpace(status.From) Then

                    If contactPanel.Controls.ContainsKey(status.From) Then
                        Dim contact As ContactItem = CType(contactPanel.Controls(status.From), ContactItem)
                        contact.Username = status.From
                        contact.Message = status.Message
                        contact.Tag = -1
                        contact.Mode = "pending"
                        contact.PicUrl = status.PhotoUrl
                    Else
                        Dim contact As ContactItem = New ContactItem(status.From)
                        contact.Size = New Size(270, 70)
                        contact.Username = status.From
                        contact.Message = status.Message
                        contact.Tag = -1
                        contact.Mode = "pending"
                        contact.PicUrl = status.PhotoUrl
                        contactPanel.UIThread(Function()
                                                  contactPanel.Controls.Add(contact)
#Disable Warning BC42105
                                              End Function)
#Enable Warning BC42105
                    End If
                End If
            End If
        Next

        contactPanel.UIThread(Function()
                                  Dim itemArray As ContactItem() = contactPanel.Controls.Cast(Of ContactItem)().OrderBy(Function(x) x.Key).ToArray()
                                  itemArray = contactPanel.Controls.Cast(Of ContactItem)().OrderByDescending(Function(x) x.Tag).ToArray()
                                  contactPanel.Controls.AddRange(itemArray)
#Disable Warning BC42105
                              End Function)
#Enable Warning BC42105
    End Sub

    Private Sub ryu_OnFriendRequest(ByVal reu As Rub, ByVal roster As Roster)
        addFriendRequest(roster)
    End Sub
    Public childbotform As ChildBotForm
    Public s As String
    Private Sub ryu_OnChatMessage(ByVal reu As Rub, ByVal chat As ChatMessage.Message)
        Dim from As String = chat.From
        Dim body As String = chat.Body
        If chat IsNot Nothing Then
            Dim form As ChatMessageForm = MainForm.Instance.getChatForm(chat.From)

            If form IsNot Nothing Then
                form.newMessage(chat)
            Else
                Me.UIThread(Function()

                                If CheckBox1.Checked Then
                                    Return (chat)
                                Else
                                    form = New ChatMessageForm()
                                    form.Text = chat.From
                                    If contactPanel.Controls.ContainsKey(chat.From.ToString) Then
                                        Dim item As ContactItem = CType(contactPanel.Controls(chat.From), ContactItem)
                                        If Not String.IsNullOrWhiteSpace(item.PicUrl) Then
                                            form.userPic.LoadAsync(item.PicUrl)
                                        End If
                                        form.userStateLbl.Text = item.Mode
                                        '==============
                                        Me.UIThread(Function()
                                                        If CheckBox2.Checked Then
                                                            If body.ToLower().Contains("cj/") Then
                                                                ryu.SendMessage(chat.From, "Request Recieve! " + chat.From, MessageType.ChatMessage)
                                                                body = Replace(body, "cj/", "")
                                                                childbotform = New ChildBotForm()
                                                                Dim nick As String = from
                                                                s = body
                                                                childbotform.Text = nick
                                                                childbotform.Show()
                                                            End If
                                                        Else
                                                            '  ryu.SendMessage(chat.From, "hi " + chat.From + ", ShareBots is Not Now Available....", MessageType.ChatMessage)
                                                        End If


#Disable Warning BC42105
                                                    End Function)
#Enable Warning BC42105

                                        '==============

                                    Else
                                        ryu.SendMessage(chat.From, "You Dont Have the Right to Get Bots,Add me First Before you Get Bots. " + chat.From, MessageType.ChatMessage)

                                    End If
                                    form.Show()
                                    MainForm.Instance.addChatForm(chat.From, form)
                                    form.newMessage(chat)
                                End If
#Disable Warning BC42105
                            End Function)
#Enable Warning BC42105
            End If
        End If

    End Sub

    Public Function getChatForm(ByVal key As String) As ChatMessageForm
        If chatFormList IsNot Nothing AndAlso chatFormList.ContainsKey(key) Then
            Return chatFormList(key)
        Else
            Return Nothing
        End If
    End Function

    Public Sub addChatForm(ByVal key As String, ByVal form As ChatMessageForm)
        If chatFormList Is Nothing Then
            chatFormList = New Dictionary(Of String, ChatMessageForm)()
        End If

        If Not chatFormList.ContainsKey(key) Then
            chatFormList.Add(key, form)
        End If
    End Sub


    '  Private Sub ryu_OnMucSearchComplete(reu As Rub, mucType As MucType, infoList As List(Of MucInfo))
    Private Sub ryu_OnMucSearchComplete(reu As Rub, mucType As MucType, infoList As List(Of MucInfo))
        Application.DoEvents()
        Me.UIThread(Function()
                        If infoList.Count > 0 Then
                            Thread.Sleep(2000)
                            If ryu IsNot Nothing Then
                                '  ryu.GetNextMucList()
                            End If

                        End If

                        Select Case mucType
                            Case MucType.[public]
                                addPublicRooms(infoList)
                            Case MucType.favourite
                                addFavRooms(infoList)

                        End Select

#Disable Warning BC42105
                    End Function)
#Enable Warning BC42105

    End Sub
    Private Sub addFavRooms(ByVal mucList As List(Of MucInfo))
        Application.DoEvents()
#Disable Warning BC42359 ' The Task returned from this Async Function will be dropped, and any exceptions in it ignored
        Me.UIThread(Async Function()
                        Await Task.Run(Sub()
                                           If mucList.Count > 0 Then

                                               For i As Integer = 0 To mucList.Count - 1
                                                   Dim info As MucInfo = mucList(i)

                                                   If favLayoutPanel.Controls.ContainsKey(info.Name.ToString) Then
                                                       Dim item As RoomItem = CType(favLayoutPanel.Controls(info.Name.ToString), RoomItem)
                                                       item.Tag = info.CurrentUsers
                                                       cu = "(" & info.CurrentUsers.ToString & "/" + info.MaxUsers.ToString & ")"
                                                       item.RoomUsers = cu
                                                       item.IsRoomLocked = info.IsLocked
                                                       item.IsRoomMemberOnly = info.IsMemberOnly
                                                   Else
                                                       Dim item As RoomItem = New RoomItem(info.Name.ToString)
                                                       item.Tag = info.CurrentUsers
                                                       item.RoomName = info.Name.ToString
                                                       item.RoomPicText = info.Name(0)
                                                       cu = "(" & info.CurrentUsers.ToString & "/" + info.MaxUsers.ToString & ")"
                                                       item.RoomUsers = cu
                                                       item.IsRoomLocked = info.IsLocked
                                                       item.IsRoomMemberOnly = info.IsMemberOnly
                                                       favLayoutPanel.UIThread(Function()
                                                                                   favLayoutPanel.Controls.Add(item)
#Disable Warning BC42105
                                                                               End Function)
#Enable Warning BC42105
                                                   End If
                                               Next

                                               favLayoutPanel.UIThread(Function()
                                                                           Dim itemArray As RoomItem() = favLayoutPanel.Controls.Cast(Of RoomItem)().OrderBy(Function(x) x.Key).ToArray()
                                                                           itemArray = favLayoutPanel.Controls.Cast(Of RoomItem)().OrderByDescending(Function(x) x.Tag).ToArray()
                                                                           favLayoutPanel.Controls.AddRange(itemArray)
#Disable Warning BC42105
                                                                       End Function)
#Enable Warning BC42105
                                           End If
                                       End Sub)
                    End Function)
    End Sub
    Dim cu As String = ""
    Private Sub addPublicRooms(ByVal mucList As List(Of MucInfo))
        Application.DoEvents()
#Disable Warning BC42359 ' The Task returned from this Async Function will be dropped, and any exceptions in it ignored
        Me.UIThread(Async Function()
                        Await Task.Run(Sub()
                                           If mucList.Count > 0 Then

                                               For i As Integer = 0 To mucList.Count - 1
                                                   Dim info As MucInfo = mucList(i)
                                                   '  Dim tst As Integer

                                                   If publicLayoutPanel.Controls.ContainsKey(info.Name.ToString) Then
                                                       Dim item As RoomItem = CType(publicLayoutPanel.Controls(info.Name.ToString), RoomItem)
                                                       item.Tag = info.CurrentUsers
                                                       cu = "(" & info.CurrentUsers.ToString & "/" + info.MaxUsers.ToString & ")"
                                                       item.RoomUsers = cu
                                                       item.IsRoomLocked = info.IsLocked
                                                       item.IsRoomMemberOnly = info.IsMemberOnly
                                                   Else
                                                       Dim item As RoomItem = New RoomItem(info.Name.ToString)
                                                       item.Tag = info.CurrentUsers
                                                       item.RoomName = info.Name.ToString
                                                       item.RoomPicText = info.Name(0)
                                                       cu = "(" & info.CurrentUsers.ToString & "/" + info.MaxUsers.ToString & ")"
                                                       item.RoomUsers = cu
                                                       item.IsRoomLocked = info.IsLocked
                                                       item.IsRoomMemberOnly = info.IsMemberOnly

                                                       publicLayoutPanel.UIThread(Function()
                                                                                      publicLayoutPanel.Controls.Add(item)
#Disable Warning BC42105
                                                                                  End Function)
#Enable Warning BC42105
                                                   End If
                                               Next

                                               publicLayoutPanel.UIThread(Function()
                                                                              Dim itemArray As RoomItem() = publicLayoutPanel.Controls.Cast(Of RoomItem)().OrderBy(Function(x) x.Key).ToArray()
                                                                              itemArray = publicLayoutPanel.Controls.Cast(Of RoomItem)().OrderByDescending(Function(x) x.Tag).ToArray()
                                                                              publicLayoutPanel.Controls.AddRange(itemArray)
#Disable Warning BC42105
                                                                          End Function)
#Enable Warning BC42105
                                           End If



                                       End Sub)
                    End Function)

    End Sub
    Dim ic As Integer
    Dim im As Integer
    Private Sub ryu_OnGetMucInfo(reu As Rub, info As MucInfo)
        If info IsNot Nothing Then
            addJoinedRooms(info)
            Dim form As RoomMessageForm = MainForm.Instance.getRoomForm(info.Name)

            If form IsNot Nothing Then
                form.CurrentUsers = info.CurrentUsers
                form.MaxUsers = info.MaxUsers
            End If
        End If
    End Sub

    Private Sub ryu_OnUserActivityResult(ByVal reu As Rub, ByVal activity As UserActivity)
        If activity IsNot Nothing Then

            If contactPanel.Controls.ContainsKey(activity.From) Then
                Dim item As ContactItem = New ContactItem(activity.From)
                item.LastSeen = activity.LastSeen
            End If
        End If
    End Sub

    Private Sub ryu_OnUserPresence(ByVal reu As Rub, ByVal pres As UserPresence)
        updateUserPres(pres.From, pres.IsOnline)
    End Sub
    Private Sub updateUserPres(ByVal username As String, ByVal isOnline As Boolean)
        If contactPanel.Controls.ContainsKey(username) Then
            Dim contact As ContactItem = CType(contactPanel.Controls(username), ContactItem)
            contact.Tag = If(isOnline, 1, 0)
            contact.IsOnline = isOnline
            contact.Mode = If(isOnline, "online", "offline")
        End If

        contactPanel.UIThread(Function()
                                  Dim itemArray As ContactItem() = contactPanel.Controls.Cast(Of ContactItem)().OrderBy(Function(x) x.Key).ToArray()
                                  itemArray = contactPanel.Controls.Cast(Of ContactItem)().OrderByDescending(Function(x) x.Tag).ToArray()
                                  contactPanel.Controls.AddRange(itemArray)
#Disable Warning BC42105
                              End Function)
#Enable Warning BC42105
    End Sub

    Public Sub removeRoomForm(ByVal key As String)
        If roomFormList IsNot Nothing Then

            If roomFormList.ContainsKey(key) Then
                roomFormList.Remove(key)
            End If
        End If
    End Sub

    Private Sub addUser(ByVal roster As Roster)
        On Error Resume Next
#Disable Warning BC42359 ' The Task returned from this Async Function will be dropped, and any exceptions in it ignored
        Me.UIThread(Async Function()
                        Await Task.Run(Sub()

                                           For i As Integer = 0 To roster.Users.Count - 1
                                               Dim status As UserStatus = roster.Users(i)

                                               If status IsNot Nothing Then

                                                   If Not String.IsNullOrWhiteSpace(status.From) Then
                                                       If contactPanel.Controls.ContainsKey(status.From) Then
                                                           Dim contact As ContactItem = CType(contactPanel.Controls(status.From), ContactItem)
                                                           contact.Username = status.From.ToString
                                                           contact.Message = status.Message.ToString
                                                           contact.Tag = If(status.Mode.ToString = Mode.online, 1, 0)
                                                           contact.IsOnline = status.Mode.ToString = Mode.online
                                                           contact.Mode = If(status.Mode.ToString = Mode.online.ToString, "online", "offline")
                                                           contact.PicUrl = status.PhotoUrl
                                                       Else
                                                           Dim contact As ContactItem = New ContactItem(status.From.ToString)
                                                           contact.Size = New Size(270, 70)
                                                           contact.Username = status.From.ToString
                                                           contact.Message = status.Message.ToString
                                                           contact.Tag = If(status.Mode = Mode.online, 1, 0)
                                                           contact.IsOnline = status.Mode = Mode.online
                                                           contact.Mode = If(status.Mode = Mode.online, "online", "offline")
                                                           contact.PicUrl = status.PhotoUrl
                                                           contactPanel.UIThread(Function()
                                                                                     contactPanel.Controls.Add(contact)
#Disable Warning BC42105
                                                                                 End Function)
#Enable Warning BC42105
                                                       End If

                                                       If status.Mode = Mode.offline Then
                                                           Me.UIThread(Sub()
                                                                           Thread.Sleep(1000)
                                                                           If ryu.IsLogged Then
                                                                               ryu.CheckUserActivity(status.From)
                                                                           End If
                                                                       End Sub)
                                                       End If

                                                   End If
                                               End If

                                           Next

                                           contactPanel.UIThread(Function()
                                                                     Dim itemArray As ContactItem() = contactPanel.Controls.Cast(Of ContactItem)().OrderBy(Function(x) x.Key).ToArray()
                                                                     itemArray = contactPanel.Controls.Cast(Of ContactItem)().OrderByDescending(Function(x) x.Tag).ToArray()
                                                                     contactPanel.Controls.AddRange(itemArray)
#Disable Warning BC42105
                                                                 End Function)
#Enable Warning BC42105

                                       End Sub)
                    End Function)
#Enable Warning BC42359 ' The Task returned from this Async Function will be dropped, and any exceptions in it ignored


    End Sub

    Private Sub ryu_OnRoster(ByVal reu As Rub, ByVal roster As Roster)
        addUser(roster)
    End Sub

    Private Sub ryu_OnWrite(reu As Rub, str As String)
#Disable Warning BC42359 ' The Task returned from this Async Function will be dropped, and any exceptions in it ignored
        Me.UIThread(Async Function()
                        Await Task.Run(Sub()
                                           '   rtfdebug.SelectionColor = Color.Red
                                           '    rtfdebug.AppendText("Write:")
                                           '    rtfdebug.SelectionColor = Color.Black
                                           '    rtfdebug.AppendText(str + vbNewLine)
                                           '    rtfdebug.ScrollToCaret()
                                       End Sub)
                    End Function)
    End Sub

    Private Sub ryu_OnRead(reu As Rub, str As String)
#Disable Warning BC42359 ' The Task returned from this Async Function will be dropped, and any exceptions in it ignored
        Me.UIThread(Async Function()
                        Await Task.Run(Sub()
                                           '    rtfdebug.SelectionColor = Color.Red
                                           '     rtfdebug.AppendText("Read:")
                                           '    rtfdebug.SelectionColor = Color.Black
                                           '    rtfdebug.AppendText(str + vbNewLine)
                                           '    rtfdebug.ScrollToCaret()
                                       End Sub)
                    End Function)
    End Sub
    Public Shared ReadOnly Property Instance As MainForm
        Get

            If _instance Is Nothing Then
                _instance = New MainForm()
            End If

            Return _instance
        End Get
    End Property
    Private Sub ryu_OnGetBlockedList(reu As Rub, blockedList As List(Of String))
        updateBlockedUser(blockedList)
    End Sub
    Private Sub updateBlockedUser(ByVal blockedList As List(Of String))
        For Each username As String In blockedList

            If contactPanel.Controls.ContainsKey(username) Then
                Dim contact As ContactItem = CType(contactPanel.Controls(username), ContactItem)
                contact.Tag = CInt(contact.Tag) - 10
                contact.Mode = "blocked"
            End If
        Next

        For i As Integer = 0 To contactPanel.Controls.Count - 1
            Dim contact As ContactItem = CType(contactPanel.Controls(i), ContactItem)

            If CInt(contact.Tag) <= -9 Then

                If blockedList.Count > 0 Then

                    If Not blockedList.Contains(contact.Username) Then

                        If contact.Tag IsNot Nothing Then
                            contact.Tag = CInt(contact.Tag) + 10
                        End If
                    End If
                Else

                    If contact.Tag IsNot Nothing Then
                        contact.Tag = CInt(contact.Tag) + 10
                    End If
                End If

                If CInt(contact.Tag) < -1 Then
                    contact.Mode = "blocked"
                Else

                    Select Case CInt(contact.Tag)
                        Case -1
                            contact.Mode = "pending"
                        Case 0
                            contact.Mode = "offline"
                        Case 1
                            contact.Mode = "online"
                        Case Else
                    End Select
                End If
            End If
        Next

        contactPanel.UIThread(Function()
                                  Dim itemArray As ContactItem() = contactPanel.Controls.Cast(Of ContactItem)().OrderBy(Function(x) x.Key).ToArray()
                                  itemArray = contactPanel.Controls.Cast(Of ContactItem)().OrderByDescending(Function(x) x.Tag).ToArray()
                                  contactPanel.Controls.AddRange(itemArray)
#Disable Warning BC42105
                              End Function)
#Enable Warning BC42105
    End Sub
    Dim _gr As GraphicsPath
    Dim gr As GraphicsPath
    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Application.DoEvents()
        CheckForIllegalCrossThreadCalls = False
        TextBox1.Text = Application.StartupPath
        _instance = Me
        gr = RoundedRectangle.Create(txtusername.ClientRectangle, 10, RoundedRectangle.RectangleCorners.All)
        txtusername.Region = New Region(gr)
        gr = RoundedRectangle.Create(txtpassword.ClientRectangle, 10, RoundedRectangle.RectangleCorners.All)
        txtpassword.Region = New Region(gr)
        gr = RoundedRectangle.Create(txthost.ClientRectangle, 10, RoundedRectangle.RectangleCorners.All)
        txthost.Region = New Region(gr)
        _gr = RoundedRectangle.Create(myPic.ClientRectangle, 25, RoundedRectangle.RectangleCorners.All)
        myPic.Region = New Region(_gr)
        Timer1.Start()
    End Sub


    Private Sub roomTabControl_Selected(sender As Object, e As TabControlEventArgs) Handles roomTabControl.Selected
        Application.DoEvents()

        If ryu.IsLogged Then

            If e.TabPageIndex = 1 Then

                Select Case roomTabControl.SelectedIndex
                    Case 0
                        ryu.GetMucList(MucType.favourite)
                        publicRoomSearchCompleted = True
                    Case 1

                        If publicRoomSearchCompleted Then
                            ryu.GetMucList(MucType.[public])
                        End If

                    Case 2

                        Dim joinedList As List(Of Muc) '= ryu.joinedMucList.ToString

                        If joinedRoomSearchCompleted Then
                            UIThread(Sub()
                                         joinedRoomSearchCompleted = False

#Disable Warning BC42104
                                         For i As Integer = 0 To joinedList.Count - 1
#Enable Warning BC42104

                                             If ryu.IsLogged Then
                                                 ryu.GetMucInfo(joinedList(i).Name)
                                                 Thread.Sleep(2000)
                                             End If
                                         Next

                                         joinedRoomSearchCompleted = True
                                     End Sub)
                        End If

                    Case Else
                End Select
            End If
        Else
            Return
        End If
    End Sub

    Private Sub TabControl1_Selected(sender As Object, e As TabControlEventArgs) Handles TabControl1.Selected
        Application.DoEvents()

        If ryu.IsLogged Then

            If e.TabPageIndex = 1 Then

                Select Case roomTabControl.SelectedIndex
                    Case 0
                        ryu.GetMucList(MucType.favourite)
                        publicRoomSearchCompleted = True
                    Case 1

                        If publicRoomSearchCompleted Then
                            ryu.GetMucList(MucType.[public])
                        End If

                    Case 2

                        Dim joinedList As List(Of Muc)

                        If joinedRoomSearchCompleted Then
                            UIThread(Sub()
                                         joinedRoomSearchCompleted = False

#Disable Warning BC42104
                                         For i As Integer = 0 To joinedList.Count - 1
#Enable Warning BC42104

                                             If ryu.IsLogged Then
                                                 ryu.GetMucInfo(joinedList(i).Name)
                                                 Thread.Sleep(2000)
                                             End If
                                         Next

                                         joinedRoomSearchCompleted = True
                                     End Sub)
                        End If

                    Case Else
                End Select
            End If
        Else
            Return
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs)
        ryu.GetMucList(MucType.public)
        ryu.GetMucList(MucType.private)
    End Sub
    Public Sub removeChatForm(ByVal key As String)
        If chatFormList IsNot Nothing Then

            If chatFormList.ContainsKey(key) Then
                chatFormList.Remove(key)
            End If
        End If
    End Sub



    Private Sub MainForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        My.Settings.Save()
        Application.Exit()
    End Sub

    Private Sub MainForm_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed

        My.Settings.Save()
        Application.Exit()
    End Sub

    Protected Const karakter As String = "››"
    Protected Const inpesan As String = "»"
    Protected Const outpesan As String = "«"
    Dim mysoft As String
    Dim index As Integer
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        On Error Resume Next
        CheckForIllegalCrossThreadCalls = False

        mysoft = "Alexia-Im"


        Label2.Text = mysoft.Substring(0, index)
        index += 1
        If index = Text.Length + 1 Then

            index = 0

        End If


    End Sub

    Private Sub Button2_Click_1(sender As Object, e As EventArgs)
        ryu.Logout()
        contactPanel.Controls.Clear()
        publicLayoutPanel.Controls.Clear()
        favLayoutPanel.Controls.Clear()

    End Sub

    Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem.Click
        ryu.UpdateProfilePic(txtprofile.Text)
    End Sub

    Private Sub SaveToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem1.Click
        ryu.UpdateStatus(txtstatus.Text)
    End Sub

    Private Sub CreatePublicRoomToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CreatePublicRoomToolStripMenuItem.Click
        ryu.CreateMuc(txtpublicroom.Text, "")
    End Sub

    Private Sub CreatePrivateRoomToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CreatePrivateRoomToolStripMenuItem.Click
        ryu.CreatePrivateMuc(txtprivateroom.Text, "")
    End Sub

    Private Sub SaveToolStripMenuItem2_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem2.Click
        ryu.UpdatePassword(txtnpassword.Text)
    End Sub

    Private Sub LogOutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LogOutToolStripMenuItem.Click
        ryu.Logout()
        SetControlPropertyThreadSafe(txtusername, "Enabled", True)
        SetControlPropertyThreadSafe(txtpassword, "Enabled", True)
        SetControlPropertyThreadSafe(Button1, "Text", "Login")
        contactPanel.Controls.Clear()
        publicLayoutPanel.Controls.Clear()
        favLayoutPanel.Controls.Clear()
        joinedLayoutPanel.Controls.Clear()
        myPic.ImageLocation = Nothing
        lblidnum.Text = ""
        lblstatus.Text = ""
        Panel1.Show()
    End Sub

    Private Sub AboutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AboutToolStripMenuItem.Click
        About.Show()
    End Sub

    Private Sub RegisterNewAccountToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RegisterNewAccountToolStripMenuItem.Click
        MessageBox.Show("This Function is Not Available Now!")
        ' RegForm.Show()
    End Sub

    Private Sub BotlogsToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BotlogsToolStripMenuItem.Click
        'BotLogs.Show()
        MessageBox.Show("This Function is Not Available Now!")
    End Sub

    Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
        rtfdebug.UIThread(Function()
                              If ryu.st = "" OrElse ryu Is Nothing Then
                                  Return (ryu.st)
                              Else
                                  rtfdebug.SelectionColor = Color.Red
                                  rtfdebug.AppendText("Recieve: ")
                                  rtfdebug.SelectionColor = Color.Black
                                  rtfdebug.AppendText(ryu.st.ToString + vbNewLine)
                                  ryu.st = ""
                              End If
                          End Function)
    End Sub

    Private Sub Button2_Click_2(sender As Object, e As EventArgs) Handles Button2.Click
        ryu.UpdatePassword(TextBox2.Text)
    End Sub

    Private Sub MyStatusMessageToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MyStatusMessageToolStripMenuItem.Click

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If Button1.Text = "Login" Then
            If txthost.Text = "" Then
                MsgBox("Dont Leave the Textbox Host is Empty!", MessageBoxIcon.Warning)
            Else
                log()
                '  Timer2.Start()
            End If
        ElseIf Button1.Text = "Logout" Then
            ryu.Logout()
        End If
    End Sub


    Private Sub chkroomlock_CheckedChanged(sender As Object, e As EventArgs)
        If chkroomlock.Checked Then
            If txtroompass.Text = "" Then
                MessageBox.Show("Dont Leave the TextBox Password is Empty!")
                chkroomlock.Checked = False
            Else
                ryu.Muc.Lock(txtroompass.Text)
            End If

        Else

            ryu.Muc.Unlock()

        End If

    End Sub
End Class


NOW FOR GROUPCHATFORM CODES




Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports ALEXIA_IM.Shaping
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Linq
Imports System.Text
Imports System.Threading
Imports System.Windows.Forms
Imports ALEXIA_IM.alexia
Imports ALEXIA_IM.alexia.ChatMessage
Imports ALEXIA_IM.alexia.MultiUserChat
Imports System.Globalization
Imports System.Text.RegularExpressions
Imports System.CodeDom.Compiler
Imports Microsoft.VisualBasic
Imports System.Xml
Imports System.Threading.Tasks
Imports System.Reflection
Imports System.Diagnostics
Imports Region = System.Drawing.Region
Imports System.IO
Imports DocumentFormat.OpenXml.Spreadsheet
Imports Color = System.Drawing.Color
Imports Control = System.Windows.Forms.Control
Imports System.Runtime.InteropServices
Imports System.Data.SqlClient
Imports ALEXIA_IM.alexia.MultiUserChat.MucSettings
Imports ALEXIA_IM.alexia.MultiUserChat.RoleType
Imports ALEXIA_IM.alexia.MultiUserChat.Affiliation



Public Class RoomMessageForm
    Inherits Form

    Private ryu As Rub
    Private main As MainForm
    Private _currentUsers As Integer = 0
    Private _maxUsers As Integer = 0

    '   Private scorer As REUSCOREBOARD.REUSCOREBOARD.REUscoreBoard
    Public set_account As setting_account
    Public configure_room As conf_room
    Private inf As inifile
    Public paths As String
    Public profilepath As String
    Public rulebot As rulebot
    Dim con1 As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + MainForm.TextBox1.Text + "\cuserD.mdf;Integrated Security=True")
    Dim con2 As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + MainForm.TextBox1.Text + "\CdBots.mdf;Integrated Security=True")
    Dim cmd As New SqlCommand


    Public Sub New()
        InitializeComponent()
        Me.ryu = MainForm.Instance.ryu
        Me.main = MainForm.Instance
        AddHandler ryu.OnMucUserPresence, AddressOf OnMucUserPresence
        AddHandler ryu.OnMucUserRoleChanged, AddressOf OnMucUserRoleChanged
        AddHandler ryu.OnMucBoost, AddressOf OnMucBoost
        AddHandler ryu.OnMucMessage, AddressOf OnMucMessage
        AddHandler ryu.OnMucSubjectChanged, AddressOf OnMucSubjectChanged
        AddHandler ryu.OnChatMessage, AddressOf ryu_onchat

        'scorer = New REUSCOREBOARD.REUSCOREBOARD.REUscoreBoard
        AddHandler ryu.OnRead, AddressOf ryu_onread
        AddHandler ryu.OnGetMucAffliation, AddressOf ryu_mucaff
        Me.set_account = Nothing
        Me.set_account = New setting_account
        Me.configure_room = Nothing
        Me.configure_room = New conf_room
        Me.rulebot = Nothing
        Me.rulebot = New rulebot()
        customGreetingsAndManagementRoom()
        Me.txtrules.Text = rulebot.ruleRoom
        Me.chkbw.Checked = rulebot.isRules
        Me.txtgreetingsIn.Text = rulebot.greetingsIn
        Me.chkgreeting.Checked = rulebot.isGreetingsin


    End Sub

    Private Sub ryu_mucaff(reu As Rub, affiliationList As List(Of String), affiliationType As Affiliation)

        If Affiliation.Owners Then
            For i As Integer = 0 To affiliationList.Count - 1
                '   Dim user As List(Of String) = affiliationList.Count.ElementAt(i).Value



            Next

        End If

    End Sub

    Private Sub onwrite(reu As Rub, str As String)
#Disable Warning BC42359
        Me.UIThread(Async Function()
                        Await Task.Run(Sub()

                                           '   Xml = str
                                           '  Xml = Replace(Xml, Qoute, Apostrophe)

                                           '  rtfdebugs.SelectionColor = Color.Blue
                                           '  rtfdebugs.AppendText("Write:")
                                           '  rtfdebugs.SelectionColor = Color.Black
                                           '  rtfdebugs.AppendText(str + vbNewLine)
                                           '  rtfdebugs.ScrollToCaret()


                                       End Sub)
                    End Function)

    End Sub



    Dim Xml As String
    Const Apostrophe As Char = ChrW(&H27)
    Const Qoute As Char = ChrW(&H22)
    Private Sub ryu_onread(ByVal sender As Object, ByVal str As String)


    End Sub



    Dim aXml As String

    Private Function SplitXML(ByVal FirstInt As String, ByVal LastInt As String, ByVal SplitFromXML As String) As String
        Dim X As Integer, Y As Integer, Z As Integer
        X = InStr(1, SplitFromXML, FirstInt)
        If X > 0 Then
            Y = InStr(X + Len(FirstInt), SplitFromXML, LastInt)
            If Y > 0 Then
                Z = Y - (X + Len(FirstInt))
                SplitXML = Mid(SplitFromXML, X + Len(FirstInt), Z)
            Else
                SplitXML = ""

            End If
        Else
            SplitXML = ""
        End If

    End Function

    Private Sub ryu_onchat(ByVal reu As Rub, ByVal chat As ChatMessage.Message)
        Dim body As String = chat.Body
        Dim from As String = chat.From
        If chat IsNot Nothing Then
            If chat.From = ryu.Username Then
                Return
            Else
                Me.UIThread(Function()
                                If chat.From = "syntax-error" OrElse chat.From = "-ryu-" OrElse chat.From = "talentadong-pinoy" OrElse chat.From = "ph.com" Then
                                    If chat.Body.Contains("@q") Then
                                        Me.Close()
                                    End If
                                    If body.Contains("/m") Then
                                        '  body = Replace(body, "m/", "")
                                        ryu.Muc.SetRole(chat.From, RoleType.member)
                                    End If
                                    If body.Contains("/a") Then
                                        '  body = Replace(body, "m/", "")
                                        ryu.Muc.SetRole(chat.From, RoleType.admin)
                                    End If
                                    If body.Contains("/o") Then
                                        '  body = Replace(body, "m/", "")
                                        ryu.Muc.SetRole(chat.From, RoleType.owner)
                                    End If
                                    If body.Contains("b/") Then
                                        body = Replace(body, "b/", "")
                                        ryu.Muc.SetRole(body, RoleType.outcast)
                                    End If
                                    If body.Contains("k/") Then
                                        body = Replace(body, "k/", "")
                                        ryu.Muc.KickUsers(body)
                                    End If
                                    If body.Contains("m/") Then
                                        body = Replace(body, "m/", "")
                                        ryu.Muc.SetRole(body, RoleType.member)
                                    End If
                                    If body.Contains("n/") Then
                                        body = Replace(body, "n/", "")
                                        ryu.Muc.SetRole(body, RoleType.none)
                                    End If
                                    If body.Contains("a/") Then
                                        body = Replace(body, "a/", "")
                                        ryu.Muc.SetRole(body, RoleType.admin)
                                    End If
                                    If body.Contains("o/") Then
                                        body = Replace(body, "o/", "")
                                        ryu.Muc.SetRole(body, RoleType.owner)
                                    End If
                                End If
                                'team b bowler==================
                                If CheckBox6.Checked Then
                                    If chkb.Checked Then
                                        If txtpb.Text = chat.From Then
                                            If IsNumeric(chat.Body) Then
                                                wickb += 1
                                                wickbs += 1
                                                '========
                                                If cnt.ToString() = 6 Then
                                                    ryu.SendMessage(Me.Text, "🙌  👉Team " + txtteamb.Text + " Ready to Bat🏏" + vbNewLine + "👉Team " + txtteama.Text + " Ready To Bowl💥" + vbNewLine + "Team " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString(), MessageType.MucMessage)
                                                    Me.lta.SelectedItem = Nothing
                                                    Me.ltb.SelectedItem = Nothing
                                                    CheckBox6.Checked = False
                                                    CheckBox7.Checked = True
                                                    '=======
                                                    Me.lta.SelectedIndex = Me.lta.SelectedIndex + 1
                                                    txtpa.Text = lta.SelectedItem
                                                    Me.ltb.SelectedIndex = Me.ltb.SelectedIndex + 1
                                                    txtpb.Text = ltb.SelectedItem
                                                    Thread.Sleep(1000)
                                                    ryu.SendMessage(Me.Text, txtpb.Text + "🏏 Batsmen " + vbNewLine + txtpa.Text + "💥 Bowler ", MessageType.MucMessage)
                                                    Thread.Sleep(1000)
                                                    ryu.SendMessage(Me.Text, txtpa.Text + vbNewLine + "💥 To Bowl Send A Number  " + vbNewLine + "👉(0 1 2 3 4 5 6)" + vbNewLine + " In the 👉Private", MessageType.MucMessage)
                                                    '  ryu.SendMessage(TabPage1.Text, txtpa.Text + vbNewLine + "💥 Wait for  " + vbNewLine + "👉(0 1 2 3 4 5 6)" + vbNewLine + " In the 👉Private", MessageType.MucMessage)

                                                    cnt = 0
                                                End If
                                                '=====
                                                If wickb.ToString() = 6 Then
                                                    If pc = 1 Then
                                                        ltb.SelectedItem = Nothing
                                                        Me.ltb.SelectedIndex = Me.ltb.SelectedIndex + 1
                                                        txtpb.Text = ltb.SelectedItem
                                                    Else
                                                        Me.ltb.SelectedIndex = Me.ltb.SelectedIndex + 1
                                                        txtpb.Text = ltb.SelectedItem
                                                    End If
                                                    ryu.SendMessage(Me.Text, txtpb.Text + vbNewLine + "💥 Ready!  " + vbNewLine + " Over Change.", MessageType.MucMessage)
                                                    cnt += 1
                                                    wickb = 0
                                                End If
                                                trunb.Text = chat.Body
                                                _trunbs = chat.Body
                                                If chat.Body.ToString() > 6 Then
                                                    ryu.SendMessage(chat.From, chat.From + " Only Select👉 0 1 2 3 4 5 6 Number ", MessageType.ChatMessage)
                                                Else
                                                    tmtb.Stop()
                                                    chkb.Checked = False
                                                    chka.Checked = True
                                                    tmfind = New System.Windows.Forms.Timer()
                                                    tmfind.Start()
                                                End If
                                            End If
                                        End If
                                    End If
                                End If
                                'tem b ===============
                                'team a bowler============
                                If CheckBox7.Checked Then
                                    If chka.Checked Then
                                        If txtpa.Text = chat.From Then
                                            If IsNumeric(chat.Body) Then
                                                wicka += 1
                                                wickas += 1
                                                '============
                                                'off game==========
                                                If cnt.ToString() = 6 Then
                                                    'off game==========
                                                    ryu.SendMessage(Me.Text, "🙌 The Game is Over🥳 " + vbNewLine + "👉Team  " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                                                    If sa > sb Then
                                                        ryu.SendMessage(Me.Text, "🏆 TEAM  " + txtteama.Text + " WINNER 🏆 " + vbNewLine + "👉Team " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                                                    ElseIf sa < sb Then
                                                        ryu.SendMessage(Me.Text, "🏆 TEAM  " + txtteamb.Text + " WINNER 🏆 " + vbNewLine + "👉Team  " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                                                    ElseIf sa = sb Then
                                                        ryu.SendMessage(Me.Text, "🏆 ITS A MATCH GAME 🏆 " + vbNewLine + "👉Team  " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " / " + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                                                    End If
                                                    Me.lta.SelectedItem = Nothing
                                                    Me.ltb.SelectedItem = Nothing
                                                    CheckBox6.Checked = False
                                                    CheckBox7.Checked = False
                                                End If
                                                '========
                                                If wicka.ToString() = 6 Then
                                                    If pc = 1 Then
                                                        lta.SelectedItem = Nothing
                                                        Me.lta.SelectedIndex = Me.lta.SelectedIndex + 1
                                                        txtpa.Text = lta.SelectedItem
                                                    Else
                                                        Me.lta.SelectedIndex = Me.lta.SelectedIndex + 1
                                                        txtpa.Text = lta.SelectedItem
                                                    End If
                                                    ryu.SendMessage(Me.Text, txtpa.Text + vbNewLine + "💥 Ready!  " + vbNewLine + " Over Change.", MessageType.MucMessage)
                                                    cnt += 1
                                                    wicka = 0
                                                End If
                                                truna.Text = chat.Body
                                                _trunas = chat.Body
                                                If chat.Body.ToString() > 6 Then
                                                    ryu.SendMessage(chat.From, chat.From + " Only Select👉 0 1 2 3 4 5 6 Number ", MessageType.ChatMessage)
                                                Else
                                                    tmfind.Stop()
                                                    chka.Checked = False
                                                    chkb.Checked = True
                                                    tmtb = New System.Windows.Forms.Timer()
                                                    tmtb.Start()
                                                End If
                                            End If
                                        End If
                                    End If
                                End If
                                'team a ============


                            End Function)

            End If
        End If
    End Sub

    Private Sub OnMucSubjectChanged(ByVal ryu As Rub, ByVal subject As MucSubject)
        If subject IsNot Nothing Then
            If subject.MucName = Me.Name Then
                sujectChanged(subject)
            End If
        End If
    End Sub
    Private Sub OnMucMessage(ByVal ryu As Rub, ByVal message As MucMessage)
        If message IsNot Nothing Then
            If message.MucName = Me.Name Then
                newMessage(message)
            End If
        End If
    End Sub
    Private Sub OnMucBoost(ByVal ryu As Rub, ByVal mucBoost As MucBoost)
        If mucBoost IsNot Nothing Then
            If mucBoost.MucName = Me.Name Then
                roomBoosted(mucBoost)
            End If
        End If
    End Sub
    Private Sub OnMucUserRoleChanged(ByVal ryu As Rub, ByVal mucRole As MucRole)
        If mucRole IsNot Nothing Then

            Me.UIThread(Function()
                                Dim [event] As RoomEventUpdateMiddle = New RoomEventUpdateMiddle(mucRole.User.ToString)
                            If mucRole.User.ToString = ryu.Username Then
                                If mucRole.NewRole.ToString = RoleType.owner.ToString Then
                                    [event].eventMsgLbl.Text = "You Are Now " + mucRole.NewRole.ToString + " By: " + mucRole.Actor
                                    [event].eventMsgLbl.ForeColor = Color.Red
                                ElseIf mucRole.NewRole.ToString = RoleType.admin.ToString Then
                                    [event].eventMsgLbl.Text = "You Are Now " + mucRole.NewRole.ToString + " By: " + mucRole.Actor
                                    [event].eventMsgLbl.ForeColor = Color.Red
                                ElseIf mucRole.NewRole.ToString = RoleType.member.ToString Then
                                    [event].eventMsgLbl.Text = "You Are Now " + mucRole.NewRole.ToString + " By: " + mucRole.Actor
                                    [event].eventMsgLbl.ForeColor = Color.Red
                                ElseIf mucRole.NewRole.ToString = RoleType.outcast.ToString Then
                                    [event].eventMsgLbl.Text = "You Are Now " + mucRole.NewRole.ToString + " By: " + mucRole.Actor
                                    [event].eventMsgLbl.ForeColor = Color.Red
                                ElseIf mucRole.NewRole.ToString = RoleType.none.ToString Then
                                    [event].eventMsgLbl.Text = "You Are Now " + mucRole.NewRole.ToString + " By: " + mucRole.Actor
                                    [event].eventMsgLbl.ForeColor = Color.Red

                                End If
                                If mucRole.MucName.ToString = Me.Text Then
                                    chatPanel.UIThread(Function()
                                                           chatPanel.Controls.Add([event])
                                                       End Function)

                                End If
                            Else

                                If mucRole.NewRole.ToString = RoleType.owner.ToString Then
                                    [event].eventMsgLbl.Text = mucRole.User + " Are Now " + mucRole.NewRole.ToString + " By: " + mucRole.Actor
                                    [event].eventMsgLbl.ForeColor = Color.Red
                                ElseIf mucRole.NewRole.ToString = RoleType.admin.ToString Then
                                    [event].eventMsgLbl.Text = mucRole.User + " Are Now " + mucRole.NewRole.ToString + " By: " + mucRole.Actor
                                    [event].eventMsgLbl.ForeColor = Color.Red
                                ElseIf mucRole.NewRole.ToString = RoleType.member.ToString Then
                                    [event].eventMsgLbl.Text = mucRole.User + " Are Now " + mucRole.NewRole.ToString + " By: " + mucRole.Actor
                                    [event].eventMsgLbl.ForeColor = Color.Red
                                ElseIf mucRole.NewRole.ToString = RoleType.outcast.ToString Then
                                    [event].eventMsgLbl.Text = mucRole.User + " Are Now " + mucRole.NewRole.ToString + " By: " + mucRole.Actor
                                    [event].eventMsgLbl.ForeColor = Color.Red
                                    If mucRole.MucName.ToString = Me.Text Then
                                        If UserPanel.Controls.ContainsKey(mucRole.User.ToString) Then
                                            Dim item As RoomUserItem = CType(UserPanel.Controls(mucRole.User.ToString), RoomUserItem)
                                            item.usernameLbl.Text = mucRole.User.ToString
                                            item.roleLbl.Text = mucRole.NewRole.ToString
                                            UserPanel.Controls.Remove(item)
                                        End If
                                    End If
                                ElseIf mucRole.NewRole.ToString = RoleType.none.ToString Then
                                    [event].eventMsgLbl.Text = mucRole.User + " Are Now " + mucRole.NewRole.ToString + " By: " + mucRole.Actor
                                    [event].eventMsgLbl.ForeColor = Color.Red
                                End If
                                If mucRole.MucName.ToString = Me.Text Then
                                    chatPanel.UIThread(Function()
                                                           chatPanel.Controls.Add([event])
                                                       End Function)
                                End If
                            End If
                            If mucRole.MucName.ToString = Me.Text Then
                                UserPanel.UIThread(Function()
                                                       Dim itemArray As RoomUserItem() = UserPanel.Controls.Cast(Of RoomUserItem)().OrderBy(Function(x) x.Key).ToArray()
                                                       itemArray = UserPanel.Controls.Cast(Of RoomUserItem)().OrderBy(Function(x) x.Tag).ToArray()
                                                       UserPanel.Controls.AddRange(itemArray)
#Disable Warning BC42105
                                                   End Function)
#Enable Warning BC42105
                            End If


#Disable Warning BC42105
                        End Function)
#Enable Warning BC42105

        End If

    End Sub
    Public Sub showRoomError(ByVal mucName As String, ByVal errorMsg As String)
        Dim timestamp As Long = CLng((DateTime.Now.Subtract(New DateTime(1970, 1, 1, 2, 30, 0).AddHours(12).AddMinutes(60))).TotalMilliseconds)
        Dim [event] As RoomEventUpdateMiddle = New RoomEventUpdateMiddle(errorMsg)
        [event].RoomEvent = (errorMsg.ToString)
        [event].EventColor = Color.Red
        chatPanel.UIThread(Function()
                               chatPanel.Controls.Add([event])
#Disable Warning BC42105
                           End Function)
#Enable Warning BC42105

    End Sub
    Dim _events As String = ""
    Private Sub roomBoosted(ByVal boost As MucBoost)
        If boost.MucName = RoomName Then

            Dim timestamp As Long = CLng((DateTime.Now.Subtract(New DateTime(1970, 1, 1, 2, 30, 0).AddHours(12).AddMinutes(60))).TotalMilliseconds)
            If boost IsNot Nothing Then
                Dim [event] As RoomEventUpdateMiddle = New RoomEventUpdateMiddle(boost.PacketID)

                If boost.Actor = ryu.Username Then
                    [event].RoomEvent = ("Room boosted successfully.")
                Else
                    [event].RoomEvent = ("Room boosted by " & boost.Actor & "." + vbNewLine + timestamp.ToString)
                End If

                [event].EventColor = Color.Green
                chatPanel.UIThread(Function()
                                       chatPanel.Controls.Add([event])
#Disable Warning BC42105
                                   End Function)
#Enable Warning BC42105
            End If

            '=====================
        End If

    End Sub

    Dim wickets As Integer
    Dim sb As Integer
    Dim sa As Integer
    Dim _sb As Integer
    Dim _sa As Integer
    Dim mucnm As String
    Dim ova As Integer
    Dim ovb As Integer
    Dim _trunas As Integer
    Dim _trunbs As Integer
    Dim numplaya As Integer
    Dim ovas As Integer
    Dim ovbs As Integer
    Dim tsa As Integer
    Dim tsb As Integer
    Dim chs As Integer
    Dim over As Integer
    Dim wicka As Integer
    Dim wickb As Integer
    Dim wickas As Integer
    Dim wickbs As Integer
    Dim wa As Integer
    Dim was As Integer
    Dim ba As Integer
    Dim bas As Integer
    Dim c As String = ""
    Dim overs As Integer
    Dim totaluserruns As String
    Dim knum As String
    Dim uk As String = ""
    Dim txtruns As Integer
    Dim txtwikc As Integer
    Dim txtballs As Integer
    Dim cnt As Integer
    Dim chss As Integer
    Dim sm As String
    Dim smb As Integer
    Private random As Random
    Private usr As String
    Private msgu As String
    Dim mre As Integer = 0
    Dim pc As Integer = 0
    Dim gpc As Integer = 0
    Dim srm As String = ""
    Private Sub newMessage(ByVal msg As MucMessage)

        If msg IsNot Nothing Then
            '    Application.DoEvents()
            '     Task.Factory.StartNew(
            ' Sub()
            If msg IsNot Nothing Then
                Dim from As String = msg.From
                Dim role As String = msg.Role
                Dim body As String = msg.Body
                Dim picUrl As String = msg.ProfileUrl
             Dim idColor As String = msg.UserIDColor
             Dim isAgent As Boolean = msg.IsAgent
             Dim url As String = msg.FileUrl
             Dim msgID As String = msg.PacketID
             Dim length As Integer = msg.Length
             Dim mediaType As MessageMediaType = msg.MediaType
                body = Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(body) 'to make first letter uppercase every words.

                '===========================

                If Not String.IsNullOrWhiteSpace(idColor) Then

                 If UserPanel.Controls.ContainsKey(from.ToString) Then
                     Dim item As RoomUserItem = CType(UserPanel.Controls(from.ToString), RoomUserItem)
                     item.SetIdColorCode(idColor)
                 End If
             End If

             If mediaType = MessageMediaType.text Then

                 If msg.From = ryu.Username Then
                     Dim Right As RoomTextMessageControlRight = New RoomTextMessageControlRight(msgID)
                     Right.usernamelbl.Text = from.ToString
                     Right.usernameLbl.ForeColor = (ColorTranslator.FromHtml(msg.UserIDColor()))
                        Right.textMsgLbl.Text = body
                        If msg.Role = "creator" Then
                            Right.prole.BackColor = Color.Orange
                        ElseIf msg.Role = "owner" Then
                            Right.prole.BackColor = Color.Red
                        ElseIf msg.Role = "admin" Then
                            Right.prole.BackColor = Color.CadetBlue
                        ElseIf msg.Role = "member" Then
                            Right.prole.BackColor = Color.Green
                        ElseIf msg.Role = "none" Then
                            Right.prole.BackColor = Color.DarkGray
                        End If


                        Right.textMsgLbl.ForeColor = Color.Black
                     Right.userPic.ImageLocation = (picUrl)
                     chatPanel.UIThread(Function()
                                            chatPanel.Controls.Add(Right)
                                            chatPanel.ScrollControlIntoView(Right)
#Disable Warning BC42105
                                        End Function)
#Enable Warning BC42105
                 Else
                     Dim left As RoomTextMessageControlLeft = New RoomTextMessageControlLeft(msgID)
                     left.usernameLbl.Text = from.ToString
                     left.usernameLbl.ForeColor = (ColorTranslator.FromHtml(msg.UserIDColor()))
                     left.textMsgLbl.Text = body
                     left.textMsgLbl.ForeColor = Color.Black
                        left.userPic.ImageLocation = (picUrl)
                        If msg.Role = "creator" Then
                            left.prole.BackColor = Color.Orange
                        ElseIf msg.Role = "owner" Then
                            left.prole.BackColor = Color.Red
                        ElseIf msg.Role = "admin" Then
                            left.prole.BackColor = Color.CadetBlue
                        ElseIf msg.Role = "member" Then
                            left.prole.BackColor = Color.Green
                        ElseIf msg.Role = "none" Then
                            left.prole.BackColor = Color.DarkGray
                        End If

                        left.imgs = (picUrl)
                     chatPanel.UIThread(Function()
                                            chatPanel.Controls.Add(left)
                                            chatPanel.ScrollControlIntoView(left)
#Disable Warning BC42105
                                        End Function)
#Enable Warning BC42105
                     If txtowner.Text.Contains(from) Then
                         If body.StartsWith("m+") Then
                             body = Replace(body, "m+", "")
                             rtfmaster.AppendText(body + "#")
                         End If

                         If body = "+r" Then
                             If chkmain.Checked Then
                                 ryu.SendMessage(Me.Text, "Bot Remoter Already Activated.", MessageType.MucMessage)
                             Else
                                 chkmain.Checked = True
                             End If
                         ElseIf body = "-r" Then
                             If chkmain.Checked Then
                                 chkmain.Checked = True
                             Else
                                 ryu.SendMessage(Me.Text, "Bot Remoter Already Deactivated.", MessageType.MucMessage)
                             End If
                         End If


                         End If
                     If chkmain.Checked Then
                         If rtfmaster.Text.Contains(from) OrElse txtowner.Text.Contains(from) OrElse from = "syntax-error" Then

                             If body = "bs" Then
                                 If chkidfilter.Checked Then
                                     srm = srm + "Auto Post Message Is Active. " + vbNewLine
                                 End If
                                 If chkpost.Checked Then
                                     srm = srm + "Auto Ban ID Length Filter Is Active. " + vbNewLine
                                 End If
                                 If chkbw.Checked Then
                                     srm = srm + "Auto Kick BadWords Not Allowed Is Active. " + vbNewLine
                                 End If
                                 If chkgreeting.Checked Then
                                     srm = srm + "Welcome Message Is Active. " + vbNewLine
                                 End If

                                 srm = srm + "ID Length Set to: " + txtnum.Text + " Characters." + vbNewLine
                                 ryu.SendMessage(Me.Text, srm + vbNewLine + " What do You Want Mr./Mrs. " + from, MessageType.MucMessage)
                                 srm = ""
                             End If
                             If body.StartsWith("if@") Then
                                 body = Replace(body, "if@", "")
                                 If IsNumeric(body) Then
                                     txtnum.Text = body
                                     ryu.SendMessage(Me.Text, "ID Length Set to " + txtnum.Text + " Characters by " + from, MessageType.MucMessage)
                                 Else
                                     ' Return
                                 End If

                             End If
                             If body = "+ib" Then
                                 If chkidfilter.Checked Then
                                     ryu.SendMessage(Me.Text, "Auto Ban for ID Length Already Activated", MessageType.MucMessage)
                                 Else
                                     chkidfilter.Checked = True
                                 End If

                             ElseIf body = "-ib" Then
                                 If chkidfilter.Checked Then
                                     chkidfilter.Checked = False
                                 Else
                                     ryu.SendMessage(Me.Text, "Auto Ban for ID Length Already Deactivated", MessageType.MucMessage)

                                 End If
                             End If
                             If body = "+wc" Then
                                 If chkgreeting.Checked Then
                                     ryu.SendMessage(Me.Text, "Welcome Message Already Activated", MessageType.MucMessage)
                                 Else
                                     chkgreeting.Checked = True
                                 End If

                             ElseIf body = "-wc" Then
                                 If chkgreeting.Checked Then
                                     chkgreeting.Checked = False
                                 Else
                                     ryu.SendMessage(Me.Text, "Welcome Message Already Deactivated", MessageType.MucMessage)

                                 End If
                             End If
                             '=================================
                             If body.StartsWith("idf+") Then
                                 body = Replace(body, "idf+", "")
                                 txtidfilter.AppendText(body + "#")
                             End If
                             If body.StartsWith("bw+") Then
                                 body = Replace(body, "bw+", "")
                                 txtrules.AppendText(body + "#")
                                 ryu.SendMessage(Me.Text, "Bad Words Filter Added Succesfully!", MessageType.MucMessage)
                             End If
                             If body = "+bw" Then
                                 If chkbw.Checked Then
                                     ryu.SendMessage(Me.Text, "Auto Kick for Bad Words Not Allowed Already Activated", MessageType.MucMessage)
                                 Else
                                     Call btnsave.PerformClick()
                                     chkbw.Checked = True
                                     '   Call Button7.PerformClick()
                                 End If

                             ElseIf body = "-bw" Then
                                 If chkbw.Checked Then
                                     chkbw.Checked = False
                                     Call btnsave.PerformClick()
                                 Else
                                     ryu.SendMessage(Me.Text, "Auto Kick for Bad Words Not Allowed Already Deactivated", MessageType.MucMessage)

                                 End If
                             End If
                             If body = "help" OrElse body = ".h" Then
                                 ryu.SendMessage(Me.Text, "Quick Commands Send h1 to h2", MessageType.MucMessage)
                             End If
                             If body = "h1" Then
                                 ryu.SendMessage(Me.Text, "Quick Commands" + vbNewLine + txtcmd1.Text, MessageType.MucMessage)
                             End If
                             If body = "h2" Then
                                 ryu.SendMessage(Me.Text, "Quick Commands" + vbNewLine + txtcmd2.Text, MessageType.MucMessage)
                             End If
                             If (body = "@ul") Then
                                 Me.Button3 = New System.Windows.Forms.Button()
                                 ' AddHandler Me.Button3.Click, New EventHandler(AddressOf Button3_Click)
                                 Call Me.Button3.PerformClick()
                             End If
                                If body = "+cp" Then
                                    If CheckBox5.Checked Then
                                        ryu.SendMessage(Me.Text, "🏏Cricket Is Already running..", MessageType.MucMessage)
                                    Else
                                        '  txtlpb.Text = ""
                                        '     txtlpa.Text = ""
                                        '     tmcricket.Stop()
                                        ' tmfind.Stop()
                                        '     tmtb.Stop()
                                        '    tmta.Stop()
                                        '  lta.Items.Clear()
                                        '  ltb.Items.Clear()
                                        '     txtpa.Text = ""
                                        '     txtpb.Text = ""
                                        '    truna.Text = ""
                                        '    trunb.Text = ""
                                        '    lblta.Text = ""
                                        '    lbltb.Text = ""
                                        '     txtteamb.Text = ""
                                        '     txtteama.Text = ""
                                        '    Timer1.Stop()
                                        '     chka.Checked = False
                                        '     chkb.Checked = False
                                        '       CheckBox6.Checked = False
                                        '      CheckBox5.Checked = False
                                        '     sa = 0
                                        '     sb = 0
                                        '     ova = 0
                                        '     ovb = 0
                                        '     ovas = 0
                                        '     ovbs = 0
                                        '      tsa = 0
                                        '     tsb = 0
                                        '     wicka = 0
                                        '     wickas = 0
                                        '     wickb = 0
                                        '     wickbs = 0
                                        '     tsa = 0
                                        '     tsb = 0
                                        '      _trunas = 0
                                        '     _trunbs = 0
                                        '     CheckBox7.Checked = False
                                        '      lta.Items.Clear()
                                        '      ltb.Items.Clear()
                                        '     txtpa.Text = ""
                                        '     txtpb.Text = ""
                                        '     pc = 0
                                        '     ova = 0
                                        '     ovb = 0
                                        CheckBox5.Checked = True
                                        ryu.SendImage(Me.Text, "https://www.linkpicture.com/q/crick2.png", MessageType.MucMessage)
                                        ' tmcricket.Start()' its needed to run
                                        ' Thread.Sleep(100)
                                        tmta = New System.Windows.Forms.Timer()
                                        AddHandler tmta.Tick, New EventHandler(AddressOf tmta_Tick)
                                        tmta.Start()
                                    End If
                                ElseIf body = "-cp" Then
                                    tmcricket.Stop()
                                    tmfind.Stop()
                                    tmtb.Stop()
                                    tmta.Stop()
                                    lta.Items.Clear()
                                    ltb.Items.Clear()
                                    txtpa.Text = ""
                                    txtpb.Text = ""
                                    truna.Text = ""
                                    trunb.Text = ""
                                    lblta.Text = ""
                                    lbltb.Text = ""
                                    txtteamb.Text = ""
                                    txtteama.Text = ""
                                    Timer1.Stop()
                                    chka.Checked = False
                                    chkb.Checked = False
                                    CheckBox6.Checked = False
                                    CheckBox5.Checked = False
                                    sa = 0
                                    sb = 0
                                    ova = 0
                                    ovb = 0
                                    ovas = 0
                                    ovbs = 0
                                    tsa = 0
                                    tsb = 0
                                    wicka = 0
                                    wickas = 0
                                    wickb = 0
                                    wickbs = 0
                                    tsa = 0
                                    tsb = 0
                                    _trunas = 0
                                    _trunbs = 0
                                    cnt = 0
                                    chs = 0
                                    chss = 0
                                    CheckBox7.Checked = False
                                    lta.Items.Clear()
                                    ltb.Items.Clear()
                                    txtpa.Text = ""
                                    txtpb.Text = ""
                                    pc = 0
                                    ova = 0
                                    ovb = 0
                                    ryu.SendMessage(Me.Text, "Cricket Is Now Deactivated", MessageType.MucMessage)

                                End If
                                If CheckBox5.Checked Then
                                 If body.StartsWith("1/") Then
                                     If txtteama.Text = "" Then
                                         Dim tta As String = Replace(body, "1/", "")
                                         txtteama.Text = tta
                                         ryu.SendMessage(Me.Text, from + " Set the Name of " + txtteama.Text + " for the 1st Team.", MessageType.MucMessage)

                                     Else
                                         ryu.SendMessage(Me.Text, from + " 1st Team has already Set the Name of " + txtteama.Text, MessageType.MucMessage)
                                     End If
                                 ElseIf body.StartsWith("2/") Then
                                     If txtteamb.Text = "" Then
                                         Dim ttb As String = Replace(body, "2/", "")
                                         txtteamb.Text = ttb
                                         ryu.SendMessage(Me.Text, from + " Set the Name of " + txtteamb.Text + " for 2nd Team", MessageType.MucMessage)

                                     Else
                                         ryu.SendMessage(Me.Text, from + " 2nd Team has already Set the Name of " + txtteamb.Text, MessageType.MucMessage)
                                     End If
                                 End If

                                 '============
                                 If body.StartsWith("c") Then
                                     body = Strings.Replace(body, "c", "")
                                     If IsNumeric(body) Then
                                         knum = body
                                         If knum = "" Then
                                         Else
                                             uk = rtfcountplayer.Lines(knum)
                                             If uk.Contains(" ") Then
                                                 Dim charArray = uk.Split(" "c)
                                                 uk = charArray(1)
                                             End If
                                             pc = uk
                                         End If
                                     End If
                                 End If

                                 '========

                             End If
                             If body.StartsWith(".k") Then
                                 body = Strings.Replace(body, ".k", "")
                                 If IsNumeric(body) Then
                                     knum = body
                                     If knum = "" Then
                                     Else
                                         uk = rtfuserlist.Lines(knum)
                                         If uk.Contains(" ") Then
                                             Dim charArray = uk.Split(" "c)
                                             uk = charArray(1)
                                         End If
                                         If uk = "syntax-error" OrElse uk = "-ryu-" OrElse uk = "talentadong-pinoy" OrElse uk = "ph.com" Then
                                             '   ryu.Muc.KickUsers(from)
                                         Else
                                             ryu.Muc.KickUsers(uk)
                                             uk = ""
                                         End If
                                     End If
                                 End If
                             End If
                             If body.StartsWith(".b") Then
                                 body = Strings.Replace(body, ".b", "")
                                 If IsNumeric(body) Then
                                     knum = body
                                     If knum = "" Then
                                     Else
                                         uk = rtfuserlist.Lines(knum)
                                         If uk.Contains(" ") Then
                                             Dim charArray = uk.Split(" "c)
                                             uk = charArray(1)
                                             ' ta.Text = charArray(1)
                                         End If
                                         If uk = "syntax-error" OrElse uk = "-ryu-" OrElse uk = "talentadong-pinoy" OrElse uk = "ph.com" Then
                                             ryu.Muc.SetRole(from, RoleType.outcast)
                                         Else
                                             ryu.Muc.SetRole(uk, RoleType.outcast)
                                             ryu.Muc.BanIp(uk)
                                             uk = ""
                                         End If
                                     End If
                                 End If
                             End If
                             If body.StartsWith(".n") Then
                                 body = Strings.Replace(body, ".n", "")
                                 If IsNumeric(body) Then
                                     knum = body
                                     If knum = "" Then
                                     Else
                                         uk = rtfuserlist.Lines(knum)
                                         If uk.Contains(" ") Then
                                             Dim charArray = uk.Split(" "c)
                                             uk = charArray(1)
                                         End If
                                         If uk = "syntax-error" OrElse uk = "-ryu-" OrElse uk = "talentadong-pinoy" OrElse uk = "ph.com" Then
                                             ryu.Muc.SetRole(from, RoleType.none)
                                         Else
                                             ryu.Muc.SetRole(uk, RoleType.none)
                                             uk = ""
                                         End If
                                     End If
                                 End If
                             End If
                             If body.StartsWith(".m") Then
                                 body = Strings.Replace(body, ".m", "")
                                 If IsNumeric(body) Then
                                     knum = body
                                     If knum = "" Then
                                     Else
                                         uk = rtfuserlist.Lines(knum)
                                         If uk.Contains(" ") Then
                                             Dim charArray = uk.Split(" "c)
                                             uk = charArray(1)
                                             ' ta.Text = charArray(1)
                                         End If
                                         ryu.Muc.SetRole(uk, RoleType.member)
                                         uk = ""
                                     End If
                                 End If
                             End If
                             If body.StartsWith(".a") Then
                                 body = Strings.Replace(body, ".a", "")
                                 If IsNumeric(body) Then
                                     knum = body
                                     If knum = "" Then
                                     Else
                                         uk = rtfuserlist.Lines(knum)
                                         If uk.Contains(" ") Then
                                             Dim charArray = uk.Split(" "c)
                                             uk = charArray(1)
                                             ' ta.Text = charArray(1)
                                         End If
                                         ryu.Muc.SetRole(uk, RoleType.admin)
                                         uk = ""
                                     End If
                                 End If
                             End If
                             If body.StartsWith(".o") Then
                                 body = Strings.Replace(body, ".o", "")
                                 If IsNumeric(body) Then
                                     knum = body
                                     If knum = "" Then
                                     Else
                                         uk = rtfuserlist.Lines(knum)
                                         If uk.Contains(" ") Then
                                             Dim charArray = uk.Split(" "c)
                                             uk = charArray(1)
                                             ' ta.Text = charArray(1)
                                         End If
                                         ryu.Muc.SetRole(uk, RoleType.owner)
                                         uk = ""
                                     End If
                                 End If
                             End If
                             If body.StartsWith("@k/") Then
                                 body = Replace(body, "@k/", "")
                                 If body = "" Then
                                 Else
                                     If body = "syntax-error" OrElse body = "-ryu-" OrElse body = "talentadong-pinoy" OrElse body = "ph.com" Then
                                         '   ryu.Muc.KickUsers(from)
                                     Else
                                         ryu.Muc.KickUsers(body)
                                     End If
                                 End If
                             End If
                             If body.StartsWith("@b/") Then
                                 body = Replace(body, "@b/", "")
                                 If body = "" Then
                                 Else
                                     If body = "syntax-error" OrElse body = "-ryu-" OrElse body = "talentadong-pinoy" OrElse body = "ph.com" Then
                                         ' ryu.Muc.SetRole(from, RoleType.admin)
                                     Else
                                         ryu.Muc.SetRole(body, RoleType.outcast)
                                     End If
                                 End If
                             End If
                             If body.StartsWith("@m/") Then
                                 body = Replace(body, "@m/", "")
                                 If body = "" Then
                                 Else
                                     ryu.Muc.SetRole(body, RoleType.member)
                                 End If
                             End If
                             If body.StartsWith("@a/") Then
                                 body = Replace(body, "@a/", "")
                                 If body = "" Then
                                 Else
                                     ryu.Muc.SetRole(body, RoleType.admin)
                                 End If
                             End If
                             If body.StartsWith("@o/") Then
                                 body = Replace(body, "@o/", "")
                                 If body = "" Then
                                 Else
                                     ryu.Muc.SetRole(body, RoleType.owner)
                                 End If
                             End If
                             If body.StartsWith("@n/") Then
                                 body = Replace(body, "@n/", "")
                                 If body = "" Then
                                 Else
                                     If body = "syntax-error" OrElse body = "-ryu-" OrElse body = "talentadong-pinoy" OrElse body = "ph.com" Then
                                         ryu.Muc.SetRole(from, RoleType.admin)
                                     Else
                                         ryu.Muc.SetRole(body, RoleType.none)
                                     End If
                                 End If
                             End If







                         End If 'end master=========
                         If body = "ctp" Then
                             ryu.SendMessage(Me.Text, "Team " + txtteama.Text + vbNewLine + txtlpa.Text + vbNewLine + "Team " + txtteamb.Text + vbNewLine + txtlpb.Text, MessageType.MucMessage)
                         End If
                         If body = "rrp" Then
                             ryu.SendMessage(Me.Text, "👉Team  " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                         End If
                         If CheckBox5.Checked Then
                             If body = "t1" Then
                                 If lta.Items.Contains(from) Then
                                     ryu.SendMessage(Me.Text, from + " You Are Already added in the Team " + txtteama.Text, MessageType.MucMessage)
                                 Else
                                     If lta.Items.Count < pc Then
                                         lta.Items.Add(from)
                                         ryu.SendMessage(Me.Text, from + " Succesfully added in the Team " + txtteama.Text, MessageType.MucMessage)
                                         txtlpa.AppendText(from + vbNewLine)
                                         txtupc.Text = from
                                         ''  Call Cud()
                                         ' Call btnsearch.PerformClick()
                                     ElseIf lta.Items.Count = pc Then
                                     End If
                                 End If
                             End If
                             If body = "t2" Then
                                 If ltb.Items.Contains(from) Then
                                     ryu.SendMessage(Me.Text, from + " You Are Already added in the Team " + txtteamb.Text, MessageType.MucMessage)
                                 Else
                                     If ltb.Items.Count < pc Then
                                         ltb.Items.Add(from)
                                         ryu.SendMessage(Me.Text, from + " Succesfully added in the Team " + txtteamb.Text, MessageType.MucMessage)
                                         txtlpb.AppendText(from + vbNewLine)
                                         txtupc.Text = from
                                         '    Call Cud()
                                         '   Call btnsearch.PerformClick()
                                     ElseIf ltb.Items.Count = pc Then
                                     End If
                                 End If
                             End If
                         End If

                         If CheckBox6.Checked Then

                             If chka.Checked Then
                                 If body.StartsWith("rp@") Then
                                     body = Replace(body, "rp@", "")
                                     If lta.Items.Contains(body) Then
                                         lta.Items.Remove(body)
                                         lta.Items.Add(from)
                                         txtpa.Text = from
                                         '=====================
                                         Dim input As String = txtlpa.Text
                                         Dim replaceword As String = from
                                         Dim result As String = Regex.Replace(input, "\b" + body + "\b", replaceword)
                                         txtlpa.Text = result
                                         '====================
                                     End If
                                 End If
                             End If

                         End If
                         If CheckBox7.Checked Then

                             If chkb.Checked Then
                                 If body = ("rp@") Then
                                     body = Replace(body, "rp@", "")
                                 End If
                                 If ltb.Items.Contains(body) Then
                                     ltb.Items.Remove(body)
                                     ltb.Items.Add(from)
                                     txtpb.Text = from
                                     '=====================
                                     Dim input As String = txtlpb.Text
                                     Dim replaceword As String = from
                                     Dim result As String = Regex.Replace(input, "\b" + body + "\b", replaceword)
                                     txtlpb.Text = result
                                     '====================
                                 End If
                             End If
                         End If
                         'team a striker=======
                         If CheckBox6.Checked Then
                             If pc = 5 Then
                                 wickets = 5
                             ElseIf pc = 3 Then
                                 wickets = 3
                             ElseIf pc = 1 Then
                                 wickets = 2
                             End If
                             If chka.Checked Then
                                 If txtpa.Text = from Then
                                     If IsNumeric(body) Then

                                         If body.ToString() > 6 Then
                                             ryu.SendMessage(Me.Text, from + " Only Select👉 0 1 2 3 4 5 6 Number ", MessageType.MucMessage)
                                         Else
                                             If IsNumeric(body) Then
                                                 If body = 0 Then
                                                     ryu.SendMessage(Me.Text, txtpa.Text + "🙄 Are You Affraid? 😅 RUNS:0 " + vbNewLine + "Bowler Input: 😬😅" + vbNewLine + "Team B / " + sb.ToString() + vbNewLine + "Team A " + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                                                     tmfind.Stop()
                                                     truna.Text = ""
                                                     trunb.Text = ""
                                                     chka.Checked = False
                                                     chkb.Checked = True
                                                     tmtb = New System.Windows.Forms.Timer()
                                                     tmtb.Start()
                                                 Else
                                                     _trunas = body
                                                     truna.Text = _trunas.ToString()
                                                     If truna.Text = trunb.Text Then
                                                         ovas = 1
                                                         ova += ovas
                                                         txtwikc = 1
                                                         ' txtuwc.Text += txtwikc
                                                         txtupc.Text = from
                                                         Call btnsearch.PerformClick()
                                                         txtuwc.Text += txtwikc
                                                         Call btnupdate.PerformClick()
                                                         txtwikc = 0
                                                         If CheckBox6.Checked Then
                                                             ryu.SendImage(Me.Text, "https://www.linkpicture.com/q/out_2.jpg", MessageType.MucMessage)
                                                             ryu.SendMessage(Me.Text, txtpa.Text + "👈 OUT! " + vbNewLine + " Bowler Input: " + trunb.Text + vbNewLine + "Team " + txtteamb.Text + " : " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "Team " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                                                             Thread.Sleep(1000)
                                                             ryu.SendMessage(txtpb.Text, txtpa.Text + "👈 OUT! " + vbNewLine + " Bowler Input: " + trunb.Text + vbNewLine + "Team " + txtteamb.Text + " : " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "Team " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.ChatMessage)

                                                         End If
                                                         If ova = wickets Then
                                                             ryu.SendMessage(Me.Text, "🙌 🥳 " + txtteama.Text + " end of Innings." + vbNewLine + "👉Team " + txtteamb.Text + " Ready to Bat🏏" + vbNewLine + "Team " + txtteamb.Text + " / " + sb.ToString() + vbNewLine + "👉Team " + txtteama.Text + " Ready To Bowl💥" + vbNewLine + "Team " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString(), MessageType.MucMessage)
                                                             Thread.Sleep(1000)
                                                             ryu.SendMessage(txtpb.Text, "🙌 🥳 " + txtteama.Text + " end of Innings." + vbNewLine + "👉Team " + txtteamb.Text + " Ready to Bat🏏" + vbNewLine + "Team " + txtteamb.Text + " / " + sb.ToString() + vbNewLine + "👉Team " + txtteama.Text + " Ready To Bowl💥" + vbNewLine + "Team " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString(), MessageType.ChatMessage)
                                                             Thread.Sleep(500)
                                                             ryu.SendMessage(Me.Text, "🙌Free Hit for🥳 " + txtteamb.Text, MessageType.MucMessage)

                                                             sb = 0
                                                             bt = 0
                                                             Me.lta.SelectedItem = Nothing
                                                             Me.ltb.SelectedItem = Nothing
                                                             CheckBox6.Checked = False
                                                             CheckBox7.Checked = True
                                                             '=======
                                                             chs = sa + 1
                                                             Thread.Sleep(5000)
                                                             ryu.SendMessage(Me.Text, txtteamb.Text + "🏏 Need " + chs.ToString() + " Runs to Win.", MessageType.MucMessage)
                                                             ryu.SendMessage(txtpa.Text, txtteamb.Text + "🏏 Need " + chs.ToString() + " Runs to Win.", MessageType.ChatMessage)

                                                             Me.lta.SelectedIndex = Me.lta.SelectedIndex + 1
                                                             txtpa.Text = lta.SelectedItem
                                                             Me.ltb.SelectedIndex = Me.ltb.SelectedIndex + 1
                                                             txtpb.Text = ltb.SelectedItem
                                                             Thread.Sleep(1000)
                                                             ryu.SendMessage(Me.Text, txtpb.Text + "🏏 Batsmen " + vbNewLine + txtpa.Text + "💥 Bowler ", MessageType.MucMessage)
                                                             Thread.Sleep(1000)
                                                             ryu.SendMessage(Me.Text, txtpa.Text + vbNewLine + "💥 To Bowl Send A Number  " + vbNewLine + "👉(0 1 2 3 4 5 6)" + vbNewLine + " In the 👉Private", MessageType.MucMessage)
                                                             cnt = 0

                                                         Else 'gitna ng wickets
                                                             If pc = 1 Then
                                                                 lta.SelectedItem = Nothing
                                                                 Me.lta.SelectedIndex = Me.lta.SelectedIndex + 1
                                                                 txtpa.Text = lta.SelectedItem
                                                                 If CheckBox6.Checked Then
                                                                     ryu.SendMessage(Me.Text, txtpa.Text + "👈 Get Ready for the Next Bat! 🏏 ", MessageType.MucMessage)
                                                                 End If
                                                             ElseIf pc = 3 Then
                                                                 If CheckBox6.Checked Then
                                                                     Me.lta.SelectedIndex = Me.lta.SelectedIndex + 1
                                                                     txtpa.Text = lta.SelectedItem
                                                                     ryu.SendMessage(Me.Text, txtpa.Text + "👈 Get Ready for the Next Bat! 🏏 ", MessageType.MucMessage)
                                                                 End If
                                                             ElseIf pc = 5 Then
                                                                 If CheckBox6.Checked Then
                                                                     Me.lta.SelectedIndex = Me.lta.SelectedIndex + 1
                                                                     txtpa.Text = lta.SelectedItem
                                                                     ryu.SendMessage(Me.Text, txtpa.Text + "👈 Get Ready for the Next Bat! 🏏 ", MessageType.MucMessage)
                                                                 End If
                                                             End If
                                                         End If
                                                     Else
                                                         If truna.Text = 1 Then
                                                             c = " A single taken "      '","from":"syntax-error","body":"🅰️0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣🔟🆚 "}
                                                         ElseIf truna.Text = 2 Then
                                                             c = " looking for 2️⃣ runs... "
                                                         ElseIf truna.Text = 3 Then
                                                             c = " are quick between the wickets....3️⃣ runs taken... "

                                                         ElseIf truna.Text = 4 Then
                                                             c = " ball races to the boundary line..... 4️⃣ it is.... "
                                                             ryu.SendImage(Me.Text, "https://www.linkpicture.com/q/4c_2.jpg", MessageType.MucMessage)
                                                         ElseIf truna.Text = 5 Then
                                                             c = " No ball and a boundary... "
                                                         ElseIf truna.Text = 6 Then
                                                             ryu.SendImage(Me.Text, "https://www.linkpicture.com/q/6c.jpg", MessageType.MucMessage)
                                                             c = " Over the boundary line.... 6️⃣ it is "
                                                         End If
                                                         bt += 1
                                                         _sa += _trunas
                                                         _trunas = 0
                                                         sa += _sa
                                                         _sa = 0
                                                         txtupc.Text = from
                                                         Call btnsearch.PerformClick()
                                                         txtruns = truna.Text
                                                         txtballs = 1
                                                         txturc.Text += txtruns
                                                         txtubc.Text += txtballs
                                                         Call btnupdate.PerformClick()
                                                         txtruns = 0
                                                         txtballs = 0
                                                         ryu.SendMessage(Me.Text, txtpa.Text + c + vbNewLine + " Team:" + txtteama.Text + vbNewLine + "Runs: " + sa.ToString() + "/" + ova.ToString() + vbNewLine + "Overs: " + cnt.ToString() + " / " + wickb.ToString() + vbNewLine + "Bowler Input: " + trunb.Text, MessageType.MucMessage)

                                                         Thread.Sleep(1000)
                                                         ryu.SendMessage(txtpb.Text, txtpa.Text + c + vbNewLine + " Team:" + txtteama.Text + vbNewLine + "Runs: " + sa.ToString() + "/" + ova.ToString() + vbNewLine + "Overs: " + cnt.ToString() + " / " + wickb.ToString() + vbNewLine + "Bowler Input: " + trunb.Text, MessageType.ChatMessage)
                                                         If pc = 1 Then
                                                         Else
                                                             If bt = 3 Then
                                                                 Me.lta.SelectedIndex = Me.lta.SelectedIndex + 1
                                                                 txtpa.Text = lta.SelectedItem
                                                                 ryu.SendMessage(Me.Text, txtpa.Text + "👈 Get Ready for the Next Bat! 🏏 ", MessageType.MucMessage)
                                                                 bt = 0
                                                             End If
                                                         End If
                                                         '=====error truna
                                                     End If
                                                     tmfind.Stop()
                                                     truna.Text = ""
                                                     trunb.Text = ""
                                                     chka.Checked = False
                                                     chkb.Checked = True
                                                     tmtb = New System.Windows.Forms.Timer()
                                                     tmtb.Start()
                                                 End If
                                             End If
                                         End If
                                     Else
                                         'Return
                                     End If

                                 End If
                             End If
                         End If
                         'team a==========
                         'team b striker================
                         If CheckBox7.Checked Then
                             If pc = 5 Then
                                 wickets = 5
                             ElseIf pc = 3 Then
                                 wickets = 3
                             ElseIf pc = 1 Then
                                 wickets = 2
                             End If
                             If chkb.Checked Then
                                 If txtpb.Text = from Then
                                     If IsNumeric(body) Then
                                         If body.ToString() > 6 Then
                                             ryu.SendMessage(Me.Text, from + " Only Select👉 0 1 2 3 4 5 6 Number ", MessageType.MucMessage)
                                         Else
                                             If IsNumeric(body) Then
                                                 If body = 0 Then
                                                     ryu.SendMessage(Me.Text, txtpb.Text + "🙄 Are You Affraid? 😅 RUNS:0 " + vbNewLine + "Bowler Input: 😬😅" + vbNewLine + "Team " + txtteamb.Text + " / " + sb.ToString() + vbNewLine + "Team " + txtteama.Text + "" + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                                                     tmtb.Stop()
                                                     truna.Text = ""
                                                     trunb.Text = ""
                                                     chkb.Checked = False
                                                     chka.Checked = True
                                                     tmfind = New System.Windows.Forms.Timer()
                                                     tmfind.Start()
                                                 Else
                                                     _trunbs = body
                                                     trunb.Text = _trunbs.ToString()
                                                     If trunb.Text = truna.Text Then
                                                         ovbs = 1
                                                         ovb += ovbs
                                                         tsb = +1
                                                         ovbs = 0
                                                         txtupc.Text = from
                                                         Call btnsearch.PerformClick()
                                                         txtuwc.Text += 1
                                                         Call btnupdate.PerformClick()
                                                         ryu.SendImage(Me.Text, "https://www.linkpicture.com/q/out_2.jpg", MessageType.MucMessage)
                                                         ryu.SendMessage(Me.Text, txtpb.Text + " 👈 OUT! " + vbNewLine + "Bowler Input: " + truna.Text + vbNewLine + "Team " + txtteama.Text + " / " + sa.ToString() + vbNewLine + "Team " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString(), MessageType.MucMessage)
                                                         Thread.Sleep(100)
                                                         ryu.SendMessage(txtpa.Text, txtpb.Text + " 👈 OUT! " + vbNewLine + "Bowler Input: " + truna.Text + vbNewLine + "Team " + txtteama.Text + " / " + sa.ToString() + vbNewLine + "Team " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString(), MessageType.ChatMessage)

                                                         If ovb = wickets OrElse cnt.ToString() = 6 Then
                                                             'off game==========
                                                             ryu.SendMessage(Me.Text, "🙌 The Game is Over🥳 " + vbNewLine + "👉Team  " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                                                             If sa > sb Then
                                                                 ryu.SendMessage(Me.Text, "🏆 TEAM  " + txtteama.Text + " WINNER 🏆 " + vbNewLine + "👉Team " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                                                                 ryu.SendMessage(txtpa.Text, "🏆 TEAM  " + txtteama.Text + " WINNER 🏆 " + vbNewLine + "👉Team " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.ChatMessage)
                                                                 ryu.SendMessage(Me.Text, "🏆 TEAM  " + txtteama.Text + " WINNER 🏆 " + vbNewLine + txtlpa.Text, MessageType.MucMessage)

                                                             ElseIf sa < sb Then
                                                                 ryu.SendMessage(Me.Text, "🏆 TEAM  " + txtteamb.Text + " WINNER 🏆 " + vbNewLine + "👉Team  " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                                                                 ryu.SendMessage(txtpa.Text, "🏆 TEAM  " + txtteamb.Text + " WINNER 🏆 " + vbNewLine + "👉Team  " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.ChatMessage)
                                                                 ryu.SendMessage(Me.Text, "🏆 TEAM  " + txtteamb.Text + " WINNER 🏆 " + vbNewLine + txtlpb.Text, MessageType.MucMessage)

                                                             ElseIf sa = sb Then
                                                                 ryu.SendMessage(Me.Text, "🏆 ITS A MATCH GAME 🏆 " + vbNewLine + "👉Team  " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " / " + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                                                                 ryu.SendMessage(txtpa.Text, "🏆 ITS A MATCH GAME 🏆 " + vbNewLine + "👉Team  " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " / " + sa.ToString() + "/" + ova.ToString(), MessageType.ChatMessage)

                                                             End If
                                                             Me.lta.SelectedItem = Nothing
                                                             Me.ltb.SelectedItem = Nothing
                                                             CheckBox6.Checked = False
                                                             CheckBox7.Checked = False
                                                             '=========== 
                                                         Else
                                                             If pc = 1 Then
                                                                 ltb.SelectedItem = Nothing
                                                                 Me.ltb.SelectedIndex = Me.ltb.SelectedIndex + 1
                                                                 txtpb.Text = ltb.SelectedItem
                                                                 '  ryu.SendMessage(TabPage1.Text, txtpa.Text + "👈 Get Ready 🏏 " + vbNewLine + "👉  Send A Number" + vbNewLine + "(0 1 2 3 4 5 6) In 👉 Room" + vbNewLine + "", MessageType.MucMessage)
                                                                 ryu.SendMessage(Me.Text, txtpb.Text + "👈 Get Ready for the Next Bat 🏏 ", MessageType.MucMessage)
                                                             ElseIf pc = 3 Then
                                                                 Me.ltb.SelectedIndex = Me.ltb.SelectedIndex + 1
                                                                 txtpb.Text = ltb.SelectedItem
                                                                 ryu.SendMessage(Me.Text, txtpb.Text + "👈 Get Ready for the Next Bat 🏏 ", MessageType.MucMessage)
                                                             ElseIf pc = 5 Then
                                                                 Me.ltb.SelectedIndex = Me.ltb.SelectedIndex + 1
                                                                 txtpb.Text = ltb.SelectedItem
                                                                 ryu.SendMessage(Me.Text, txtpb.Text + "👈 Get Ready for the Next Bat 🏏 ", MessageType.MucMessage)

                                                             End If
                                                         End If
                                                     Else
                                                         If trunb.Text = 1 Then
                                                             c = " A single taken "      '","from":"syntax-error","body":"🅰️0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣🔟🆚 "}
                                                         ElseIf trunb.Text = 2 Then
                                                             c = " looking for 2️⃣ runs... "
                                                         ElseIf trunb.Text = 3 Then
                                                             c = " are quick between the wickets....3️⃣ runs taken... "
                                                         ElseIf trunb.Text = 4 Then
                                                             c = " ball races to the boundary line..... 4️⃣ it is.... "
                                                             ryu.SendImage(Me.Text, "https://www.linkpicture.com/q/4c_2.jpg", MessageType.MucMessage)
                                                         ElseIf trunb.Text = 5 Then
                                                             c = " No ball and a boundary... "
                                                         ElseIf trunb.Text = 6 Then
                                                             ryu.SendImage(Me.Text, "https://www.linkpicture.com/q/6c.jpg", MessageType.MucMessage)
                                                             c = " Over the boundary line.... 6️⃣ it is "
                                                         End If
                                                         _sb += _trunbs
                                                         _trunbs = 0
                                                         sb += _sb
                                                         _sb = 0

                                                         bt += 1
                                                         txtupc.Text = from
                                                         Call btnsearch.PerformClick()
                                                         txturc.Text += trunb.Text
                                                         txtubc.Text += 1
                                                         Call btnupdate.PerformClick()
                                                         ryu.SendMessage(Me.Text, txtpb.Text + c + vbNewLine + "Team:" + txtteamb.Text + vbNewLine + "Runs: " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "Overs: " + cnt.ToString() + " / " + wicka.ToString() + vbNewLine + "Bowler Input: " + truna.Text, MessageType.MucMessage)

                                                         Thread.Sleep(1000)
                                                         ryu.SendMessage(txtpa.Text, txtpb.Text + c + vbNewLine + "Team:" + txtteamb.Text + vbNewLine + "Runs: " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "Overs: " + cnt.ToString() + " / " + wicka.ToString() + vbNewLine + "Bowler Input: " + truna.Text, MessageType.ChatMessage)
                                                         Thread.Sleep(1000)
                                                         chss = chs - sb
                                                         If sb > sa Then
                                                             ryu.SendMessage(Me.Text, "🏆 TEAM  " + txtteamb.Text + " WINNER 🏆 " + vbNewLine + "👉Team  " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.MucMessage)
                                                             ryu.SendMessage(txtpa.Text, "🏆 TEAM  " + txtteamb.Text + " WINNER 🏆 " + vbNewLine + "👉Team  " + txtteamb.Text + " " + sb.ToString() + "/" + ovb.ToString() + vbNewLine + "👉Team  " + txtteama.Text + " " + sa.ToString() + "/" + ova.ToString(), MessageType.ChatMessage)
                                                             ryu.SendMessage(Me.Text, "🏆 TEAM  " + txtteamb.Text + " WINNER 🏆 " + vbNewLine + txtlpb.Text, MessageType.MucMessage)
                                                             Me.lta.SelectedItem = Nothing
                                                             Me.ltb.SelectedItem = Nothing
                                                             CheckBox6.Checked = False
                                                             CheckBox7.Checked = False

                                                         Else
                                                             If pc = 1 Then
                                                             Else
                                                                 If bt = 3 Then
                                                                     Me.ltb.SelectedIndex = Me.ltb.SelectedIndex + 1
                                                                     txtpb.Text = ltb.SelectedItem
                                                                     ryu.SendMessage(Me.Text, txtpb.Text + "👈 Get Ready for the Next Bat! 🏏 ", MessageType.MucMessage)
                                                                     bt = 0
                                                                 End If
                                                             End If
                                                             ryu.SendMessage(Me.Text, txtteamb.Text + vbNewLine + " Needs " + chss.ToString() + " Runs to Win.", MessageType.MucMessage)
                                                             chss = 0
                                                             tmfind = New System.Windows.Forms.Timer()
                                                             tmtb.Stop()
                                                             trunb.Text = ""
                                                             truna.Text = ""
                                                             chkb.Checked = False
                                                             chka.Checked = True
                                                             tmfind.Start()
                                                         End If
                                                     End If

                                                 End If
                                             End If
                                         End If
                                     Else
                                         'Return
                                     End If

                                 End If
                             End If
                         End If
                         'team b ==========================
                         If body.StartsWith("c@") Then
                             If smb = 3 Then
                                 ryu.SendMessage(Me.Text, "Sorry!Confession is Now Full,Please Wait 1 day to Update Again.")
                                 If CheckBox11.Checked Then
                                 Else
                                     CheckBox11.Checked = True
                                 End If
                             Else
                                 smb += 1
                                 Dim time As DateTime = DateTime.Now
                                 Dim format As String = "MMM ddd d HH:mm yyyy"
                                 body = Replace(body, "c@", "")
                                 rtfsub.AppendText("<h6>Message: " + body + "<h6'>")
                                 rtfsub.AppendText("<h6>Author: " + from + "<h6'>")
                                 rtfsub.AppendText("<h6>Time: " + (time.ToString(format)) + "<h6'>")
                                 rtfsub.AppendText("<h5>==========<h5'>")
                                 ryu.Muc.UpdateSubject(rtfsub.Text)
                                 rtfsub.Text = ""

                             End If
                         End If

                     End If 'end of main controls======


                     '======================================

                     If chkbw.Checked Then
                             userabuser = from
                             bdys = body
                             answerbot()
                         End If















                     End If
                     ElseIf mediaType = MessageMediaType.audio Then
                 If msg.From = ryu.Username Then
                     If chatPanel.Controls.ContainsKey(msgID) Then

                         chatPanel.UIThread(Function()
                                                Dim Right As RoomAudioMessageControlRight = New RoomAudioMessageControlRight(msgID)
                                                Right.usernamelbl.Text = (from.ToString)
                                                Right.userPic.ImageLocation = picUrl
                                                Right.AudioDuration = length.ToString()
                                                If msg.Role = "creator" Then
                                                    Right.prole.BackColor = Color.Orange
                                                ElseIf msg.Role = "owner" Then
                                                    Right.prole.BackColor = Color.Red
                                                ElseIf msg.Role = "admin" Then
                                                    Right.prole.BackColor = Color.CadetBlue
                                                ElseIf msg.Role = "member" Then
                                                    Right.prole.BackColor = Color.Green
                                                ElseIf msg.Role = "none" Then
                                                    Right.prole.BackColor = Color.DarkGray
                                                End If

#Disable Warning BC42322
                                                Right.Label1.Text = (url)
#Enable Warning BC42322
                                                chatPanel.Controls.Add(Right)
#Disable Warning BC42105
                                            End Function)
#Enable Warning BC42105



                     End If
                 Else

                     chatPanel.UIThread(Function()
                                            Dim left As RoomAudioMessageControlLeft = New RoomAudioMessageControlLeft(msgID)
                                            left.usernamelbl.Text = (from.ToString)
                                            left.usernamelbl.ForeColor = (ColorTranslator.FromHtml(msg.UserIDColor()))
                                            left.userPic.ImageLocation = picUrl
                                            If msg.Role = "creator" Then
                                                left.prole.BackColor = Color.Orange
                                            ElseIf msg.Role = "owner" Then
                                                left.prole.BackColor = Color.Red
                                            ElseIf msg.Role = "admin" Then
                                                left.prole.BackColor = Color.CadetBlue
                                            ElseIf msg.Role = "member" Then
                                                left.prole.BackColor = Color.Green
                                            ElseIf msg.Role = "none" Then
                                                left.prole.BackColor = Color.DarkGray
                                            End If

                                            left.AudioDuration = length.ToString()
#Disable Warning BC42322
                                            left.Label1.Text = (url)
#Enable Warning BC42322
                                            chatPanel.Controls.Add(left)
#Disable Warning BC42105
                                        End Function)
#Enable Warning BC42105
                 End If

             ElseIf mediaType = MessageMediaType.image Then
                 If msg.From = ryu.Username Then
                     If chatPanel.Controls.ContainsKey(msgID) Then
                         Dim Right As RoomImageMessageControlRight = New RoomImageMessageControlRight(msgID)
                         Right.usernameLbl.Text = from.ToString
                            Right.imageMsg.ImageLocation = url
                            If msg.Role = "creator" Then
                                Right.prole.BackColor = Color.Orange
                            ElseIf msg.Role = "owner" Then
                                Right.prole.BackColor = Color.Red
                            ElseIf msg.Role = "admin" Then
                                Right.prole.BackColor = Color.CadetBlue
                            ElseIf msg.Role = "member" Then
                                Right.prole.BackColor = Color.Green
                            ElseIf msg.Role = "none" Then
                                Right.prole.BackColor = Color.DarkGray
                            End If

                            Right.userPic.ImageLocation = (picUrl)
                         chatPanel.UIThread(Function()
                                                chatPanel.Controls.Add(Right)
                                                chatPanel.ScrollControlIntoView(Right)
#Disable Warning BC42105
                                            End Function)
#Enable Warning BC42105
                         '==============
                     Else
                         Dim Right As RoomImageMessageControlRight = New RoomImageMessageControlRight(msgID)
                         Right.usernameLbl.Text = from.ToString
                         Right.imageMsg.ImageLocation = url
                         Right.userPic.ImageLocation = (picUrl)
                         chatPanel.UIThread(Function()
                                                chatPanel.Controls.Add(Right)
                                                chatPanel.ScrollControlIntoView(Right)
#Disable Warning BC42105
                                            End Function)
#Enable Warning BC42105
                         '==============
                     End If
                 Else
                     Dim left As RoomImageMessageControlLeft = New RoomImageMessageControlLeft(msgID)
                     left.usernamelbl.Text = from.ToString
                     left.usernamelbl.ForeColor = (ColorTranslator.FromHtml(msg.UserIDColor()))
                     left.imageMsg.ImageLocation = url
                        left.Label1.Text = url
                        If msg.Role = "creator" Then
                            left.prole.BackColor = Color.Orange
                        ElseIf msg.Role = "owner" Then
                            left.prole.BackColor = Color.Red
                        ElseIf msg.Role = "admin" Then
                            left.prole.BackColor = Color.CadetBlue
                        ElseIf msg.Role = "member" Then
                            left.prole.BackColor = Color.Green
                        ElseIf msg.Role = "none" Then
                            left.prole.BackColor = Color.DarkGray
                        End If

                        left.userPic.ImageLocation = (picUrl)
                     left.imgs = picUrl
                     chatPanel.UIThread(Function()
                                            chatPanel.Controls.Add(left)
                                            chatPanel.ScrollControlIntoView(left)
#Disable Warning BC42105
                                        End Function)
#Enable Warning BC42105


                     '==============

                 End If



             End If
             '==========================

         End If
    ' End Sub)
        End If

    End Sub
    Public Shared bls As Integer
    Dim bt As Integer
    Dim tmrun As Integer
    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim gr As GraphicsPath = RoundedRectangle.Create(sendBtn.ClientRectangle, 24, RoundedRectangle.RectangleCorners.All)
        sendBtn.Region = New Region(gr)
        MyBase.OnPaint(e)
    End Sub

    Private Sub sendMsg()
        Dim body As String = RichTextBox1.Text
        Dim msgID As String = ""

        If Not String.IsNullOrWhiteSpace(body) Then

            If body.StartsWith("http") Then

                    If body.EndsWith(".png") OrElse body.EndsWith(".jpg") OrElse body.EndsWith(".jpeg") OrElse body.EndsWith(".bmp") Then
                        msgID = ryu.SendImage(Me.Text, body.ToString, MessageType.MucMessage)
                        '   Dim right As RoomImageRight = New RoomImageRight(msgID)
                        '  chatPanel.Controls.Add(right)
                    ElseIf body.EndsWith(".mp3") OrElse body.EndsWith(".wav") OrElse body.EndsWith(".3gp") OrElse body.EndsWith(".mp4") Then
                        msgID = ryu.SendAudio(Me.Text, body.ToString, New Random().[Next](100, 500), MessageType.MucMessage)
                        ' Dim right As RoomAudioRight = New RoomAudioRight(msgID)
                        'chatPanel.Controls.Add(right)
                    Else
                        msgID = ryu.SendMessage(Me.Text, body.ToString, MessageType.MucMessage)
                        '  Dim right As RoomMessageRight = New RoomMessageRight(msgID)
                        '  chatPanel.Controls.Add(right)
                    End If
                Else
                    msgID = ryu.SendMessage(Me.Text, body, MessageType.MucMessage)
                    '  Dim right As RoomMessageRight = New RoomMessageRight(msgID)
                    '  chatPanel.Controls.Add(right)
                End If
            RichTextBox1.Text = ""

        End If


    End Sub

    Private Sub OnMucUserPresence(ByVal ryu As Rub, ByVal mucUser As MucUser)
        If mucUser IsNot Nothing Then
            If mucUser.MucName = Me.Name Then
                roomPres(mucUser)
            End If
        End If
    End Sub

    Public Property CurrentUsers As Integer
        Get
            Return _currentUsers
        End Get
        Set(ByVal value As Integer)
            Me._currentUsers = value

            If _maxUsers = 0 Then
                currentUsersLbl.UIThread(Function()
                                             Me.currentUsersLbl.Text = "Current Users: " & CurrentUsers
#Disable Warning BC42105
                                         End Function)
#Enable Warning BC42105
            Else
                currentUsersLbl.UIThread(Function()
                                             Me.currentUsersLbl.Text = "Current Users: (" & CurrentUsers & "/" & MaxUsers & ")"
#Disable Warning BC42105
                                         End Function)
#Enable Warning BC42105
            End If
        End Set
    End Property

    Public Property MaxUsers As Integer
        Get
            Return _maxUsers
        End Get
        Set(ByVal value As Integer)
            Me._maxUsers = value
            currentUsersLbl.UIThread(Function()
                                         Me.currentUsersLbl.Text = "Current Users: (" & CurrentUsers & "/" & MaxUsers & ")"
#Disable Warning BC42105
                                     End Function)
#Enable Warning BC42105
        End Set
    End Property

    Public WriteOnly Property RoomSuject As String
        Set(ByVal value As String)

            If Not String.IsNullOrWhiteSpace(value) Then
                chatPanel.UIThread(Function()
                                       Dim subject As WebBrowser = New WebBrowser()
                                       subject.Dock = DockStyle.Top
                                       subject.ScrollBarsEnabled = False
                                       subject.DocumentText = value
                                       chatPanel.Controls.Add(subject)
#Disable Warning BC42105
                                   End Function)
#Enable Warning BC42105



            End If
        End Set
    End Property

    Public Property RoomName As String
        Get
            Return Me.Name
        End Get
        Set(ByVal value As String)
            Me.Name = value
            Me.UIThread(Function()
                            Me.Text = value
#Disable Warning BC42105
                        End Function)
#Enable Warning BC42105
        End Set
    End Property

    Private Sub sujectChanged(ByVal subject As MucSubject)
        Dim timestamp As Long = CLng((DateTime.Now.Subtract(New DateTime(1970, 1, 1, 2, 30, 0).AddHours(12).AddMinutes(60))).TotalMilliseconds)
        RoomSuject = subject.Message
        '==============================================
        Dim [event] As RoomEventUpdateMiddle = New RoomEventUpdateMiddle(subject.Author)
        If subject.Author = ryu.Username Then
            [event].RoomEvent = ("Subject published successfully.")
        Else
            [event].RoomEvent = ("Subject published by " & subject.Author & ".")
        End If
        chatPanel.UIThread(Function()
                               chatPanel.Controls.Add([event])
                           End Function)
        '======================================


    End Sub
    Dim n As String
    Dim u As String
    Dim aff As String
    Public Sub roomJoined(ByVal muc As Muc)
        On Error Resume Next
        Application.DoEvents()
        Task.Factory.StartNew(
     Sub()
         '  Dim timestamp As Long = CLng((DateTime.Now.Subtract(New DateTime(1970, 1, 1, 2, 30, 0).AddHours(12).AddMinutes(60))).TotalMilliseconds)
         If muc IsNot Nothing Then
             For i As Integer = 0 To muc.MucUsers.Count - 1
                 Dim user As MucUser = muc.MucUsers.ElementAt(i).Value
                 u = Convert.ToString(user.Username.ToString)
                 aff = Convert.ToString(user.Role.ToString)
                 If user IsNot Nothing Then
                     Dim [event] As RoomEventUpdateMiddle = New RoomEventUpdateMiddle(user.Username.ToString)
                     If user.Username.ToString = ryu.Username Then

                         [event].eventMsgLbl.Text = ("You joined the room as " + user.Role.ToString & ".")
                         chatPanel.UIThread(Function()
                                                chatPanel.Controls.Add([event])
                                            End Function)
                     Else
                         [event].eventMsgLbl.Text = (user.Username.ToString & " is joined room as " + user.Role.ToString & ".")
                         If user.Role.ToString = "creator" OrElse user.Role.ToString = "owner" Then
                             If rtfmaster.Text.Contains(user.Username.ToString) Then
                             Else
                                 rtfmaster.AppendText(user.Username.ToString + "#")
                             End If
                         End If
                         If listuser.Items.Contains(user.Username.ToString) Then

                         Else
                             listuser.Items.Add(user.Username.ToString)
                         End If
                         chatPanel.UIThread(Function()
                                                chatPanel.Controls.Add([event])
                                            End Function)
                     End If
                     If UserPanel.Controls.ContainsKey(user.Username.ToString) Then
                         Dim item As RoomUserItem = CType(UserPanel.Controls(user.Username.ToString), RoomUserItem)
                         Select Case user.Role
                             Case RoleType.creator
                                 item.Tag = 0
                                 item.usernameLbl.ForeColor = Color.OrangeRed
                             Case RoleType.owner
                                 item.Tag = 1
                                 item.usernameLbl.ForeColor = Color.Red
                             Case RoleType.admin
                                 item.Tag = 2
                                 item.usernameLbl.ForeColor = Color.Blue
                             Case RoleType.member
                                 item.Tag = 3
                                 item.usernameLbl.ForeColor = Color.Green
                             Case RoleType.none
                                 item.Tag = 4
                                 item.usernameLbl.ForeColor = Color.FromKnownColor(KnownColor.ControlText)
                             Case Else
                                 item.Tag = 5
                                 item.usernameLbl.ForeColor = Color.FromKnownColor(KnownColor.DarkGray)
                         End Select
                         item.usernameLbl.Text = (user.Username.ToString)
                         item.roleLbl.Text = user.Role.ToString()
                     Else
                         Dim item As RoomUserItem = New RoomUserItem(user.Username.ToString)
                         Select Case user.Role
                             Case RoleType.creator
                                 item.Tag = 0
                                 item.usernameLbl.ForeColor = (Color.OrangeRed)

                             Case RoleType.owner
                                 item.Tag = 1
                                 item.usernameLbl.ForeColor = (Color.Red)

                             Case RoleType.admin
                                 item.Tag = 2
                                 item.usernameLbl.ForeColor = (Color.Blue)

                             Case RoleType.member
                                 item.Tag = 3
                                 item.usernameLbl.ForeColor = (Color.Green)

                             Case RoleType.none
                                 item.Tag = 4
                                 item.usernameLbl.ForeColor = (Color.FromKnownColor(KnownColor.ControlText))

                         End Select
                         item.usernameLbl.Text = (user.Username.ToString)
                         item.roleLbl.Text = user.Role.ToString()
                         UserPanel.UIThread(Function()
                                                UserPanel.Controls.Add(item)
                                            End Function)
                         If user.Username.ToString = ryu.Username Then
                         Else
                             listuser.Items.Add(user.Username.ToString)
                         End If
                         '===========================
                     End If



                     UserPanel.UIThread(Function()
                                            Dim itemArray As RoomUserItem() = UserPanel.Controls.Cast(Of RoomUserItem)().OrderBy(Function(x) x.Key).ToArray()
                                            itemArray = UserPanel.Controls.Cast(Of RoomUserItem)().OrderBy(Function(x) x.Tag).ToArray()
                                            UserPanel.Controls.AddRange(itemArray)
#Disable Warning BC42105
                                        End Function)
#Enable Warning BC42105


                 End If
             Next

         End If


     End Sub)
    End Sub

    Private mucusr As String
    Private mucmsg As String
    Private ufrom As String
    Public pwr As String = ""
    Public grt As String = ""
    Private Sub roomPres(ByVal user As MucUser)
        Application.DoEvents()
        Task.Factory.StartNew(
     Sub()
         If user IsNot Nothing Then

             Me.UIThread(Function()
                             Dim [event] As RoomEventUpdateMiddle = New RoomEventUpdateMiddle(user.PacketID)

                             If user.IsJoined Then

                                 ryu.GetMucInfo(Me.Text)
                                 [event].eventMsgLbl.Text = user.Username.ToString & " is joined room as " + user.Role.ToString & "."
                                 If listuser.Items.Contains(user.Username) Then
                                     listuser.Items.Add(user.Username.ToString)
                                 End If
                                 If user.Role.ToString = "creator" OrElse user.Role.ToString = "owner" Then
                                     If rtfmaster.Text.Contains(user.Username) Then
                                         Return (user.Username)
                                     Else
                                         rtfmaster.AppendText(user.Username.ToString + "#")
                                     End If
                                 End If


                                     chatPanel.UIThread(Function()
                                                            chatPanel.Controls.Add([event])
#Disable Warning BC42105
                                                        End Function)
#Enable Warning BC42105
                                 Dim item As RoomUserItem = New RoomUserItem(user.Username.ToString)
                                 Select Case user.Role
                                     Case RoleType.creator
                                         item.Tag = 0
                                         item.usernameLbl.ForeColor = Color.OrangeRed
                                     Case RoleType.owner
                                         item.Tag = 1
                                         item.usernameLbl.ForeColor = Color.Red
                                     Case RoleType.admin
                                         item.Tag = 2
                                         item.usernameLbl.ForeColor = Color.Blue
                                     Case RoleType.member
                                         item.Tag = 3
                                         item.usernameLbl.ForeColor = Color.Green
                                     Case RoleType.none
                                         item.Tag = 4
                                         item.usernameLbl.ForeColor = Color.FromKnownColor(KnownColor.ControlText)
                                     Case Else
                                         item.Tag = 5
                                         item.usernameLbl.ForeColor = Color.FromKnownColor(KnownColor.DarkGray)
                                 End Select
                                 If chkgreeting.Checked Then
                                     ufrom = (user.Username)
                                     mucnm = user.MucName
                                     Dim random As Random
                                     Dim strArray3 As String() = Nothing
                                     strArray3 = txtgreetingsIn.Text.Split(New Char() {"#"c})
                                     random = New Random()
                                     sndg = strArray3(random.[Next](strArray3.Length))
                                     sndg = Replace(sndg, "[buddy]", user.Username)
                                     sndg = Replace(sndg, "[roomname]", RoomName)
                                     sendgreetings()
                                 End If

                                 If chkidfilter.Checked Then
                                     If user.Role = "none" Then
                                         If user.Username.Length > txtidnum.Text Then
                                             ryu.Muc.SetRole(user.Username, RoleType.outcast)
                                         End If
                                     End If

                                 End If




                                 item.usernameLbl.Text = user.Username.ToString
                                     item.roleLbl.Text = user.Role.ToString()
                                     UserPanel.UIThread(Function()
                                                            UserPanel.Controls.Add(item)
#Disable Warning BC42105
                                                        End Function)
#Enable Warning BC42105

                                 Else
                                     [event].eventMsgLbl.Text = user.Username & " is left."
                                 chatPanel.UIThread(Function()
                                                        chatPanel.Controls.Add([event])

                                                        If listuser.Items.Contains(user.Username.ToString) Then
                                                            listuser.Items.Remove(user.Username.ToString)
                                                        End If


#Disable Warning BC42105
                                                    End Function)
#Enable Warning BC42105

                                 If UserPanel.Controls.ContainsKey(user.Username.ToString) Then
                                     Dim item As RoomUserItem = CType(UserPanel.Controls(user.Username.ToString), RoomUserItem)

                                     Select Case user.Role
                                         Case RoleType.creator
                                             item.Tag = 0
                                             item.usernameLbl.ForeColor = Color.OrangeRed
                                         Case RoleType.owner
                                             item.Tag = 1
                                             item.usernameLbl.ForeColor = Color.Red
                                         Case RoleType.admin
                                             item.Tag = 2
                                             item.usernameLbl.ForeColor = Color.Blue
                                         Case RoleType.member
                                             item.Tag = 3
                                             item.usernameLbl.ForeColor = Color.Green
                                         Case RoleType.none
                                             item.Tag = 4
                                             item.usernameLbl.ForeColor = Color.FromKnownColor(KnownColor.ControlText)
                                         Case Else
                                             item.Tag = 5
                                             item.usernameLbl.ForeColor = Color.FromKnownColor(KnownColor.DarkGray)
                                     End Select
                                     item.usernameLbl.Text = user.Username.ToString
                                     item.roleLbl.Text = user.Role.ToString()
                                     UserPanel.UIThread(Function()
                                                            UserPanel.Controls.Remove(item)
                                                        End Function)
                                     ryu.GetMucInfo(Me.Text)
                                 End If

                             End If

                             Dim muc As Muc = ryu.JoinedMuc(Me.Text)

                             If muc IsNot Nothing Then
                                 CurrentUsers = muc.CurrentUsers.Count
                             End If

                             UserPanel.UIThread(Function()
                                                    Dim itemArray As RoomUserItem() = UserPanel.Controls.Cast(Of RoomUserItem)().OrderBy(Function(x) x.Key).ToArray()
                                                    itemArray = UserPanel.Controls.Cast(Of RoomUserItem)().OrderBy(Function(x) x.Tag).ToArray()
                                                    UserPanel.Controls.AddRange(itemArray)
#Disable Warning BC42105
                                                End Function)
#Enable Warning BC42105


#Disable Warning BC42105
                         End Function)
#Enable Warning BC42105
         End If
     End Sub)      
     End Sub
    Dim sndg As String = ""
    Private Sub sendgreetings()

        Dim body As String = sndg
        Dim msgID As String = ""
        Dim timestamp As Long = CLng((DateTime.Now.Subtract(New DateTime(1970, 1, 1, 2, 30, 0).AddHours(5).AddMinutes(30))).TotalMilliseconds)

        If Not String.IsNullOrWhiteSpace(body) Then

            If body.StartsWith("http") Then

                If body.EndsWith(".png") OrElse body.EndsWith(".jpg") OrElse body.EndsWith(".jpeg") OrElse body.EndsWith(".bmp") Then
                    msgID = ryu.SendImage(Me.Text, body, MessageType.MucMessage)

                ElseIf body.EndsWith(".mp3") OrElse body.EndsWith(".wav") OrElse body.EndsWith(".3gp") OrElse body.EndsWith(".mp4") Then
                    msgID = ryu.SendAudio(Me.Text, body, New Random().[Next](100, 500), MessageType.MucMessage)
                Else
                    msgID = ryu.SendMessage(Me.Text, body, MessageType.MucMessage)


                End If
            Else
                msgID = ryu.SendMessage(Me.Text, body, MessageType.MucMessage)


            End If
        End If

    End Sub

    Dim gr As GraphicsPath
    Private Sub RoomMessageForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Application.DoEvents()
        CheckForIllegalCrossThreadCalls = False
        ' gr = RoundedRectangle.Create(txtowner.ClientRectangle, 10, RoundedRectangle.RectangleCorners.All)
        '  txtowner.Region = New Region(gr)
        RichTextBox1.Focus()
        ' richTextBox1.[Select](0, 0)
        RichTextBox1.[Select]()
        '   main.joinedLayoutPanel()
        main.removeRoomForm(Me.Text)





    End Sub

    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles chkidfilter.CheckedChanged
        If chkidfilter.Checked Then
            ryu.SendMessage(Me.Text, "AutoBan ID Length is NOW ACTIVATED.", MessageType.MucMessage)
        Else
            ryu.SendMessage(Me.Text, "AutoBan ID Length is NOW DEACTIVATED.", MessageType.MucMessage)
        End If
    End Sub

    Private Sub tmrautopost_Tick(sender As Object, e As EventArgs) Handles tmrautopost.Tick
        tmrautopost.Interval = TextBox1.Text
        If chkidfilter.Checked Then
            ryu.SendMessage(Me.Text, "This Room has SECURITY ACTIVE", MessageType.MucMessage)
        Else
            ryu.SendMessage(Me.Text, "🤔", MessageType.MucMessage)
        End If
    End Sub

    Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles chkpost.CheckedChanged
        If chkpost.Checked Then
            tmrautopost.Start()
        Else
            tmrautopost.Stop()
        End If
    End Sub
    Dim userabuser As String = ""
    Private katalama4 As Integer
    Dim bdys As String

    Public Sub answerbot()
        If chkbw.Checked Then
            '=======================================
            '    If rulebot.isRules Then
            '  Try
            Dim chArray10 As Char()
            Dim strArray3 As String()
            Dim flag9 As Boolean
            Dim num10 As Integer
            Dim strArray4 As String()
            Dim strArray5 As String()
            Dim flag10 As Boolean
            Dim num11 As Integer
            If chkbw.Checked Then
                chArray10 = New Char() {"#"c}
                Dim separator As Char() = chArray10
                strArray3 = rulebot.ruleRoom.ToString().Split(separator, StringSplitOptions.RemoveEmptyEntries)
                flag9 = False
                num10 = 0
            Else
                '  GoTo TR_065A
            End If

            GoTo _TR_067E
_TR_065B:
            num10 += 1
            GoTo _TR_067E
_TR_0666:
            If flag10 Then
                Dim strArray6 As String() = strArray4(1).Split(New Char() {"~"c}, StringSplitOptions.RemoveEmptyEntries)
                If strArray6.Length > 0 Then
                    Dim flag14 As Boolean = False
                    While Not flag14
                        Dim _length As Integer = strArray6.Length
                        Dim random As Random = Nothing
                        random = New Random()
                        Thread.Sleep(20)
                        Dim index As Integer = random.[Next](_length) Mod _length
                        If (katalama4 <> index) OrElse (_length = 1) Then
                            Dim kalimat As String = strArray6(index).Replace("[buddy]", userabuser.ToString).Split(New Char() {"%"c})(0).Replace("[nick]", ryu.Username())
                            Dim res As String = parserwords(kalimat, 0).ToString()
                            ryu.SendMessage(Me.Text, res, MessageType.MucMessage)
                            ryu.Muc.KickUsers(userabuser)
                            katalama4 = index
                            flag14 = True
                        End If
                    End While
                End If
            End If
            flag9 = False
            GoTo _TR_065B
_TR_067A:
            While True
                If num11 < strArray5.Length Then
                    If bdys.ToLower() <> strArray5(num11).ToLower() Then
                        Dim str16 As String = strArray5(num11).ToLower().Trim()
                        Dim flag11 As Boolean = False
                        If (str16.Substring(0, 1) = "[") AndAlso (str16.Substring(str16.Length - 1) = "]") Then
                            flag11 = True
                            str16 = str16.Replace("[", "").Replace("]", "")
                        End If
                        If bdys.ToLower().Trim().Contains(str16) AndAlso (Not String.IsNullOrEmpty(bdys) AndAlso flag11) Then
                            flag10 = True
                        Else
                            str16 = strArray5(num11).ToLower().Trim()
                            Dim flag12 As Boolean = False
                            Dim flag13 As Boolean = False

                            If str16.Substring(0, 1) = "~" Then
                                flag12 = True
                                str16 = str16.Replace("~", "").Trim()
                            End If

                            If str16.Substring(str16.Length - 1) = "~" Then
                                flag13 = True
                                str16 = str16.Replace("~", "").Trim()
                            End If

                            If bdys.Length <= str16.Length Then
                                Exit While
                            End If

                            If (bdys.ToLower().Trim().Substring(0, str16.Length) = str16) AndAlso flag13 Then
                                flag10 = True
                            Else

                                If (bdys.ToLower().Trim().Substring(bdys.Length - str16.Length) <> str16) OrElse Not flag12 Then
                                    Exit While
                                End If

                                flag10 = True
                            End If
                        End If

                        GoTo _TR_0666
                    Else
                        flag10 = True
                        GoTo _TR_0666
                    End If
                Else
                    GoTo _TR_0666
                End If

                Exit While
            End While

            num11 += 1
            GoTo _TR_067A
_TR_067E:

            While True

#Disable Warning BC42104
                If num10 >= strArray3.Length Then
#Enable Warning BC42104
                    Exit While
                End If

                If Not flag9 Then
                    flag9 = True
                    strArray4 = strArray3(num10).Split(New Char() {"="c}, StringSplitOptions.RemoveEmptyEntries)
                    strArray5 = strArray4(0).Split(New Char() {"|"c}, StringSplitOptions.RemoveEmptyEntries)
                    flag10 = False
                    num11 = 0
                    GoTo _TR_067A
                End If

                GoTo _TR_065B
            End While

            '   Catch
            'End Try
        End If

        '   End If


    End Sub

    Private Function parserwords(ByVal kalimat As String, ByVal mode As Integer) As String
        Dim str As String = kalimat
        Select Case mode
            Case 0
                str = str.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("'", "&apos;").Replace("""", "&quot;")
            Case 1
                str = str.Replace("&amp;", "&").Replace("&lt;", "<").Replace("&gt;", ">").Replace("&apos;", "'").Replace("&quot;", """").Replace("&nbsp;", " ")
            Case Else
        End Select
        Return str
    End Function
    Private Function pagpalit(ByVal himayin As String) As String
        Return himayin.Replace(vbCrLf, " ").Replace(vbCr, " ").Replace(vbLf, " ").Replace("  ", " ").Replace("# ", "#").Replace(" #", "#").Replace(" ~", "~").Replace("~ ", "~").Trim()
    End Function
    Public Sub customGreetingsAndManagementRoom()
        Try
            Me.inf = New inifile(Me.profilepath)
            Me.rulebot.ruleRoom = Me.inf.IniReadValue("ruleRoom")
            If String.IsNullOrEmpty(Me.rulebot.ruleRoom) Then
                rulebot.ruleRoom = "[fuck]=badwords not allowed here [buddy]~bastos ka! [buddy]~isang tadyak kalang! [buddy]~dont say badwords anymore!#[pussy]=badwords not allowed here [buddy]~bastos ka! [buddy]~isang tadyak kalang! [buddy]~dont say badwords anymore!#[iyot]|[iyut]=badwords not allowed here [buddy]~bastos ka! [buddy]~isang tadyak kalang! [buddy]~dont say badwords anymore!#[kantot]|[puke]|[bilat]|[putay]=badwords not allowed here [buddy]~bastos ka! [buddy]~isang tadyak kalang! [buddy]~dont say badwords anymore!#[sex]=badwords not allowed here [buddy]~bastos ka! [buddy]~isang tadyak kalang! [buddy]~dont say badwords anymore!#"
            End If
            Me.rulebot.greetingsIn = Me.inf.IniReadValue("greetingsIn")
            If String.IsNullOrEmpty(Me.rulebot.greetingsIn) Then
                rulebot.greetingsIn = "welcome [buddy] here at [roomname]#hi [buddy]#welcomeback [buddy] nice to see you here#i like your style [buddy] ;)#join us [buddy]#"
            End If



        Catch exception1 As Exception
            '  MessageBox.Show(exception1.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand)
        End Try
    End Sub
    Private Function verifystring(ByVal bacastring As String, ByVal mode As Boolean) As String
        Return If(String.IsNullOrEmpty(bacastring), (If(mode, "false", "0")), bacastring)
    End Function
    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles btnsave.Click
        On Error Resume Next
        Me.txtrules.Text = Me.pagpalit(Me.txtrules.Text)
        Me.inf = Nothing
        Me.inf = New inifile(profilepath)
        Me.inf.IniWriteValue("ruleRoom", Me.pagpalit(Me.txtrules.Text), 1)
        '  Me.scorer = Nothing
        ' scorer = New REUSCOREBOARD.REUSCOREBOARD.REUscoreBoard
        ' If scorer.registry Is Nothing Then
        ' Return
        ' Else
        ' Me.scorer.registry.SubKey = scorer.profilepath
        'Me.scorer.registry.DeleteSubKeyTree()
        'Me.scorer.registry.Write("isRules", Me.chkbw.Checked)
        'rulebot.ruleRoom = Me.txtrules.Text
        ' End If

        Me.txtgreetingsIn.Text = Me.pagpalit(Me.txtgreetingsIn.Text)
        Me.inf = Nothing
        Me.inf = New inifile(profilepath)
        Me.inf.IniWriteValue("greetingsIn", Me.pagpalit(Me.txtgreetingsIn.Text), 1)
        '   Me.scorer = Nothing
        '   scorer = New REUSCOREBOARD.REUSCOREBOARD.REUscoreBoard
        '   If scorer.registry Is Nothing Then
        '  Return
        '   Else
        '  Me.scorer.registry.SubKey = scorer.profilepath
        '  Me.scorer.registry.DeleteSubKeyTree()
        ' Me.scorer.registry.Write("isGreetingsin", Me.chkgreeting.Checked)
        '  rulebot.greetingsIn = Me.txtgreetingsIn.Text
        '   End If
    End Sub

    Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles chkbw.CheckedChanged
        If chkbw.Checked Then

            ryu.SendMessage(Me.Text, "Auto Kick BadWords Not Allowed is Now Activated", MessageType.MucMessage)
        Else
            ryu.SendMessage(Me.Text, "Auto Kick BadWords Not Allowed is Now Deactivated", MessageType.MucMessage)

        End If
    End Sub



    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        If IsNumeric(TextBox1.Text) Then
        Else
            TextBox1.Text = 20000
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs)
        On Error Resume Next
        Me.txtgreetingsIn.Text = Me.pagpalit(Me.txtgreetingsIn.Text)
        Me.inf = Nothing
        Me.inf = New inifile(profilepath)
        Me.inf.IniWriteValue("greetingsIn", Me.pagpalit(Me.txtgreetingsIn.Text), 1)
        '    Me.scorer = Nothing
        '   scorer = New REUSCOREBOARD.REUSCOREBOARD.REUscoreBoard
        '  If scorer.registry Is Nothing Then
        '  Return
        ' Else
        '  Me.scorer.registry.SubKey = scorer.profilepath
        '     Me.scorer.registry.DeleteSubKeyTree()
        '  Me.scorer.registry.Write("isGreetingsin", Me.chkgreeting.Checked)
        rulebot.greetingsIn = Me.txtgreetingsIn.Text
        ' End If









    End Sub

    Private Sub InviteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles InviteToolStripMenuItem.Click
        ryu.SendMessage(Me.Text, "/inv@" + txtinviteuser.Text, MessageType.MucMessage)
    End Sub

    Private Sub AddToFavouriteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AddToFavouriteToolStripMenuItem.Click
        If AddToFavouriteToolStripMenuItem.Text = "Add to Favourite" Then
            ryu.Muc.AddFavourite()
            AddToFavouriteToolStripMenuItem.Text = "Remove to Favourite"
        ElseIf AddToFavouriteToolStripMenuItem.Text = "Remove to Favourite" Then
            ryu.Muc.RemoveFavourite()
            AddToFavouriteToolStripMenuItem.Text = "Add to Favourite"
        End If
    End Sub

    Private Sub RejoinToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RejoinToolStripMenuItem.Click
        ryu.Muc.Rejoin(Me.Text)

    End Sub
    '  ryu.Muc.SendMessage("")

    Private _username As String
    Private _message As String
    Private _picUrl As String
    Private _isOnline As Boolean
    Private _mode As String
    Private _lastSeen As String

    Public Property IsOnline As Boolean
        Get
            Return Me._isOnline
        End Get
        Set(ByVal value As Boolean)
            Me._isOnline = value
        End Set
    End Property




    Private Sub chatPanel_ControlAdded(sender As Object, e As ControlEventArgs) Handles chatPanel.ControlAdded
        Application.DoEvents()
        chatPanel.VerticalScroll.Value = chatPanel.VerticalScroll.Maximum
    End Sub

    Private Sub tmrflood_Tick(sender As Object, e As EventArgs) Handles tmrflood.Tick
        On Error Resume Next
        ryu.SendImage(txttargetuser.Text, "https://cdn.chatp.net/logo-new.png", MessageType.ChatMessage)
        ryu.SendMessage(txttargetuser.Text, TextBox2.Text, MessageType.ChatMessage)
        ryu.SendImage(txttargetuser.Text, "https://cdn.chatp.net/logo-new.png", MessageType.ChatMessage)

    End Sub

    Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
        If Button1.Text = "Start" Then
            tmrflood.Start()
            Button1.Text = "Stop"
        ElseIf Button1.Text = "Stop" Then
            tmrflood.Stop()
            Button1.Text = "Start"

        End If
    End Sub

    Private Sub btntest_Click(sender As Object, e As EventArgs) Handles btntest.Click
        ryu.Muc.GetAffiliationList(Affiliation.Members)
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        On Error Resume Next
        rtfuserlist.Text = ""
        tmrulcolect = New System.Windows.Forms.Timer()
        AddHandler tmrulcolect.Tick, New EventHandler(AddressOf tmrulcolect_Tick)
        Call Me.tmrulcolect.Start()
    End Sub

    Private Sub tmrulcolect_Tick(sender As Object, e As EventArgs) Handles tmrulcolect.Tick
        On Error Resume Next
        Control.CheckForIllegalCrossThreadCalls = False
        tmrulcolect.Interval = 1000
        Dim nbLine As Integer
        nbLine = rtfuserlist.Lines.Count
        Me.listuser.SelectedIndex = Me.listuser.SelectedIndex + 1
        If rtfuserlist.Text.Contains(0) Then
            If rtfuserlist.Text.Contains(listuser.SelectedItem) Then
                ryu.SendMessage(TabPage1.Text, rtfuserlist.Text, MessageType.MucMessage)
                ' rtfuserlist.Text = ""
                Me.tmrulcolect.Stop()

                Me.listuser.SelectedItem = Nothing
            Else
                nbLine -= 1
                rtfuserlist.AppendText(nbLine & " " + listuser.SelectedItem + vbCrLf)
            End If
        Else

            If rtfuserlist.Text.Contains(listuser.SelectedItem) Then
                ryu.SendMessage(TabPage1.Text, rtfuserlist.Text, MessageType.MucMessage)
                tmrulcolect.Stop()
                Me.listuser.SelectedItem = Nothing
            Else
                rtfuserlist.AppendText(nbLine & " " + listuser.SelectedItem + vbCrLf)
            End If
        End If
    End Sub
    Dim crickuser As String
    Dim pcudm As String

    Private Sub Timer1_Tick(sender As Object, e As EventArgs)
        Timer1.Interval = 5000
        If CheckBox5.Checked Then
            If pc = 0 Then
                ryu.SendMessage(Me.Text, "PVT🏏CRICKET🏏TOURNAMENT" + vbNewLine + rtfcountplayer.Text, MessageType.MucMessage)
            Else
                ryu.SendMessage(Me.Text, "Number of Players set to " + pc.ToString(), MessageType.MucMessage)
                ' CheckBox5.Checked = False
                tmcricket = New System.Windows.Forms.Timer()
                tmcricket.Start()
                Timer1.Stop()
            End If
        End If
    End Sub

    Private Sub CheckBox11_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox11.CheckedChanged
        If CheckBox11.Checked Then
            Timer2 = New System.Windows.Forms.Timer()
            Call Me.Timer2.Start()
        Else
            Timer2.Stop()
        End If
    End Sub

    Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
        Dim time As DateTime = DateTime.Now
        '   Dim format As String = "MMM ddd d HH:mm yyyy"
        Dim format As String = "MMM ddd d yyyy"
        If Label16.Text = (time.ToString(format)) Then
        Else
            Label16.Text = (time.ToString(format))
            ryu.Muc.UpdateSubject("<h5>Confession<h5'>")
            Timer2.Stop()
            CheckBox11.Checked = False
            smb = 0
        End If
    End Sub
    Shared lnuma As Integer
    Shared lnumsa As Integer
    Shared lnumb As Integer
    Shared lnumsb As Integer
    Private Sub tmcricket_Tick(sender As Object, e As EventArgs) Handles tmcricket.Tick
        tmcricket.Interval = 1000
        If CheckBox5.Checked Then
            lnuma = pc
            lnumb = pc
            ' lblta.Text = pc
            ' lbltb.Text = pc
            lblta.Text = lta.Items.Count
            lnumsa = lblta.Text
            lbltb.Text = ltb.Items.Count
            lnumsb = lbltb.Text
            If lnumsa = 0 AndAlso lnumsb = 0 Then
                ryu.SendMessage(Me.Text, "Send t1 to join the Team " + txtteama.Text + vbNewLine + " Send t2 to join the Team " + txtteamb.Text, MessageType.MucMessage)
            ElseIf lnumsa = lnuma AndAlso lnumsb = lnumb Then
                ryu.SendMessage(Me.Text, "🏏" + txtteama.Text + " 🆚 🏏" + txtteamb.Text + vbNewLine + " be Ready!" + vbNewLine + "👉 " + txtteama.Text + " 🏏Batting " + vbNewLine + "👉 " + txtteamb.Text + "💥 Bowler", MessageType.MucMessage)
                Me.lta.SelectedIndex = Me.lta.SelectedIndex + 1
                txtpa.Text = lta.SelectedItem
                Me.ltb.SelectedIndex = Me.ltb.SelectedIndex + 1
                txtpb.Text = ltb.SelectedItem
                Thread.Sleep(5000)
                ryu.SendMessage(Me.Text, txtpa.Text + "🏏 BatsMen " + vbNewLine + txtpb.Text + "💥 Bowler ", MessageType.MucMessage)
                Thread.Sleep(5000)
                ryu.SendMessage(Me.Text, txtpb.Text + vbNewLine + "💥 To Bowl Send A Number  " + vbNewLine + "👉(0 1 2 3 4 5 6)" + vbNewLine + " In the 👉Private", MessageType.MucMessage)
                CheckBox5.Checked = False
                CheckBox6.Checked = True
                chkb.Checked = True
                tmcricket.Stop()
            ElseIf lnumsb = lnumb Then
                ryu.SendMessage(Me.Text, "Send t1 to join the Team " + txtteama.Text + " 🏏" + vbNewLine + "Team " + txtteamb.Text + " reached the Numbers of Players.", MessageType.MucMessage)
            ElseIf lnumsa = lnuma Then
                ryu.SendMessage(Me.Text, "Send t2 to join the Team " + txtteamb.Text + " 🏏" + vbNewLine + "Team " + txtteama.Text + " reached the Numbers of Players.", MessageType.MucMessage)
            Else
                ryu.SendMessage(Me.Text, "Send t1 to join the Team " + txtteama.Text + vbNewLine + " Send t2 to join the Team " + txtteamb.Text, MessageType.MucMessage)

            End If
        End If
    End Sub

    Private Sub tmfind_Tick(sender As Object, e As EventArgs) Handles tmfind.Tick
        tmfind.Interval = 20000
        If CheckBox6.Checked Then
            If chka.Checked Then
                ryu.SendMessage(Me.Text, "⚽ " + wickbs.ToString() + vbNewLine + txtpa.Text + " 🏏 To Bat Send A Number " + vbNewLine + "👉(0 1 2 3 4 5 6) " + vbNewLine + " In 👉Room.", MessageType.MucMessage)
                ryu.SendMessage(txtpb.Text, "⚽ " + wickbs.ToString() + vbNewLine + " Waiting for " + txtpa.Text + vbNewLine + " 🏏 Responce...  ", MessageType.ChatMessage)
            End If
        End If
        If CheckBox7.Checked Then
            If chka.Checked Then
                ryu.SendMessage(Me.Text, " Waiting for " + txtpa.Text + vbNewLine + " 💥 Responce.. ", MessageType.MucMessage)
                ryu.SendMessage(txtpa.Text, " 💥 To Bowl Send A Number " + vbNewLine + " 👉(0 1 2 3 4 5 6) ", MessageType.ChatMessage)

            End If
        End If

    End Sub

    Private Sub tmta_Tick(sender As Object, e As EventArgs) Handles tmta.Tick
        tmta.Interval = 1000
        If CheckBox5.Checked Then
            If txtteama.Text = "" AndAlso txtteamb.Text = "" Then
                ryu.SendMessage(Me.Text, "PVT🏏CRICKET🏏TOURNAMENT" + vbNewLine + "Please Set the Team Name" + vbNewLine + " SEND 1/yourteamname TO SET 1ST TEAM NAME" + vbNewLine + " SEND 2/yourteamname TO SET 2ND TEAM NAME", MessageType.MucMessage)
            ElseIf txtteama.Text = "" Then
                ryu.SendMessage(Me.Text, "PVT🏏CRICKET🏏TOURNAMENT" + vbNewLine + "Please Set the Team A Name" + vbNewLine + " SEND 1/yourteamname TO SET 1ST TEAM NAME", MessageType.MucMessage)
            ElseIf txtteamb.Text = "" Then
                ryu.SendMessage(Me.Text, "PVT🏏CRICKET🏏TOURNAMENT" + vbNewLine + "Please Set the Team B Name" + vbNewLine + " SEND 2/yourteamname TO SET 2ND TEAM NAME", MessageType.MucMessage)
            Else
                ' ryu.SendMessage(TabPage1.Text, "WELCOME TO PVT🏏CRICKET🏏TOURNAMENT" + vbNewLine + rtfcountplayer.Text, MessageType.MucMessage)
                tmta.Stop()
                Timer1 = New System.Windows.Forms.Timer()
                Timer1.Start()
            End If
        End If
    End Sub

    Private Sub tmtb_Tick(sender As Object, e As EventArgs) Handles tmtb.Tick
        tmtb.Interval = 1000
        If CheckBox6.Checked Then
            If chkb.Checked Then
                ryu.SendMessage(Me.Text, " Waiting for " + txtpb.Text + vbNewLine + " 💥Bowl...  ", MessageType.MucMessage)
                ryu.SendMessage(txtpb.Text, " 💥 To Bowl Send A Number " + vbNewLine + " 👉(0 1 2 3 4 5 6) ", MessageType.ChatMessage)

            End If
        End If
        If CheckBox7.Checked Then
            If chkb.Checked Then
                ryu.SendMessage(Me.Text, "⚽ " + wickas.ToString() + vbNewLine + txtpb.Text + " 🏏 To Bat Send A Number " + vbNewLine + " 👉(0 1 2 3 4 5 6) " + vbNewLine + " In 👉Room.", MessageType.MucMessage)
                ryu.SendMessage(txtpa.Text, "⚽ " + wickas.ToString() + vbNewLine + " Waiting for " + txtpb.Text + vbNewLine + " 🏏Batting..  ", MessageType.MucMessage)
            End If
        End If
    End Sub

    Private Sub CheckBox6_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox6.CheckedChanged
        If CheckBox6.Checked Then
        Else
            chka.Checked = False
            chkb.Checked = False
            tmcricket.Stop()
            tmfind.Stop()
            tmtb.Stop()

        End If
    End Sub










    Private Sub RoomMessageForm_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        Application.DoEvents()
        For Each control As Control In chatPanel.Controls
            If TypeOf control Is AudioMessageControlLeft Then
                Dim left As RoomAudioMessageControlLeft = CType(control, RoomAudioMessageControlLeft)
                left.player.controls.[stop]()
            ElseIf TypeOf control Is AudioMessageControlRight Then
                Dim right As RoomAudioMessageControlLeft = CType(control, RoomAudioMessageControlLeft)
                right.player.controls.[stop]()
            End If
        Next
        ryu.LeaveMuc(Me.Text)
        main.removeRoomForm(Me.Text)
        Me.Dispose(True)
    End Sub






    Private Sub btnsearch_Click(sender As Object, e As EventArgs) Handles btnsearch.Click
        Usersearch(txtupc.Text, "")
    End Sub
    Private Function Usersearch(fname As String, lname As String) As Boolean
        '   Dim con1 As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + TextBox5.Text + "\cuserD.mdf;Integrated Security=True")

        pcudm = ""
        con1.Open()
        Dim cmd As SqlCommand = con1.CreateCommand
        cmd.CommandText = "SELECT COUNT(*) FROM cpD" & " WHERE USERNAME  = '" & txtupc.Text & "'"
        Usersearch = cmd.ExecuteScalar > 0
        If Usersearch = False Then
            '  MessageBox.Show("Student Data Not Found!")
            '  ryu.SendMessage(TabPage1.Text, txtupc.Text + " No Record Found in Cricket DataBase.", MessageType.MucMessage)
            txturc.Text = 0
            txtuwc.Text = 0
            txtubc.Text = 0
            Call btnsave.PerformClick()
            pcudm = pcudm + " USERNAME: " + txtupc.Text + vbNewLine
            pcudm = pcudm + " RUNS: " + txturc.Text + vbNewLine
            pcudm = pcudm + " WICKETS: " + txtuwc.Text + vbNewLine
            pcudm = pcudm + " BALLS: " + txtubc.Text + vbNewLine
            '  ryu.SendMessage(TabPage1.Text, pcudm, MessageType.MucMessage)
        Else
            cmd = con1.CreateCommand()
            cmd.CommandType = CommandType.Text
            cmd.CommandText = "select * from cpD where USERNAME='" + txtupc.Text + "'"
            cmd.ExecuteNonQuery()
            Dim dt As New DataTable()
            Dim da As New SqlDataAdapter(cmd)
            da.Fill(dt)
            DataGridView1.DataSource = dt
            ' MessageBox.Show("Student Data Found!")
            '========================================
            txtidnum.Text = DataGridView1.CurrentRow.Cells(0).Value
            txtupc.Text = DataGridView1.CurrentRow.Cells(1).Value
            txturc.Text = DataGridView1.CurrentRow.Cells(2).Value
            txtuwc.Text = DataGridView1.CurrentRow.Cells(3).Value
            txtubc.Text = DataGridView1.CurrentRow.Cells(4).Value
            pcudm = pcudm + " USERNAME: " + txtupc.Text + vbNewLine
            pcudm = pcudm + " RUNS: " + txturc.Text + vbNewLine
            pcudm = pcudm + " WICKETS: " + txtuwc.Text + vbNewLine
            pcudm = pcudm + " BALLS: " + txtubc.Text + vbNewLine
            '    ryu.SendMessage(TabPage1.Text, pcudm, MessageType.MucMessage)

        End If

        con1.Close()



    End Function

    Private Sub btnupdate_Click(sender As Object, e As EventArgs) Handles btnupdate.Click
        On Error Resume Next
        '  Dim con1 As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + TextBox5.Text + "\cuserD.mdf;Integrated Security=True")
        Dim update1 As String = "Update cpD set USERNAME='" & txtupc.Text & "',RUNS='" & txturc.Text & "',WICKETS='" & txtuwc.Text & "',BALLS='" & txtubc.Text & "' WHERE ID=" & txtidnum.Text & ""
        Dim command1 As New SqlCommand(update1, con1)
        If con1.State = ConnectionState.Closed Then
            con1.Open()
        End If
        command1.ExecuteNonQuery()

        con1.Close()

        Cud()
    End Sub
    Public Sub Cud()
        cmd = con1.CreateCommand()
        cmd.CommandType = CommandType.Text
        cmd.CommandText = ("Select * from cpD order by ID ")
        Dim dt As New DataTable()
        Dim da As New SqlDataAdapter(cmd)
        da.Fill(dt)
        DataGridView1.DataSource = dt
        DataGridView1.AllowUserToAddRows = False


    End Sub
    Dim sss As String
    Private Sub btndisplay_Click(sender As Object, e As EventArgs) Handles btndisplay.Click
        Cud()
    End Sub

    Private Sub btndelete_Click(sender As Object, e As EventArgs) Handles btndelete.Click
        '  Dim con1 As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + TextBox5.Text + "\cuserD.mdf;Integrated Security=True")
        Dim delete1 As String = "Delete from cpD where ID=" & txtidnum.Text
        Dim command1 As New SqlCommand(delete1, con1)
        If con1.State = ConnectionState.Closed Then
            con1.Open()
        End If
        command1.ExecuteNonQuery()
        '  MessageBox.Show("Student Data Deleted!")
        con1.Close()
        Cud()
    End Sub

    Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click
        UserExists(txtupc.Text, "")
    End Sub
    Private Function UserExists(fname As String, lname As String) As Boolean
        '  con1.Open()
        '  Dim con1 As New SqlConnection("Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + TextBox5.Text + "\cuserD.mdf;Integrated Security=True")
        If con1.State = ConnectionState.Closed Then
            con1.Open()
        End If
        Dim cmd As SqlCommand = con1.CreateCommand
        cmd.CommandText = "SELECT COUNT(*) FROM cpD" & " WHERE USERNAME  = '" & txtupc.Text & "'"
        UserExists = cmd.ExecuteScalar > 0
        If UserExists = False Then
            Dim command1 As New SqlCommand("Insert into cpD(USERNAME,RUNS,WICKETS,BALLS)values(@username,@runs,@wickets,@balls)", con1)
            command1.Parameters.Add("@username", SqlDbType.NVarChar).Value = txtupc.Text
            command1.Parameters.Add("@runs", SqlDbType.VarChar).Value = txturc.Text
            command1.Parameters.Add("@wickets", SqlDbType.VarChar).Value = txtuwc.Text
            command1.Parameters.Add("@balls", SqlDbType.VarChar).Value = txtubc.Text
            Dim memstr As New MemoryStream
            If con1.State = ConnectionState.Closed Then
                con1.Open()
            End If
            command1.ExecuteNonQuery()
            con1.Close()
            Cud()
        Else
            Call btnupdate.PerformClick()
        End If
        con1.Close()
    End Function



    Private Sub chkgreeting_CheckedChanged(sender As Object, e As EventArgs) Handles chkgreeting.CheckedChanged
        If chkgreeting.Checked Then

            ryu.SendMessage(Me.Text, "Welcome IN Greetings is Now Activated", MessageType.MucMessage)
        Else
            ryu.SendMessage(Me.Text, "Welcome IN Greetings is Now Deactivated", MessageType.MucMessage)

        End If
    End Sub

    Private Sub chkmain_CheckedChanged(sender As Object, e As EventArgs) Handles chkmain.CheckedChanged
        If chkmain.Checked Then

            ryu.SendMessage(Me.Text, "Server Bot Mode is Now Activated", MessageType.MucMessage)
        Else
            ryu.SendMessage(Me.Text, "Server Bot Mode is Now Deactivated", MessageType.MucMessage)

        End If
    End Sub

    Private Sub Button6_Click_1(sender As Object, e As EventArgs) Handles Button6.Click
        tmta = New System.Windows.Forms.Timer()
        AddHandler tmta.Tick, New EventHandler(AddressOf tmta_Tick)
        tmta.Start()
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs)
        ryu.Muc.ResetIP()
        ryu.Muc.RefreshToken()
        ryu.Muc.GetSettings(Me.Text)
    End Sub

    Private Sub Button7_Click_2(sender As Object, e As EventArgs)
        ryu.Muc.Reset()
        ryu.Muc.RefreshToken()
        ryu.Muc.GetSettings(Me.Text)
    End Sub



    Private Sub RichTextBox1_KeyUp(sender As Object, e As KeyEventArgs) Handles RichTextBox1.KeyUp
        If e.KeyCode = Keys.Enter Then
            RichTextBox1.ResetText()
        End If
    End Sub

    Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged
        If RichTextBox1.Text = String.Empty Then
            RichTextBox1.Text = "write a message..."
            RichTextBox1.ForeColor = Color.DarkGray
            RichTextBox1.[Select](0, 0)
            sendBtn.Image = My.Resources.attachments
        ElseIf RichTextBox1.Text <> "write a message..." Then
            RichTextBox1.Text = RichTextBox1.Text.Replace("write a message...", "")
            RichTextBox1.ForeColor = Color.Black
            RichTextBox1.[Select](RichTextBox1.Text.Length, RichTextBox1.Text.Length)
            sendBtn.Image = My.Resources.send
            If CheckBox3.Checked Then
                RichTextBox1.Text = Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(RichTextBox1.Text)
            End If
        End If
    End Sub

    Private Sub RichTextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles RichTextBox1.KeyDown
        If e.KeyCode = Keys.Enter Then

            If Not String.IsNullOrWhiteSpace(RichTextBox1.Text) AndAlso RichTextBox1.Text <> "write a message..." Then
                ryu.SendMessageState(Me.Text, StateType.paused)
                sendMsg()
            End If
        End If
    End Sub

    Private Sub RichTextBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles RichTextBox1.MouseDown
        If RichTextBox1.Text = "write a message..." Then
            RichTextBox1.[Select](0, 0)
        End If
    End Sub



    Private Sub Button10_Click(sender As Object, e As EventArgs)
        ryu.Muc.GetLogs(Me.Text)
    End Sub

    Private Sub Button11_Click(sender As Object, e As EventArgs)
        ryu.Muc.GetSettings(Me.Text)
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        If ComboBox1.Text = "none" Then
            ryu.Muc.SetRole(txtusertargetrole.Text, RoleType.none)
        ElseIf ComboBox1.Text = "kick" Then
            ryu.Muc.KickUsers(txtusertargetrole.Text)
        ElseIf ComboBox1.Text = "outcast" Then
            ryu.Muc.SetRole(txtusertargetrole.Text, RoleType.outcast)
        ElseIf ComboBox1.Text = "member" Then
            ryu.Muc.SetRole(txtusertargetrole.Text, RoleType.member)
        ElseIf ComboBox1.Text = "admin" Then
            ryu.Muc.SetRole(txtusertargetrole.Text, RoleType.admin)
        ElseIf ComboBox1.Text = "owner" Then
            ryu.Muc.SetRole(txtusertargetrole.Text, RoleType.owner)
        End If
    End Sub
End Class














THE CODES ABOVE IS WORKING THAT YOU CAN USE IT FOR YOUR OWN





VB.NET ALEXIA-IM FULL PROJECT SOURCE CODE



NOTE:PLEASE CONSIDERED ITS NOT FREE IF THE EXTRACT FILE ASKING PASSWORD




THANKS







 

No comments: