mattmakai / fullstackpython.com

Full Stack Python source with Pelican, Bootstrap and Markdown.
https://www.fullstackpython.com/
MIT License
2.88k stars 627 forks source link

Slackbot receiving links #150

Closed idenkov closed 6 years ago

idenkov commented 6 years ago

Hi Matt,

Thanks for the tutorial! I am just getting started with python and decided doing it with a bot it could be interesting.

One problem I stumbled upon is that the function parse_direct_mention don't match if the message contains valid FQDN - slack transforms them into links and the input is something like this <https://google.com|google.com>

Can you help with direction how to solve it?

mattmakai commented 6 years ago

hey @aoberoi, any idea on this potential parse_direction_mention URL handling quirk?

aoberoi commented 6 years ago

At a glance, I don’t see why the regex used wouldn’t work. But maybe I’m missing something. I’ll try to reproduce this soon.

idenkov commented 6 years ago

Had a little bit of time today and it looks like when you sent this: @BOT google.com it receives U4W3MKHKQ> ssh <http://google.com|google.com and normal messages looks like that

U4W3MKHKQ 
hi

Looks like it tries to remove the leading < and the last > from the return of that function. So the thing that removes < and > from the bot id, actually removes them from the whole message.

aoberoi commented 6 years ago

@idenkov good detective work! i'll try to reproduce this now.

aoberoi commented 6 years ago

I think i figured it out, all we have to do is modify the regular expression. we just need to make the + non-greedy by changing it to +?. I'll send some PRs.

aoberoi commented 6 years ago

@mattmakai please also merge https://github.com/mattmakai/slack-starterbot/pull/9 when you get a chance.

mattmakai commented 6 years ago

thanks again @aoberoi, this is now merged and live. @idenkov everything work well on your end now?

idenkov commented 6 years ago

Thanks, yep it works kind of lame took that bot id match for granted and didn't even think about it.