Voici comment créer un simple script 'Hello World' dans openBot.
Ce script permet d'importer toute l'api d'Openbot,
Puis d'envoyer une notification 'Hello World' à tous les clients connectés
Et enfin d'écrire le message dans le log d'OpenBot.
4 lignes suffisent en réalité une fois tous les commentaires enlevés
#!/usr/bin/python
# -*- coding: utf-8 -*-
# __name__ is the script running name
# __args__ is an array with the optional script params
from _api import * # do not remove this line!!! it's for import the OpenBot API !!!!
# now, you can start your code here.
# for sending notify to all socket client connected
launch({"function":"socket_server.send", "name":__name__, "message":"Hello World!"})
# for writing a message in the OpenBot log files
# first parameter is your string message, the second parameter is an integer
# defining the level of log debug, 0 for error, 1 for warning, 2 for information
# by default OpenBot is configured to only write error messages.
# see file '/home/pi/python/settings/openbot.conf' or '\\openbot\back-end\settings\openbot.conf' option 'DEBUG_LEVEL' for details
# log files are writed in '/home/pi/python/log/' or '\\openbot\back-end\log\'
self.api_log.write("Hello World!", 0) # this write your message in each case in the OpenBot log file.Voici ce que ça donne sans les commentaires:
#!/usr/bin/python
from _api import *
launch({"function":"socket_server.send", "name":__name__, "message":"Hello World!"})
self.api_log.write("Hello World!", 0) # this write your message in each case in the OpenBot log file.le fichier complet est disponible via le lien ci-dessous:
http://www.ms-robot.com/%5Bdoc%5D/api/e ... oworld.rar