IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

Problème commande pour un bot Irc en vb


Sujet :

VB.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de kazylax
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    278
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juillet 2007
    Messages : 278
    Par défaut Phrase coupé dans la commande
    Bonjour,

    Je suis en train de faire un bot Irc sur visual basic 2008 Express
    et je bloque pour faire les commandes

    voici un exemple
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
            Dim aide As Integer
            If aide = "!aide" Then
                wsClient.SendData(wsClient.StringToBytes("PRIVMSG #test :test" & Environment.NewLine))
            End If
    En faite je voudrais avoir la commande (!aide)
    mais ceci ne fonctionne pas

    que la commande soit exécuter par les utilisateurs
    et non sur le programme meme

    Savez vous comment faire la commande s'il vous plait ?

    Merci
    Cordialement,

  2. #2
    Membre Expert
    Avatar de supersnail
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 719
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 719
    Par défaut
    Bonjour,

    Depuis quand on compare un Integer avec un String?

    A mon avis,l'erreur vient de là.

  3. #3
    Membre éclairé Avatar de kazylax
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    278
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juillet 2007
    Messages : 278
    Par défaut
    le problème c'est que les commandes ne fonctionne pas
    sauf celui ci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    wsClient.SendData(wsClient.StringToBytes("JOIN #test" & Environment.NewLine))
    Si je met la commande suivante aucun effet sur le t'chat

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    wsClient.SendData(wsClient.StringToBytes("MSG #test test" & Environment.NewLine))
    j'ai l'erreur suivante
    Eggy MSG :Commande inconnue

    Si vous avez une idée
    Merci
    Cordialement,

  4. #4
    Membre Expert
    Avatar de supersnail
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 719
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 719
    Par défaut
    Euh.. c'est pas avec le peu de code que tu as mis qu'on va pouvoir vraiment t'aider

  5. #5
    Membre éclairé Avatar de kazylax
    Profil pro
    Inscrit en
    Juillet 2007
    Messages
    278
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juillet 2007
    Messages : 278
    Par défaut
    Après plusieurs test j'ai réussi
    sauf que la je peux pas mettre plus de deux mot dans la meme phrase

    voici le code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    Imports System
    Imports System.Net
    Imports System.Net.Sockets
    Imports System.Text
     
    Public Class StateObject
        Public workSocket As Socket = Nothing
        Public BufferSize As Integer = 32767
        Public buffer(32767) As Byte
        Public sb As New StringBuilder()
    End Class
     
    Public Class SocketsClient
        Public Event onConnect()
        Public Event onError(ByVal Description As String)
        Public Event onDataArrival(ByVal Data As Byte(), ByVal TotalBytes As Integer)
        Public Event onDisconnect()
        Public Event onSendComplete(ByVal DataSize As Integer)
     
        Private Shared response As [String] = [String].Empty
        Private Shared port As Integer = 44
        Private Shared ipHostInfo As IPHostEntry = Dns.Resolve("localhost")
        Private Shared ipAddress As ipAddress = ipHostInfo.AddressList(0)
        Private Shared client As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
     
        Public Sub Connect(ByVal RemoteHostName As String, ByVal RemotePort As Integer)
            Try
                client = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
                port = RemotePort
                ipHostInfo = Dns.Resolve(RemoteHostName)
                ipAddress = ipHostInfo.AddressList(0)
                Dim remoteEP As New IPEndPoint(ipAddress, port)
                client.BeginConnect(remoteEP, AddressOf sockConnected, client)
            Catch
                'RaiseEvent onError(Err.Description)
                RaiseEvent onError("Serveur invalide !")
                Exit Sub
            End Try
        End Sub
     
        Public Sub SendData(ByVal Data() As Byte)
            Try
                Dim byteData As Byte() = Data
                client.BeginSend(byteData, 0, byteData.Length, 0, AddressOf sockSendEnd, client)
            Catch
                RaiseEvent onError(Err.Description)
                Exit Sub
            End Try
        End Sub
     
        Public Sub Disconnect()
            Try
                client.Shutdown(SocketShutdown.Both)
            Catch
            End Try
            client.Close()
        End Sub
     
        Public Function StringToBytes(ByVal Data As String) As Byte()
            StringToBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(Data)
        End Function
     
        Public Function BytestoString(ByVal Data As Byte()) As String
            BytestoString = System.Text.ASCIIEncoding.ASCII.GetString(Data)
        End Function
     
        Private Sub sockConnected(ByVal ar As IAsyncResult)
            Try
                If client.Connected = False Then RaiseEvent onError("Connection refused.") : Exit Sub
                Dim state As New StateObject()
                state.workSocket = client
                client.BeginReceive(state.buffer, 0, state.BufferSize, 0, AddressOf sockDataArrival, state)
                RaiseEvent onConnect()
            Catch
                RaiseEvent onError(Err.Description)
                Exit Sub
            End Try
        End Sub
     
        Private Sub sockDataArrival(ByVal ar As IAsyncResult)
            Dim state As StateObject = CType(ar.AsyncState, StateObject)
            Dim client As Socket = state.workSocket
            Dim bytesRead As Integer
     
            Try
                bytesRead = client.EndReceive(ar)
            Catch
                Exit Sub
            End Try
     
            Try
                Dim Data() As Byte = state.buffer
                If bytesRead = 0 Then
                    client.Shutdown(SocketShutdown.Both)
                    client.Close()
                    RaiseEvent onDisconnect()
                    Exit Sub
                End If
                ReDim state.buffer(32767)
     
                client.BeginReceive(state.buffer, 0, state.BufferSize, 0, AddressOf sockDataArrival, state)
                RaiseEvent onDataArrival(Data, bytesRead)
            Catch
                RaiseEvent onError(Err.Description)
                Exit Sub
            End Try
        End Sub
     
        Private Sub sockSendEnd(ByVal ar As IAsyncResult)
            Try
                Dim client As Socket = CType(ar.AsyncState, Socket)
                Dim bytesSent As Integer = client.EndSend(ar)
                RaiseEvent onSendComplete(bytesSent)
            Catch
                RaiseEvent onError(Err.Description)
                Exit Sub
            End Try
        End Sub
     
        Public Function Connected() As Boolean
            Try
                Return client.Connected
            Catch
                RaiseEvent onError(Err.Description)
                Exit Function
            End Try
        End Function
    End Class
    Je lance la commande avec un bouton ou je met ceci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
        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 & Environment.NewLine))
        End Sub
    Merci
    Cordialement,

  6. #6
    Membre Expert
    Avatar de supersnail
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 719
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 719
    Par défaut
    Bonjour,
    les mots que tu envoies ont des accents?

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 11
    Dernier message: 30/05/2013, 14h19
  2. Aide pour Bot IRC Perl
    Par furious_mac dans le forum Langage
    Réponses: 3
    Dernier message: 06/09/2010, 18h24
  3. Réponses: 1
    Dernier message: 13/05/2008, 11h29
  4. Problème pour un client IRC avec Indy9/D7
    Par Ren97 dans le forum Web & réseau
    Réponses: 2
    Dernier message: 05/01/2008, 22h16
  5. bot irc: problème d'affichage et d'envoie
    Par alceste dans le forum C++
    Réponses: 21
    Dernier message: 21/06/2006, 14h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo