Conversation
A bot that simply gives hug when sending '.hug'
This just means that it'll respond to other messages with an approximate distance of 2. So “hugable6:”, “hugable:”, etc. will all trigger the bot, you can test that. One thing to keep in mind is that this distance shouldn't be too big, otherwise one command might trigger more than one bot if the nicknames are similar (“gugpable6” – is that greppable or huggable?). To make it deploy automatically on merge you'll need to tweak https://github.com/Raku/whateverable/blob/main/compose.yaml |
|
Cool! Two comments: Raku scripts, if given an extension, are sorta expected to have the .raku extension nowadays. Also, Raku test files nowadays have the .rakutest extension. |
Either all bots need to change the extension or none should use the new extension. There's some logic in |
|
@4zv4l ok, then either leave the .p6 extension. Or if you feel brave, modernize all of the .p6 extensions (possibly in a separate PR?) |
|
Also, the closest bot in terms of functionality is Lines 127 to 145 in 0daa02d (and see some other code around it, too) There's a reason for some of this. For example, in this PR, you only seem to support messages like: But whateverable consistently supports messages like this too: And the new bot could easily also support this: People rarely remember the correct command, so all whateverable bots consistently DWIM. Note that tellable also implements some of the nickname normalization (e.g. |
|
Thanks for all your nice reply ! I'll check to add the support to use the bot name. Not sure about the nickname vs supporting arbitrary string after "hugs", imo the arbitrary string also allows to handle the discord bridge users, so maybe preferred ? Once I've done that, I'll check if I can make another pr to update the extension of the Raku module and test files without breaking everything, happy to contribute with anything my brain is able to produce/handle ! |
Not recommended, as people will be misspelling it as “huggable”, “hugable6”, etc. – the fuzzy name logic was added based on actual usage. A distance of 1 or 2 is fine.
I always thought that it wouldn't reply if it's a direct match of another user, but I couldn't find the code for that, so maybe it wasn't implemented. Still, though, I don't remember of any cases where the user's name was too similar (and there are a lot of bots with different names!).
Discord bridge users are supported anyway. All bots work across the bridge, in fact discord users will be able to use |
xbin/Huggable.p6
Outdated
| #| .hug <nick>... | ||
| method irc-privmsg-channel ($msg where / [\s|^] '.hug' [\s|$] /) { | ||
| my $idx = $msg.text.index('.hug') + 4; | ||
| $.irc.send: :where($msg.channel) :text("hugs" ~ ($msg.text.substr($idx) // "")); |
There was a problem hiding this comment.
What makes that a /me action?
There was a problem hiding this comment.
I think I see what you mean, the bot should reply with a * hugs <nick> ?
But I am not sure how to trigger this instead of a normal message with IRC::Client.
There was a problem hiding this comment.
If you do :text(“\x01ACTION hugs ” ~ $nick ~ “\x01”);, does it work?
xt/Huggable.t
Outdated
|
|
||
| my $t = Huggable.new: bot => ‘Huggable’; | ||
|
|
||
| $t.common-tests: help => ‘Like this: .hug’; |
There was a problem hiding this comment.
Probably needs to show an example of hugging someone
There was a problem hiding this comment.
Is it better now ? I basically took the same as Tellable bot.
xt/Huggable.t
Outdated
| #| .hug <nick> | ||
| $t.test('.hug', | ||
| 'hug', | ||
| 'hugs'); |
There was a problem hiding this comment.
If the nickname was not provided, then I clearly expect a hug for myself. IMO it should hug the sender.
There was a problem hiding this comment.
changed to default hug the sender if no nick is provider 🙏
Help shows how to hug someone with .hug <nick> Rename Huggable.t to match other test files
| #| .hug | ||
| #| .hug <nick>... | ||
| #| hugs the sender if no nick is provided | ||
| method irc-privmsg-channel ($msg where / [\s|^] '.hug' [\s|$] /) { |
There was a problem hiding this comment.
Personally I'd prefer to see it in the regex itself rather than doing the cutting of the string with an index:
Something like:
multi method irc-to-me($msg where { .Str ~~ m:r/^ \s* [.hug \s+]? $<who>=<.&irc-nick> <[:,]>* \s* $/ }) {
“hugs ” ~ $<who>
}
AlexDaniel
left a comment
There was a problem hiding this comment.
I'd prefer the /me action to be figured out, and the regex to use irc-nick and all that, but other than that it's good enough.
|
@4zv4l we're merging this now but feel free to submit more improvements. Thank you! 🤗 |
A bot that simply gives hug when sending '.hug'
It's pretty simple, I tried to follow what I have seen from other bot source file.
Not totally sure if I understand the
selfrunand thefuzzy-nick.Made it after reading this: https://raku.github.io/CCR/Remaster/Zoffix%20Znet/On-Troll-Hugging-Hole-Digging-and-Improving-Open-Source-Communities.html
And realizing that the bot isn't active anymore.
If it is ok to be added, I can also edit the Wiki to add the Huggable entry 🙏