Script pour sms messaging server

Signaler
Messages postés
7
Date d'inscription
mardi 27 décembre 2011
Statut
Membre
Dernière intervention
8 mars 2012
-
Messages postés
7
Date d'inscription
mardi 27 décembre 2011
Statut
Membre
Dernière intervention
8 mars 2012
-
bonjour,
je viens de m'enregistrer dans votre site que je trouve très cool d'ailleurs.
j'aimerais avoir un script vbs qui me permette de réaliser mon projet.
en effet il s'agit de faire un script qui recois des sms et va dans ma base de donnée acces recupérer la réponse qu'il aura déchifrée du sms :
par exemple si j'en vois "demo maison" le script reconnais le "d" de demo et va chercher le texte qui correspond à demo de la maison et le renvois.
A voir également:

7 réponses

Messages postés
1241
Date d'inscription
mardi 10 octobre 2006
Statut
Membre
Dernière intervention
27 août 2013
5
Bonjour,

j'aimerais avoir un script vbs

Oui et donc tu as commencé à coder quelque chose? où bloques tu exactement?

Attention à la catégorie dans laquelle tu postes vb.net c'est pas vbs, si un admin peut déplacer le post..

L'expérience, c'est une connerie par jour, mais jamais la même..
Messages postés
14723
Date d'inscription
vendredi 14 mars 2003
Statut
Modérateur
Dernière intervention
17 septembre 2020
144
Bonjour,

Quel est exactement ton problème ?
Voir le point 1 de ma signature.

---------------------------------------------------------------------
[list=ordered][*]Pour poser correctement une question et optimiser vos chances d'obtenir des réponses, pensez à lire le règlement CS, ce lien ou encore celui-ci[*]Quand vous postez un code, merci d'utiliser la coloration syntaxique (3ième icône en partant de la droite : )
[*]Si votre problème est résolu (et uniquement si c'est le cas), pensez à mettre "Réponse acceptée" sur le ou les messages qui vous ont aidés./list
---
Mon site
Messages postés
7
Date d'inscription
mardi 27 décembre 2011
Statut
Membre
Dernière intervention
8 mars 2012

ok voici le code de départ

Option Explicit

CONST STR_WEPLAYYOURMUSICDBFILE = "C:\Program Files\ActiveXperts\SMS Messaging Server\Projects\Voting Demo (Music)\Database\WePlayYourMusic.mdb"
CONST STR_DEBUGFILE = "C:\Program Files\ActiveXperts\SMS Messaging Server\Sys\Tmp\WePlayYourMusic.txt"

CONST STR_USAGE = "To send a request, type: Horos . For instance: Vote belier"

Dim g_objMessageDB, g_objDebugger, g_objConstants


' Creation of global objects
Set g_objConstants = CreateObject( "AxMmServer.Constants" )
Set g_objMessageDB = CreateObject( "AxMmServer.MessageDB" )
Set g_objDebugger = CreateObject( "ActiveXperts.VbDebugger" )

' Set Debug file
g_objDebugger.DebugFile = STR_DEBUGFILE
g_objDebugger.Enabled = True





' // ========================================================================
' // ProcessMessage
' // ------------------------------------------------------------------------
' // ProcessMessage trigger function
' // ========================================================================

Function ProcessMessage( numMessageID )
Dim objMessageIn, objMessageOut, arrMessage
Dim strMessageOutBody
Dim numSongID, strCommand

g_objDebugger.WriteLine ">> ProcessMessage"

' Open the Message Database
g_objMessageDB.Open
If( g_objMessageDB.LastError <> 0 ) Then
g_objDebugger.WriteLine "<< ProcessMessage, unable to open database"
Exit Function
End If

' Retrieve the message that has just been received. If it fails then exit script
Set objMessageIn g_objMessageDB.FindFirstMessage( "ID " & numMessageID )
If g_objMessageDB.LastError <> 0 Then
g_objMessageDB.Close
g_objDebugger.WriteLine "<< ProcessMessage, unable to find message"
Exit Function
End If

' Set incoming SMS message status to: SUCCESS (previous state was: PENDING)
objMessageIn.StatusID = g_objConstants.MESSAGESTATUS_SUCCESS
g_objMessageDB.Save objMessageIn
g_objDebugger.WriteLine " Incoming message saved, result: [" & g_objMessageDB.LastError & "]"

' Split received message body into pieces (separated by spaces)
arrMessage = Split( UCase( objMessageIn.Body ), " " )

If( UBound( arrMessage ) = 0 ) Then
' Just 1 param, so ? is expected. But on any other single word, also show help
strMessageOutBody = ShowHelp()
ElseIf( UBound( arrMessage ) = 1 ) Then
strCommand = GetCommand( arrMessage(0) ) ' Converts any word starting with v or V to V
numSongID = GetSongID( arrMessage(1) ) ' Converts string to number, if possible. Also checks range

If( strCommand <> "V" ) Then
strMessageOutBody = ShowWrongParam( arrMessage(0) )
ElseIf( numSongID = 0 ) Then
strMessageOutBody = ShowWrongParam( arrMessage(1) )
Else
strMessageOutBody = UpdateSongRequests( objMessageIn.FromAddress, numSongID )
End If
Else
strMessageOutBody = ShowSyntaxError()
End If

' Create a new reply message
Set objMessageOut = g_objMessageDB.Create
g_objDebugger.WriteLine " New message created, result: [" & g_objMessageDB.LastError & "]"
If( g_objMessageDB.LastError = 0 ) Then
objMessageOut.DirectionID = g_objConstants.MESSAGEDIRECTION_OUT
objMessageOut.TypeID = g_objConstants.MESSAGETYPE_SMS
objMessageOut.StatusID = g_objConstants.MESSAGESTATUS_PENDING
objMessageOut.ToAddress = objMessageIn.FromAddress
objMessageOut.ChannelID = objMessageIn.ChannelID ' Use same channel as used for the incoming message.
objMessageOut.BodyFormatID = objMessageIn.BodyFormatID
objMessageOut.Body = strMessageOutBody
g_objMessageDB.Save objMessageOut
g_objDebugger.WriteLine " New message saved, result: [" & g_objMessageDB.LastError & "]"
End If

' Close the Message Database
g_objMessageDB.Close

g_objDebugger.WriteLine "<< ProcessMessage"
End Function


' // ========================================================================
' // UpdateSongRequests
' // ------------------------------------------------------------------------
' // Update the SongRequests table with the request that was just received
' // ========================================================================
Function UpdateSongRequests( strSenderNumber, numSongID )
On Error Resume Next
Dim objConn, strQuery, RS, hexError, strResult
Dim cnt1, cnt2
Dim strSong

g_objDebugger.WriteLine( ">> UpdateSongRequests( " & strSenderNumber & "," & numSongID & ")" )

' Create database object; open the database
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & STR_WEPLAYYOURMUSICDBFILE & ";"

' Retrieve Song title, to display it later in the reply
' If it does not exist then return with an error
strQuery = "SELECT * FROM SongTitles WHERE ID=" & numSongID
Err.Clear ' Clear a previous error
Set RS = objConn.Execute( strQuery )
hexError = Hex( Err.Number )
If( hexError <> "0" ) Then
g_objDebugger.WriteLine( "<< UpdateSongRequests, Err.Number: " & Err.Number & "; Err.Description: " & Err.Description )
UpdateSongRequests = "Request could not be processed (database error #" & hexError & " occured ). "
objConn.Close
Set objConn = Nothing
Exit Function
End If
If( RS.EOF ) Then
g_objDebugger.WriteLine( "<< UpdateSongRequests, song does not exist" )
UpdateSongRequests = "Request could not be processed (song #" & numSongID & " does not exist). "
objConn.Close
Set objConn = Nothing
Exit Function
End If
strSong = RS( "Artist" ) & "-" & RS( "Title" )
strSong = Trim( strSong )

' Execute INSERT statement
strQuery = "INSERT INTO SongRequests( SmsNumber, DateVal, TimeVal, SongID ) VALUES ( '" & strSenderNumber & "', '" & Date() & "', '" & Time() & "', " & numSongID & " )"
Err.Clear ' Clear a previous error
objConn.Execute( strQuery )

' Catch error - if any
hexError = Hex( Err.Number )
If( hexError <> "0" ) Then
g_objDebugger.WriteLine( "Err.Number: " & Err.Number & "; Err.Description: " & Err.Description )
UpdateSongRequests = "Request could not be processed. "
objConn.Close
Set objConn = Nothing
Exit Function
End If
strResult = "Request successfully processed. "

' Now, calculate #request for this particular song (cnt1) and totla requests(cnt2).
' If both can be calculated then append it to the reponse
cnt1 = 0
cnt2 = 0
strQuery "Select Count(*) As cnt1 FROM SongRequests WHERE SongID " & numSongID
g_objDebugger.WriteLine( strQuery )
Set RS = objConn.Execute( strQuery )
hexError = Hex( Err.Number )
If( hexError = "0" ) Then
cnt1 = RS( "cnt1" )

strQuery = "Select Count(*) As cnt2 FROM SongRequests"
Set RS = objConn.Execute( strQuery )

hexError = Hex( Err.Number )
If( hexError = "0" ) Then
cnt2 = RS( "cnt2" )
strResult = strResult & "#Votes for [" & strSong & "] so far: " & cnt1 & "; #Total Votes (any song) : " & cnt2
End If
End If

objConn.Close
Set objConn = Nothing

UpdateSongRequests = strResult

g_objDebugger.WriteLine( "<< UpdateSongRequests, result: " & UpdateSongRequests )

End Function


' // ========================================================================
' // Show... functions
' // ------------------------------------------------------------------------
' // Some error handling Show errors
' // ========================================================================

Function ShowWrongParam( strParam )
ShowWrongParam = "Wrong parameter: " & strParam
End Function

Function ShowWrongCommand( strCommand )
ShowWrongCommand = "Wrong command: " & strCommand
End Function

Function ShowSyntaxError()
ShowSyntaxError = "Syntax error. " & STR_USAGE
End Function

Function ShowHelp()
ShowHelp = STR_USAGE
End Function


' // ========================================================================
' // GetCommand
' // ------------------------------------------------------------------------
' // Get the command. The only supported command is: Vote (or 'H' or 'H', or
' // anything else that starts with 'h'
' // ========================================================================

Function GetCommand( strCommand )
Dim strUCommand

g_objDebugger.WriteLine( ">> GetCommand ( " & strCommand & " )" )

GetCommand = ""

strUCommand = UCase( strCommand )
If( Left( strUCommand, 1 ) <> "H" ) Then
GetCommand = ""
g_objDebugger.WriteLine( "<< GetCommand, first character is not a 'h' or 'H'" )
Exit Function
End If

GetCommand = "H"

g_objDebugger.WriteLine( "<< GetCommand, return: H" )

End Function


' // ========================================================================
' // GetSongID
' // ------------------------------------------------------------------------
' // Function returns the song ID.
' // If paramter cannot be ocnverted to a number, or if number not in
' // range [1..1000] then 0 is returned
' // ========================================================================

Function GetSongID( strSongID )
On Error Resume Next ' Necessary to catch error because of a non-numeric value

Dim numSongID

g_objDebugger.WriteLine( ">> GetSongID ( " & strSongID & " )" )

numSongID = 0 ' do this because next call may fail upon non-integer
numSongID = CInt( strSongID )
If( numSongID = 0 ) Then
GetSongID = 0
Exit Function
End If

If( numSongID < 1 Or numSongID > 1000 ) Then
GetSongID = 0
Exit Function
End If

GetSongID = numSongID

g_objDebugger.WriteLine( "<< GetSongID, return: " & numSongID )

End Function

mais quand je le teste j'arrive pas à avoir la base de donnée access et les sms n'est pas renvoyé
Messages postés
14723
Date d'inscription
vendredi 14 mars 2003
Statut
Modérateur
Dernière intervention
17 septembre 2020
144
Bonjour,

Bien, et quel est le problème ?
quand tu postes un code, regardes le point 2 de ma signature.

---------------------------------------------------------------------
[list=ordered][*]Pour poser correctement une question et optimiser vos chances d'obtenir des réponses, pensez à lire le règlement CS, ce lien ou encore celui-ci[*]Quand vous postez un code, merci d'utiliser la coloration syntaxique (3ième icône en partant de la droite : )
[*]Si votre problème est résolu (et uniquement si c'est le cas), pensez à mettre "Réponse acceptée" sur le ou les messages qui vous ont aidés./list
---
Mon site
Messages postés
7
Date d'inscription
mardi 27 décembre 2011
Statut
Membre
Dernière intervention
8 mars 2012

EN R2ALIT2 JE VOUDRAIS UN CODE VBSCRIPT QUI ME PERMETTE DE LIRE UN SMS ENTRANT ENSUITE A PARTIR D4UN MOTS CLE CONTENU DANS CE DERNIER, RENVOYER UNE REPONSE A L'EXPEDITEUR.
par exemple : sms envoyé " demo belier" le script reconnait le mot demo et va cherche le texte correspondant à la journée de belier dans la base de données microsoft Access.
Messages postés
7
Date d'inscription
mardi 27 décembre 2011
Statut
Membre
Dernière intervention
8 mars 2012

Option Explicit

CONST STR_WEPLAYYOURMUSICDBFILE = "C:\Program Files\ActiveXperts\SMS Messaging Server\Projects\Voting Demo (Music)\Database\WePlayYourMusic.mdb"
CONST STR_DEBUGFILE = "C:\Program Files\ActiveXperts\SMS Messaging Server\Sys\Tmp\WePlayYourMusic.txt"

CONST STR_USAGE = "To send a request, type: Horos . For instance: Vote belier"

Dim g_objMessageDB, g_objDebugger, g_objConstants


' Creation of global objects
Set g_objConstants = CreateObject( "AxMmServer.Constants" )
Set g_objMessageDB = CreateObject( "AxMmServer.MessageDB" )
Set g_objDebugger = CreateObject( "ActiveXperts.VbDebugger" )

' Set Debug file
g_objDebugger.DebugFile = STR_DEBUGFILE
g_objDebugger.Enabled = True





' // ========================================================================
' // ProcessMessage
' // ------------------------------------------------------------------------
' // ProcessMessage trigger function
' // ========================================================================

Function ProcessMessage( numMessageID )
Dim objMessageIn, objMessageOut, arrMessage
Dim strMessageOutBody
Dim numSongID, strCommand

g_objDebugger.WriteLine ">> ProcessMessage"

' Open the Message Database
g_objMessageDB.Open
If( g_objMessageDB.LastError <> 0 ) Then
g_objDebugger.WriteLine "<< ProcessMessage, unable to open database"
Exit Function
End If

' Retrieve the message that has just been received. If it fails then exit script
Set objMessageIn g_objMessageDB.FindFirstMessage( "ID " & numMessageID )
If g_objMessageDB.LastError <> 0 Then
g_objMessageDB.Close
g_objDebugger.WriteLine "<< ProcessMessage, unable to find message"
Exit Function
End If

' Set incoming SMS message status to: SUCCESS (previous state was: PENDING)
objMessageIn.StatusID = g_objConstants.MESSAGESTATUS_SUCCESS
g_objMessageDB.Save objMessageIn
g_objDebugger.WriteLine " Incoming message saved, result: [" & g_objMessageDB.LastError & "]"

' Split received message body into pieces (separated by spaces)
arrMessage = Split( UCase( objMessageIn.Body ), " " )

If( UBound( arrMessage ) = 0 ) Then
' Just 1 param, so ? is expected. But on any other single word, also show help
strMessageOutBody = ShowHelp()
ElseIf( UBound( arrMessage ) = 1 ) Then
strCommand = GetCommand( arrMessage(0) ) ' Converts any word starting with v or V to V
numSongID = GetSongID( arrMessage(1) ) ' Converts string to number, if possible. Also checks range

If( strCommand <> "V" ) Then
strMessageOutBody = ShowWrongParam( arrMessage(0) )
ElseIf( numSongID = 0 ) Then
strMessageOutBody = ShowWrongParam( arrMessage(1) )
Else
strMessageOutBody = UpdateSongRequests( objMessageIn.FromAddress, numSongID )
End If
Else
strMessageOutBody = ShowSyntaxError()
End If

' Create a new reply message
Set objMessageOut = g_objMessageDB.Create
g_objDebugger.WriteLine " New message created, result: [" & g_objMessageDB.LastError & "]"
If( g_objMessageDB.LastError = 0 ) Then
objMessageOut.DirectionID = g_objConstants.MESSAGEDIRECTION_OUT
objMessageOut.TypeID = g_objConstants.MESSAGETYPE_SMS
objMessageOut.StatusID = g_objConstants.MESSAGESTATUS_PENDING
objMessageOut.ToAddress = objMessageIn.FromAddress
objMessageOut.ChannelID = objMessageIn.ChannelID ' Use same channel as used for the incoming message.
objMessageOut.BodyFormatID = objMessageIn.BodyFormatID
objMessageOut.Body = strMessageOutBody
g_objMessageDB.Save objMessageOut
g_objDebugger.WriteLine " New message saved, result: [" & g_objMessageDB.LastError & "]"
End If

' Close the Message Database
g_objMessageDB.Close

g_objDebugger.WriteLine "<< ProcessMessage"
End Function


' // ========================================================================
' // UpdateSongRequests
' // ------------------------------------------------------------------------
' // Update the SongRequests table with the request that was just received
' // ========================================================================
Function UpdateSongRequests( strSenderNumber, numSongID )
On Error Resume Next
Dim objConn, strQuery, RS, hexError, strResult
Dim cnt1, cnt2
Dim strSong

g_objDebugger.WriteLine( ">> UpdateSongRequests( " & strSenderNumber & "," & numSongID & ")" )

' Create database object; open the database
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & STR_WEPLAYYOURMUSICDBFILE & ";"

' Retrieve Song title, to display it later in the reply
' If it does not exist then return with an error
strQuery = "SELECT * FROM SongTitles WHERE ID=" & numSongID
Err.Clear ' Clear a previous error
Set RS = objConn.Execute( strQuery )
hexError = Hex( Err.Number )
If( hexError <> "0" ) Then
g_objDebugger.WriteLine( "<< UpdateSongRequests, Err.Number: " & Err.Number & "; Err.Description: " & Err.Description )
UpdateSongRequests = "Request could not be processed (database error #" & hexError & " occured ). "
objConn.Close
Set objConn = Nothing
Exit Function
End If
If( RS.EOF ) Then
g_objDebugger.WriteLine( "<< UpdateSongRequests, song does not exist" )
UpdateSongRequests = "Request could not be processed (song #" & numSongID & " does not exist). "
objConn.Close
Set objConn = Nothing
Exit Function
End If
strSong = RS( "Artist" ) & "-" & RS( "Title" )
strSong = Trim( strSong )

' Execute INSERT statement
strQuery = "INSERT INTO SongRequests( SmsNumber, DateVal, TimeVal, SongID ) VALUES ( '" & strSenderNumber & "', '" & Date() & "', '" & Time() & "', " & numSongID & " )"
Err.Clear ' Clear a previous error
objConn.Execute( strQuery )

' Catch error - if any
hexError = Hex( Err.Number )
If( hexError <> "0" ) Then
g_objDebugger.WriteLine( "Err.Number: " & Err.Number & "; Err.Description: " & Err.Description )
UpdateSongRequests = "Request could not be processed. "
objConn.Close
Set objConn = Nothing
Exit Function
End If
strResult = "Request successfully processed. "

' Now, calculate #request for this particular song (cnt1) and totla requests(cnt2).
' If both can be calculated then append it to the reponse
cnt1 = 0
cnt2 = 0
strQuery "Select Count(*) As cnt1 FROM SongRequests WHERE SongID " & numSongID
g_objDebugger.WriteLine( strQuery )
Set RS = objConn.Execute( strQuery )
hexError = Hex( Err.Number )
If( hexError = "0" ) Then
cnt1 = RS( "cnt1" )

strQuery = "Select Count(*) As cnt2 FROM SongRequests"
Set RS = objConn.Execute( strQuery )

hexError = Hex( Err.Number )
If( hexError = "0" ) Then
cnt2 = RS( "cnt2" )
strResult = strResult & "#Votes for [" & strSong & "] so far: " & cnt1 & "; #Total Votes (any song) : " & cnt2
End If
End If

objConn.Close
Set objConn = Nothing

UpdateSongRequests = strResult

g_objDebugger.WriteLine( "<< UpdateSongRequests, result: " & UpdateSongRequests )

End Function


' // ========================================================================
' // Show... functions
' // ------------------------------------------------------------------------
' // Some error handling Show errors
' // ========================================================================

Function ShowWrongParam( strParam )
ShowWrongParam = "Wrong parameter: " & strParam
End Function

Function ShowWrongCommand( strCommand )
ShowWrongCommand = "Wrong command: " & strCommand
End Function

Function ShowSyntaxError()
ShowSyntaxError = "Syntax error. " & STR_USAGE
End Function

Function ShowHelp()
ShowHelp = STR_USAGE
End Function


' // ========================================================================
' // GetCommand
' // ------------------------------------------------------------------------
' // Get the command. The only supported command is: Vote (or 'H' or 'H', or
' // anything else that starts with 'h'
' // ========================================================================

Function GetCommand( strCommand )
Dim strUCommand

g_objDebugger.WriteLine( ">> GetCommand ( " & strCommand & " )" )

GetCommand = ""

strUCommand = UCase( strCommand )
If( Left( strUCommand, 1 ) <> "H" ) Then
GetCommand = ""
g_objDebugger.WriteLine( "<< GetCommand, first character is not a 'h' or 'H'" )
Exit Function
End If

GetCommand = "H"

g_objDebugger.WriteLine( "<< GetCommand, return: H" )

End Function


' // ========================================================================
' // GetSongID
' // ------------------------------------------------------------------------
' // Function returns the song ID.
' // If paramter cannot be ocnverted to a number, or if number not in
' // range [1..1000] then 0 is returned
' // ========================================================================

Function GetSongID( strSongID )
On Error Resume Next ' Necessary to catch error because of a non-numeric value

Dim numSongID

g_objDebugger.WriteLine( ">> GetSongID ( " & strSongID & " )" )

numSongID = 0 ' do this because next call may fail upon non-integer
numSongID = CInt( strSongID )
If( numSongID = 0 ) Then
GetSongID = 0
Exit Function
End If

If( numSongID < 1 Or numSongID > 1000 ) Then
GetSongID = 0
Exit Function
End If

GetSongID = numSongID

g_objDebugger.WriteLine( "<< GetSongID, return: " & numSongID )

End Function 
Messages postés
7
Date d'inscription
mardi 27 décembre 2011
Statut
Membre
Dernière intervention
8 mars 2012

lorsque le code ci dessus est tapé et mis en fonction j'ai pas de message réponse quand j'envois un sms à mon numéro cela est du à quoi ?