Skip to main content

A simple, easy-to-use and powerful library for automating gameplay in the Fruit Craft game through APIs.

Project description

fruitbot

This library lets you use the game's API to automate everything in the Fruitcraft game. Basically, it provides the tools you need to write code that acts like a bot—playing the game for you, handling tasks, fighting battles, managing your tribe, upgrading assets, and more. With it, you can create programs that make the gameplay faster and easier, helping you grow in the game without manual effort.

Quick Start

from fruitbot import Client
from fruitbot.enums import CardPackTypes

bot = Client(session_name="fruit", restore_key="TOUR ACCOUNT RESTORE KEY")

data = bot.loadPlayer(save_session=True)
print(f"name: {data['name']},   amount of gold: {data['gold']},  id: {data['id']}")
print(bot.buyCardPack(CardPackTypes.BROWN_PACK))

Processing Updates

You can utilize the decorators @on_message_update(), @on_player_status_update(), @on_player_status_update(), @on_battle_alert(), @on_battle_update(), @on_auction_update() and @on_tribe_membership_update() to receive and process the updates you need.

To start receiving updates, call the comebackToGame() method and set the open_socket argument to True.

For example:

from fruitbot import Client
from fruitbot.exceptions import OnlineOnAnotherDevice, PlayingOnAnotherDevice
from colorama import Fore
from time import sleep

bot = Client(session_name="fruit", restore_key="YOUR ACCOUNT RESTORE KEY")

try:
    account_name = bot.loadPlayer(save_session=True)["name"]
except (OnlineOnAnotherDevice, PlayingOnAnotherDevice) as e:
    print(e)
    exit()

@bot.on_message_update()
def answerMessage(message: dict):
    if "سلام" in message["text"] and message["sender"] != account_name:
        bot.sendMessageToTribe(f"Hi {message['sender']}")
        sleep(1)
    print(f"{Fore.GREEN}\u202A{message['sender']}:\u202A{Fore.RESET} {message['text']}")

bot.comebackToGame(open_socket=True)
sleep(60)
bot.stopUpdates()

As demonstrated in the previous example, you can use the stopUpdates() method to terminate the reception of updates. Without invoking this method, updates will continue to be received forever, unless an issue arises.

If you ever need a specific update for any reason, @on_special_event() is here to assist you. The only required argument is push_message_type.

@bot.on_special_event("battle_help")
def helpTribemate():
    # your code
    pass

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fruitbot-1.5.0.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fruitbot-1.5.0-py3-none-any.whl (27.6 kB view details)

Uploaded Python 3

File details

Details for the file fruitbot-1.5.0.tar.gz.

File metadata

  • Download URL: fruitbot-1.5.0.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for fruitbot-1.5.0.tar.gz
Algorithm Hash digest
SHA256 aced836ab4e856b9215eec7da929c226880640dd6cbedc62c414b96d2fc4b2a6
MD5 05f1f9cf937f187ba68ccb7ae2b260b8
BLAKE2b-256 f524713fa5ed7af009726e0cfb9fbf813c11ebf34b44f261a333d57e1a0ab742

See more details on using hashes here.

File details

Details for the file fruitbot-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: fruitbot-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 27.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for fruitbot-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9bb063d1e12d3211581741c171c8c9d81459324c063110b27286b5f95111b7bd
MD5 e565a595dcf52c4e3b16a14afe5dc2a0
BLAKE2b-256 9d48221053716677a1ad83eb70adcb2a8c7bcd8a5784bb9a31ccad6bdcdb2aa3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page