NoMeansNowastaken / KarutaSniper

A bot to automate collecting cards for the discord game Karuta
GNU General Public License v3.0
26 stars 15 forks source link

Running on Linux -> path issues #28

Open Hiroxiom opened 7 months ago

Hiroxiom commented 7 months ago

I'm running the program on an Ubuntu system. But I had to customize the main.py because some paths are not recognized.
I also had to remove "pypiwin32" from the requirements file because it doesn't exist on Linux.

Error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/discord/client.py", line 637, in _run_event
    await coro(*args, **kwargs)
  File "/root/KarutaSniper/main.py", line 130, in on_ready
    await self.update_files()
  File "/root/KarutaSniper/main.py", line 734, in update_files
    with open("keywords\\characters.txt") as ff:
FileNotFoundError: [Errno 2] No such file or directory: 'keywords\\characters.txt'

Fix: Changed lines are: 139-147 From

asyncio.get_event_loop().create_task(self.cooldown())
            asyncio.get_event_loop().create_task(self.filewatch("keywords\\animes.txt"))
            asyncio.get_event_loop().create_task(self.filewatch("keywords\\characters.txt"))
            asyncio.get_event_loop().create_task(
                self.filewatch("keywords\\aniblacklist.txt")
            )
            asyncio.get_event_loop().create_task(
                self.configwatch("config.json")
            )
            asyncio.get_event_loop().create_task(
                self.filewatch("keywords\\charblacklist.txt")
            )

To

asyncio.get_event_loop().create_task(self.filewatch(os.path.join("keywords", "animes.txt")))
asyncio.get_event_loop().create_task(self.filewatch(os.path.join("keywords", "characters.txt")))
asyncio.get_event_loop().create_task(self.filewatch(os.path.join("keywords", "aniblacklist.txt")))
asyncio.get_event_loop().create_task(self.configwatch(os.path.join("config.json")))
asyncio.get_event_loop().create_task(self.filewatch(os.path.join("keywords", "charblacklist.txt")))

Fix: Changed lines are: 746-757 From

async def update_files(self):
        with open("keywords\\characters.txt") as ff:
            self.chars = ff.read().splitlines()

        with open("keywords\\animes.txt") as ff:
            self.animes = ff.read().splitlines()

        with open("keywords\\aniblacklist.txt") as ff:
            self.aniblacklist = ff.read().splitlines()

        with open("keywords\\charblacklist.txt") as ff:
            self.charblacklist = ff.read().splitlines()

To

async def update_files(self):
    with open(os.path.join("keywords", "characters.txt")) as ff:
        self.chars = ff.read().splitlines()

    with open(os.path.join("keywords", "animes.txt")) as ff:
        self.animes = ff.read().splitlines()

    with open(os.path.join("keywords", "aniblacklist.txt")) as ff:
        self.aniblacklist = ff.read().splitlines()

    with open(os.path.join("keywords", "charblacklist.txt")) as ff:
        self.charblacklist = ff.read().splitlines()

Other information: