1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
|
Public Class Form1
Inherits System.Windows.Forms.Form
Private WithEvents wsClient As New SocketsClient()
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents Button4 As System.Windows.Forms.Button
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Label1 = New System.Windows.Forms.Label
Me.GroupBox2 = New System.Windows.Forms.GroupBox
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.Label6 = New System.Windows.Forms.Label
Me.PictureBox2 = New System.Windows.Forms.PictureBox
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox5 = New System.Windows.Forms.TextBox
Me.Label2 = New System.Windows.Forms.Label
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.Button4 = New System.Windows.Forms.Button
Me.TextBox6 = New System.Windows.Forms.TextBox
Me.Button3 = New System.Windows.Forms.Button
Me.GroupBox2.SuspendLayout()
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.PictureBox2, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.BackColor = System.Drawing.SystemColors.ActiveCaption
Me.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox1.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox1.ForeColor = System.Drawing.Color.Black
Me.TextBox1.Location = New System.Drawing.Point(8, 12)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.TextBox1.Size = New System.Drawing.Size(611, 258)
Me.TextBox1.TabIndex = 0
'
'TextBox2
'
Me.TextBox2.BackColor = System.Drawing.SystemColors.ActiveCaption
Me.TextBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox2.ForeColor = System.Drawing.Color.DarkOrchid
Me.TextBox2.Location = New System.Drawing.Point(37, 276)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(445, 20)
Me.TextBox2.TabIndex = 1
'
'Button1
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button1.Location = New System.Drawing.Point(488, 276)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(81, 20)
Me.Button1.TabIndex = 2
Me.Button1.Text = "Envoyer"
'
'Button2
'
Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button2.Location = New System.Drawing.Point(322, 58)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(139, 24)
Me.Button2.TabIndex = 4
Me.Button2.Text = "Rejoindre le salon"
'
'TextBox3
'
Me.TextBox3.BackColor = System.Drawing.SystemColors.ActiveCaption
Me.TextBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox3.Location = New System.Drawing.Point(322, 28)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(139, 20)
Me.TextBox3.TabIndex = 5
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(265, 35)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(51, 13)
Me.Label1.TabIndex = 6
Me.Label1.Text = "Salon :"
'
'GroupBox2
'
Me.GroupBox2.Controls.Add(Me.PictureBox1)
Me.GroupBox2.Controls.Add(Me.Label6)
Me.GroupBox2.Controls.Add(Me.PictureBox2)
Me.GroupBox2.Controls.Add(Me.Label1)
Me.GroupBox2.Controls.Add(Me.Label3)
Me.GroupBox2.Controls.Add(Me.TextBox3)
Me.GroupBox2.Controls.Add(Me.TextBox5)
Me.GroupBox2.Controls.Add(Me.Button2)
Me.GroupBox2.Controls.Add(Me.Label2)
Me.GroupBox2.Controls.Add(Me.TextBox4)
Me.GroupBox2.Controls.Add(Me.Button4)
Me.GroupBox2.Location = New System.Drawing.Point(53, 322)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(516, 142)
Me.GroupBox2.TabIndex = 8
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "Les options"
'
'PictureBox1
'
Me.PictureBox1.Image = Global.Irc.NET.My.Resources.Resources.question
Me.PictureBox1.Location = New System.Drawing.Point(467, 28)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(19, 20)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Me.PictureBox1.TabIndex = 11
Me.PictureBox1.TabStop = False
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(185, 113)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(175, 13)
Me.Label6.TabIndex = 14
Me.Label6.Text = "Enregistrer le serveur, port et salons"
'
'PictureBox2
'
Me.PictureBox2.Image = Global.Irc.NET.My.Resources.Resources.save
Me.PictureBox2.Location = New System.Drawing.Point(156, 106)
Me.PictureBox2.Name = "PictureBox2"
Me.PictureBox2.Size = New System.Drawing.Size(23, 20)
Me.PictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.PictureBox2.TabIndex = 13
Me.PictureBox2.TabStop = False
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.Location = New System.Drawing.Point(12, 48)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(42, 13)
Me.Label3.TabIndex = 8
Me.Label3.Text = "Port :"
'
'TextBox5
'
Me.TextBox5.BackColor = System.Drawing.SystemColors.ActiveCaption
Me.TextBox5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox5.Location = New System.Drawing.Point(85, 41)
Me.TextBox5.Name = "TextBox5"
Me.TextBox5.Size = New System.Drawing.Size(139, 20)
Me.TextBox5.TabIndex = 7
Me.TextBox5.Text = "7500"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(12, 25)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(67, 13)
Me.Label2.TabIndex = 6
Me.Label2.Text = "Serveur :"
'
'TextBox4
'
Me.TextBox4.BackColor = System.Drawing.SystemColors.ActiveCaption
Me.TextBox4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox4.ForeColor = System.Drawing.Color.Black
Me.TextBox4.Location = New System.Drawing.Point(85, 18)
Me.TextBox4.Name = "TextBox4"
Me.TextBox4.Size = New System.Drawing.Size(139, 20)
Me.TextBox4.TabIndex = 5
Me.TextBox4.Text = "213.246.45.64"
'
'Button4
'
Me.Button4.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button4.Location = New System.Drawing.Point(85, 67)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing.Size(139, 24)
Me.Button4.TabIndex = 4
Me.Button4.Text = "Valider"
'
'TextBox6
'
Me.TextBox6.AcceptsReturn = True
Me.TextBox6.AcceptsTab = True
Me.TextBox6.BackColor = System.Drawing.SystemColors.ActiveCaption
Me.TextBox6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.TextBox6.ForeColor = System.Drawing.Color.Black
Me.TextBox6.Location = New System.Drawing.Point(165, 484)
Me.TextBox6.Multiline = True
Me.TextBox6.Name = "TextBox6"
Me.TextBox6.Size = New System.Drawing.Size(248, 20)
Me.TextBox6.TabIndex = 9
'
'Button3
'
Me.Button3.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button3.Location = New System.Drawing.Point(422, 482)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(81, 20)
Me.Button3.TabIndex = 10
Me.Button3.Text = "Envoyer"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.ActiveCaption
Me.ClientSize = New System.Drawing.Size(629, 527)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.TextBox6)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MaximizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Bot IrcTchat V1.0"
Me.GroupBox2.ResumeLayout(False)
Me.GroupBox2.PerformLayout()
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.PictureBox2, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
#End Region
Private Sub AT(ByVal Text As String)
TextBox1.AppendText(Text & Environment.NewLine)
TextBox1.ScrollToCaret()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox4.Text = My.Settings.Serveur
TextBox5.Text = My.Settings.Port
TextBox3.Text = My.Settings.Salon
End Sub
Private Sub wsClient_onConnect() Handles wsClient.onConnect
AT("Connexion en cours...")
wsClient.SendData(wsClient.StringToBytes("NICK Eggy" & Environment.NewLine))
wsClient.SendData(wsClient.StringToBytes("USER Eggy localhost 0.0.0.0 :(Robot) Bot pour les serveurs T'chat" & Environment.NewLine))
End Sub
Private Sub wsClient_onError(ByVal Description As String) Handles wsClient.onError
AT("Erreur: " & Description & Environment.NewLine)
'AT("Erreur: Connectez vous avant de faire ceci !" & ControlChars.NewLine)
End Sub
Private Sub wsClient_onDataArrival(ByVal Data() As Byte, ByVal totBytes As Integer) Handles wsClient.onDataArrival
Dim inData As String = wsClient.BytestoString(Data)
Dim lData() As String
Dim C() As String
Dim tData As Integer
Dim CL As Integer
Dim CLi As String
Dim a As Integer
lData = Split(inData, Chr(10))
tData = UBound(lData) - LBound(lData)
For a = 0 To tData
If Mid(lData(a), 1, 1) = ":" Then
lData(a) = Mid(lData(a), 2)
End If
Next
For CL = 0 To tData
C = Split(lData(CL), " ")
ReDim Preserve C(2000)
CLi = lData(CL)
If C(0) = "PING" Then
wsClient.SendData(wsClient.StringToBytes("PONG :" & Mid(C(1), 2) & Environment.NewLine))
End If
AT(CLi)
Next
End Sub
#Region "Les commandes"
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If Asc(e.KeyChar) = 13 Then
wsClient.SendData(wsClient.StringToBytes(TextBox2.Text & Environment.NewLine))
TextBox2.SelectAll()
End If
End Sub
#End Region
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox3.Text = "" Then
MsgBox("ERREUR: Ajoutez au moins un Salon !")
Else
wsClient.SendData(wsClient.StringToBytes("JOIN " & TextBox3.Text & Environment.NewLine))
End If
End Sub
Private Sub Main_Form1Closing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
wsClient.SendData(wsClient.StringToBytes("QUIT" & " :Bye" & Environment.NewLine))
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Button4.Text = "Veuillez patienter..."
Me.Button4.Enabled = False
Try
If TextBox4.Text = "" Then
MsgBox("vous n'avez pas mis votre IP")
Me.Button4.Enabled = True
Me.Button4.Text = "Valider"
ElseIf TextBox5.Text = "" Then
MsgBox("vous n'avez pas mis votre PORT")
Me.Button4.Enabled = True
Me.Button4.Text = "Valider"
Else
wsClient.Connect(TextBox4.Text, TextBox5.Text)
Me.Button4.Enabled = True
Me.Button4.Text = "Valider"
End If
Catch ex As Exception
MsgBox("SERVEUR: votre dns n'est pas valide")
Me.Button4.Enabled = True
Me.Button4.Text = "Valider"
End Try
End Sub
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
My.Settings.Serveur = TextBox4.Text
My.Settings.Port = TextBox5.Text
My.Settings.Salon = TextBox3.Text
My.Settings.Save()
MsgBox("Sauvegarde des informations avec Succès")
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
MsgBox("Vous pouvez mettre dans la case Salon" & vbCrLf & "Plusieurs salon (Ex: #chan1, #chan2, #chan3)")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
wsClient.SendData(wsClient.StringToBytes("privmsg" & " #central " & TextBox6.Text & vbCrLf))
End Sub
Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class |
Partager