Position Examples


  • Import the necessary python libraries and modules.

from agribot import Agribot, StubHandler

  • Log in and create an Agribot instance.

bot = Agribot.login("zaxrok@gmail.com", "zeta@1234!")

  • Define a custom handler, CustomHandler, with methods:

    • on_connect: Prints a connection confirmation.

    • on_response: Stays idle on bot response.

    • on_change: Prints bot’s current position and disconnects the bot.

class CustomHandler(StubHandler):
    def on_connect(self, bot, client):
        print("Connected to Agribot")

    def on_response(self, bot, response):
        pass

    def on_change(self, bot, state):
        # 위치 정보 출력
        position = bot.position()
        print("Current position:", position)

        # 연결 종료
        bot.disconnect()

  • Connect the Agribot instance with the CustomHandler instance, resulting in the execution of the defined methods on respective triggers.

handler = CustomHandler()
bot.connect(handler)