GithubHelp home page GithubHelp logo

Comments (8)

BlueKossa avatar BlueKossa commented on June 6, 2024 4

Create a file called run.sh (or something else) with this in it

#!/bin/sh
while true
do python3 ./main.py
done

then to run it, sh ./run.sh

from capsulefarmerevolved.

CptPICHU avatar CptPICHU commented on June 6, 2024 3

Please we need this Poro. I also missed drops because of it. I'd suggest doing it like this:
If the program recovery fails, wait 10 minutes to try again. That would be a nice solution!

from capsulefarmerevolved.

LeagueOfPoro avatar LeagueOfPoro commented on June 6, 2024 2

It does automatically restart three times. However, after three unsuccessful recovery attempts it shuts itself off to prevent account/IP blocking.

from capsulefarmerevolved.

Ares902 avatar Ares902 commented on June 6, 2024 1

I'm using this script to check whether CapsuleFarmer is running or not. I run it on Windows, but this could be modified to work on other systems too. Feel free to use it:

import os
import win32gui
import time

class Restart:

    def check_program_running(program_name):
        def callback(hwnd, hwnds):
            if win32gui.IsWindowVisible(hwnd) and win32gui.GetWindowText(hwnd) != '':
                hwnds.append(hwnd)
            return True

        hwnds = []
        win32gui.EnumWindows(callback, hwnds)

        for hwnd in hwnds:
            if program_name in win32gui.GetWindowText(hwnd):
                return True
        return False

    def start_program(program_path, start_dir):
        try:
            os.chdir(start_dir)
            os.startfile(program_path)
            print(f"{time.ctime()} Started program: {program_path}")
        except:
            print(f"{time.ctime()} Could not start program: " + program_path)

    program_name = "CapsuleFarmerEvolved.exe"
    start_dir = os.path.dirname(os.path.abspath(__file__))
    program_path = start_dir + "\\" + program_name
    check_interval = 600 # in seconds

    while True:
        if not check_program_running(program_name):
            print(f"{time.ctime()} Program not running. Starting now...")
            start_program(program_path, start_dir)
        else:
            print(f"{time.ctime()} Program running.")
        time.sleep(check_interval)

Has to be in the same folder as the CapsuleFarmer, or change the start_dir variable to wherever the .exe or the main.py is.

In case you are not using the exe you also have to change the program_name variable to main.py

from capsulefarmerevolved.

IttsGod avatar IttsGod commented on June 6, 2024

Temporary workaround is:

create a textfile in the directory with the CapsuleFarmer.exe
open the textfile and write in it:

:1
CapsuleFarmerEvolved.exe
goto 1

save and rename the file ending to .bat instead of .txt

if you run the file now, it should restart itself after crashing

from capsulefarmerevolved.

steffenhengst avatar steffenhengst commented on June 6, 2024

Thank you for the answer. Enquiry about this.
You always talk about an .exe. My bot is running on my RPI 4 and strong the bot via the python main.py. Would that also work with it?

from capsulefarmerevolved.

IttsGod avatar IttsGod commented on June 6, 2024

Sorry, thought u were using the EXE on Windows
Im running it on my Raspberry Pi 3 too, but on Docker which with the commands in the Readme already auto restarts it

from capsulefarmerevolved.

kalinzange avatar kalinzange commented on June 6, 2024

I'm using this script to check whether CapsuleFarmer is running or not. I run it on Windows, but this could be modified to work on other systems too. Feel free to use it:

import os
import win32gui
import time

class Restart:

    def check_program_running(program_name):
        def callback(hwnd, hwnds):
            if win32gui.IsWindowVisible(hwnd) and win32gui.GetWindowText(hwnd) != '':
                hwnds.append(hwnd)
            return True

        hwnds = []
        win32gui.EnumWindows(callback, hwnds)

        for hwnd in hwnds:
            if program_name in win32gui.GetWindowText(hwnd):
                return True
        return False

    def start_program(program_path, start_dir):
        try:
            os.chdir(start_dir)
            os.startfile(program_path)
            print(f"{time.ctime()} Started program: {program_path}")
        except:
            print(f"{time.ctime()} Could not start program: " + program_path)

    program_name = "CapsuleFarmerEvolved.exe"
    start_dir = os.path.dirname(os.path.abspath(__file__))
    program_path = start_dir + "\\" + program_name
    check_interval = 600 # in seconds

    while True:
        if not check_program_running(program_name):
            print(f"{time.ctime()} Program not running. Starting now...")
            start_program(program_path, start_dir)
        else:
            print(f"{time.ctime()} Program running.")
        time.sleep(check_interval)

Has to be in the same folder as the CapsuleFarmer, or change the start_dir variable to wherever the .exe or the main.py is.

In case you are not using the exe you also have to change the program_name variable to main.py

For All Who want to use this:
It's required Python and pywin32 Library (pip install pywin32) installed on your computer.

from capsulefarmerevolved.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.