impredicative / irc-rss-feed-bot

Dockerized IRC bot to post RSS/Atom and scraped HTML/JSON/CSV feeds to channels
https://hub.docker.com/r/ascensive/irc-rss-feed-bot
GNU Affero General Public License v3.0
28 stars 4 forks source link

AttributeError: 'types.SimpleNamespace' object has no attribute 'nick_casefold' #55

Closed lovelaced closed 4 years ago

lovelaced commented 4 years ago

Hi there, thanks for all your work. I'm attempting to run this via a docker-compose file as suggested in the readme. All permissions on config/secrets seem fine, the bot logs in fine with the configured nick and admin, but nothing seems to work and it prints this exception after successful login. Admin commands also do not work (when I type 'exit' it spits out this exception again).

irc-rss-feed-bot    | Exception in thread Thread-13:
irc-rss-feed-bot    | Traceback (most recent call last):
irc-rss-feed-bot    |   File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
irc-rss-feed-bot    |     self.run()
irc-rss-feed-bot    |   File "/usr/local/lib/python3.8/threading.py", line 870, in run
irc-rss-feed-bot    |     self._target(*self._args, **self._kwargs)
irc-rss-feed-bot    |   File "/app/ircrssfeedbot/bot.py", line 345, in _handle_join
irc-rss-feed-bot    |     if (user.casefold() != config.runtime.nick_casefold) or (channel.casefold() not in config.INSTANCE["channels:casefold"]):
irc-rss-feed-bot    | AttributeError: 'types.SimpleNamespace' object has no attribute 'nick_casefold'

Is this a bug or a misconfiguration somehow on my part? Thanks!

impredicative commented 4 years ago

Would you mind if I see your full non-secret YAML config?

impredicative commented 4 years ago

Basically, .nick_casefold is supposed to be set when processing event 900 (RPL_LOGGEDIN) and by event NICK, both of which are received from the IRC server. I don't know which server you're using, and if it's sending 900.

lovelaced commented 4 years ago

I do get the confirmation in my server buffer that my nick is logged in and authed to my admin account. ("xxx has just authenticated as you")

host: irc.hackint.org
ssl_port: 6697
nick: testbotnick
admin: my!~admin@details
alerts_channel: #testalertchannel
mode: "+igR"
defaults:
  new: all
feeds:
  "#testalertchannel":
    talks:
      url: https://talks.toorcon.net/toorcon21/schedule/feed.xml
      period: 12
      shorten: false
impredicative commented 4 years ago

I'm trying to determine if your server is sending 900 or not. When you start the bot, do you see a message such as the following in its log?

2020-06-23 07:18:00,915 INFO Thread-6-7f80787f8700:ircrssfeedbot.bot:312:_handle_900_loggedin: The client identity as nick>!<user>@<host is News[bot]!News[bot]@unaffiliated/xyz/bot/mybot.

lovelaced commented 4 years ago

Ah, yeah, I don't see anything like that in the logs unfortunately. The last INFO message before it throws the exception is: irc-rss-feed-bot | 2020-06-23 12:14:11,433 INFO MainThread-7f5efdc11740:ircrssfeedbot.bot:102:_log_config: Administrative commands will be accepted as private messages or directed public messages from <mynick>

impredicative commented 4 years ago

Just to be sure, do you strongly prefer to use the current IRC server or would Freenode work for you?

lovelaced commented 4 years ago

Our communities all live on hackint so it's definitely a requirement - it's a pretty large server which supports a lot of the organization of the European hackerspace community and CCC. Maybe its configuration is an edge case that you don't want to have to think about, which is totally OK. :) I don't see any obvious red flags here: https://www.hackint.org/connect

impredicative commented 4 years ago

I will add a simple workaround and update you. If it's not good enough, I'll have to try hackint to see which events it sends.

lovelaced commented 4 years ago

Thank you, I really appreciate it!

impredicative commented 4 years ago

I have released https://github.com/impredicative/irc-rss-feed-bot/releases/tag/0.9.25 . It should finish building in a few minutes.

lovelaced commented 4 years ago

Works great! Thank you again, really appreciated. :)

lovelaced commented 4 years ago

Maybe I spoke too soon; admin commands work properly, but after testing a few different feeds (and one of the samples given in the README.md) I'm getting the following error:

irc-rss-feed-bot    | Traceback (most recent call last):
irc-rss-feed-bot    |   File "/app/ircrssfeedbot/bot.py", line 149, in _msg_channel
irc-rss-feed-bot    |     feed.post()
irc-rss-feed-bot    |   File "/app/ircrssfeedbot/feed.py", line 414, in post
irc-rss-feed-bot    |     msg = entry.message
irc-rss-feed-bot    |   File "/app/ircrssfeedbot/entry.py", line 106, in message
irc-rss-feed-bot    |     format_map = dict(identity=config.runtime.identity, channel=self.feed_reader.channel, feed=_style_name(self.feed_reader.name), url=self.short_url or self.long_url,)
irc-rss-feed-bot    | AttributeError: 'types.SimpleNamespace' object has no attribute 'identity'

Does this have to do with the lack of an asserted identity from the 900 response?

impredicative commented 4 years ago

Does this have to do with the lack of an asserted identity from the 900 response?

Yes. I will have to see which events are sent by hackint, and if any one of them is a substitute for 900.

impredicative commented 4 years ago

Meanwhile, maybe you can ask in their support channel about why 900 is not sent, and if there is any substitute event at sign-on which conveys the identity including the nick.

lovelaced commented 4 years ago

After chatting with an admin, the server is supposed to be sending a 900 (works for them). Most people do base their bots on this. I suspect this has something to do with SASL; I was informed the 900 response should be sent upon correct identification with SASL, and the expected behavior (reproduced by others) is the 900 "you are now logged in as " response, which is normally sent after AUTHENTICATE + but for some reason the first response I get is a 903. I realize this is an external library, but maybe there is something obvious here I'm missing.

<<< :nuke.hackint.org NOTICE * :*** Looking up your hostname...
<<< :nuke.hackint.org NOTICE * :*** Checking Ident
<<< :nuke.hackint.org NOTICE * :*** No Ident response
<<< :nuke.hackint.org NOTICE * :*** Couldn't look up your hostname
<<< :nuke.hackint.org CAP * LS :account-notify away-notify cap-notify chghost extended-join multi-prefix sasl tls userhost-in-names
>>> CAP REQ :away-notify cap-notify sasl chghost
<<< PING :91C82466
>>> PONG :91C82466
<<< :nuke.hackint.org CAP freemedia ACK :away-notify cap-notify sasl chghost
Capability away-notify handled.
Capability cap-notify handled.
>>> AUTHENTICATE PLAIN
Capability chghost handled.
<<< AUTHENTICATE +
>>> AUTHENTICATE <removed>
<<< :nuke.hackint.org 903 freemedia :SASL authentication successful
Capability sasl handled.
>>> CAP END
<<< :nuke.hackint.org 001 freemedia :Welcome to the hackint Internet Relay Chat Network freemedia
impredicative commented 4 years ago

I tried connecting to hackint with a registered nick with the bot. I received event 900 with the correct values and it worked fine.

A few times I also tried abruptly disconnecting and then reconnecting. Sometimes I received an incorrect nick, in which case the bot automatically disconnected and reconnected until the configured nick was received.

I don't know what to do here since it worked for me. I enabled INFO level logging for the 900 event. Previously it was DEBUG level, and so it wasn't being logged. Try release 0.9.26 for this change.

Let's first see if you get 900 logged or not by the bot. If you don't get it logged, ensure that you're using a new user account with no unusual configuration. You can also try from a different ISP or cloud if you need.

lovelaced commented 4 years ago

Thanks for the feedback + your testing. I really appreciate the effort here. We have a happy ending (though I do feel massively stupid): It ends up hackint doesn't send a 900 unless your email is verified (I was unaware it had any technical function beyond password resets). Not sure this is documented anywhere, but moral of the story is: always remember to verify your emails! It may have unintended consequences.

Love the bot and thank you again, keep IRC alive 💖

impredicative commented 4 years ago

Thanks for the update. I have now added a note to the readme noting this email verification requirement.