archangelic / pinhook

the pluggable python framework for IRC bots and Twitch bots
https://archangelic.github.io/pinhook/
MIT License
31 stars 4 forks source link

AttributeError: 'TwitchBot' object has no attribute 'log_file' #73

Closed ghost closed 4 years ago

ghost commented 4 years ago

Using the following code:

bot = TwitchBot(
    nickname="pyllybot",
    channel="#siinacutie",
    token=secret
).start()

I receive the error:

Traceback (most recent call last):
  File "./pyllybot.py", line 18, in <module>
    bot = TwitchBot(
  File "/opt/virtual_env/pyllybot/lib/python3.8/site-packages/pinhook/bot.py", line 319, in __init__
    self.start_logging()
  File "/opt/virtual_env/pyllybot/lib/python3.8/site-packages/pinhook/bot.py", line 82, in start_logging
    if self.log_file:
AttributeError: 'TwitchBot' object has no attribute 'log_file'
ghost commented 4 years ago

I'm presently cloning pinhook to see why this happens, but my current workaround is:

class Bot(TwitchBot):
    log_file = "bot.log"
    def __init__(self, nickname, channel, token):
        TwitchBot.__init__(self, nickname=nickname, channel=channel, token=token)

bot = Bot(
    nickname="pyllybot",
    channel="#siinacutie",
    token=secret
).start()

A bit off-topic, but I must also add self.cmd_prefix or it crashes when someone chats.

archangelic commented 4 years ago

I have made significant changes to the base bot and utterly neglected TwithBot so I will need to go in and add these.

archangelic commented 4 years ago

@SiinaCutie I have created the twitch_fix branch to bring things up to parity (PR #74)

Try this out and see if it works for you!

ghost commented 4 years ago

Works perfectly, thanks!

archangelic commented 4 years ago

Fixed in 1.9.3