Viewing 1 reply thread
  • Author
    Posts
    • #4758
      lecagnois
      Participant

      Matériel nécessaire :
      Un raspberry configuré en serveur (deja fais si vous avais suivi le tuto pour la domotique)

      Il vous faut donc :
      1) créer la procédure dans le programme INMOOV-AI_startup.py
      2) créer un fichier aiml dans le répertoire rachel ou modifier messenger.aiml
      3) créer un fichier php sur votre serveur raspberry

      Voici le Fichier Python

      def Mailsend(amis):
           try:
               # adresse ip de votre serveur raspeberry
               u = os.popen("ping -n 1 192.168.1.27")
               result = u.read()
               if result.count("perte 0") == 1 and result.count("Impossible") == 0:
                    talk(amis)
                    # création d un dictionnaire des amis
                    dico = {"jean-pierre":"xxxxxxx@wanadoo.fr" , "colette":"xxxxxxx@wanadoo.fr"}
                    # message si pas trouvé
                    if (dico.get(amis) == None):
                       print("Amis inconnu dans l annuaire")
                       talk("personne inconnu au bataillon")
                    else:
                       print (dico.get(amis))
                       talk(" fais parti de tes amis , je lui envoie un mot")
                       var1= (dico.get(amis))
                       var2= "Votre robot INMOOV vous souhaire\n une bonne journee"
                       url = ('http://192.168.1.27/mailsend.php?var1=%s&var2=%s' %(var1, var2))
                       urllib.urlopen(url)
               else:
                   talk("désolé le serveur est éteint , allumé votre serveur.")
      
           except IOError:
              talk("désolé le serveur est éteint , mail non transmis")
              

      Voici le Fichier PHP (sendmail.php)

      <?php
           
           $subject = 'programmation Inmoov';
           $message = 'Bonjour !';
           $headers = 'From: webmaster@example.com' . "\r\n" .
           'Reply-To: webmaster@example.com' . "\r\n" .
           'X-Mailer: PHP/' . phpversion();
      
           mail( $_GET['var1'], $subject, $_GET['var2'], $headers);
       ?>
      

      Voici le fichier AIML

      <category>
            <pattern>ENVOYER UN MAIL À *</pattern>
            <template>
      		<think><set name="destinataire"><star/></set></think>
      			<oob>
      				<mrl>
      				   <service>python</service>
      				   <method>exec</method>
      				   <param>Mailsend("<get name="destinataire"/>")</param>
      				 </mrl>
      			</oob>
      			
         	</template>
          </category>
      • This topic was modified 7 years, 8 months ago by lecagnois.
    • #4760
      lecagnois
      Participant

      NOTA :

      Votre Raspberry doit être configurer en serveur SSMTP

      ci joint un tuto pour le configurer :
      https://www.fanjoe.be/?p=1345

Viewing 1 reply thread
  • You must be logged in to reply to this topic.