<CM-Punk>
http://pastebin.com/C7d5Yv9Q I need help with this. When I attempt to use the command it doesn't work properly. It only sends the first word of the command to nickserv...
Azure_ has joined #cinch
Azure_ is now known as Azure
<onewheelskyward>
Have you tried inspecting text before its sent?
<CM-Punk>
Pardon? I'm sorry, I don't know what tht means. :P
<onewheelskyward>
If you have a debugger, put a breakpoint before the nickserv send. If not, add puts text.inspect and make sure it contains what you think it does.
<dominikh>
it'd help more if we knew the actual regexp used.
<CM-Punk>
Sorry dominikh, I thought I included it, but I didn't. Here: match /ns (.+?) (.+)/, method: :execute_ns
<dominikh>
your method takes two arguments, one message, one capture group. your regexp has two capture groups.
<dominikh>
the first capture group will match up to the first space character
<dominikh>
the second capture group, which you throw away, will match the rest
<CM-Punk>
Oh that makes sense
<CM-Punk>
So I should have one capture group, that looks like this: (.+)
<dominikh>
a) these if on line 6 will never match. the keys are User objects, not strings
<catepillar>
2. if using a regex, add the //i option
<dominikh>
b) Channel(m.channel) == m.channel
<dominikh>
c) m.channel.users.has_key?(User(user))
<dominikh>
well, or a ! before that to negate it
<dominikh>
d) for the love of formatting, fix your indentation
<catepillar>
lol
<catepillar>
i was wondering why there were no method delcarations, and just thought they had accidently been removed when trimming it down for pastebin
<CM-Punk>
On line six it's checking if the target user is in the channel
<dominikh>
doesn't change anything of what I just said.
<dominikh>
either way, see my c) again. it's not just cleaner, it solves your problem of case sensitivity. line 10 will be analogous, User(user) == m.user
<CM-Punk>
Okay
<CM-Punk>
So changing these things will fix case sensitivity?
<dominikh>
yes
<CM-Punk>
Okay, thanks dominikh
<dominikh>
matter of fact, though, the include? one probably already was case insensitive. I hate the code I've written :)
<dominikh>
!eval User("dominikh") == "dominikh"
<Cinchy>
true
<dominikh>
whoever coded that (me) is an idiot
<CM-Punk>
What about line two
<onewheelskyward>
Ah, past self code. Been there.
<CM-Punk>
That's case sensitive too
<dominikh>
onewheelskyward: past believes, really. it seemed like a great idea to allow every conceivable combination
<onewheelskyward>
I could see the case for that.
<dominikh>
CM-Punk: as I said, User(user) == m.user instead of user == m.user.nick – you will always want to compare actual User objects, not their nicks
<dominikh>
onewheelskyward: yeah, that case is confusing people :)
<onewheelskyward>
heh.
<dominikh>
onewheelskyward: I think the moment when you don't get why an array full of User objects returns true for #include?(some_string) is a good moment to regret your choices
<onewheelskyward>
yeah that string thing is a little non-deterministic
<onewheelskyward>
Like, I'm not sure what to expect from it
<catepillar>
!eval User("catepillar").nick
<catepillar>
:(
<onewheelskyward>
Object to object collection? Sure.
<dominikh>
to be fair, I spent the last 1.5 years in a statically typed language, so I'm biased towards that nowadays
<dominikh>
catepillar: it's not sandboxed, ergo only I can use it
<catepillar>
i figured as much
<CM-Punk>
Okay well
<CM-Punk>
Is there any way to parse the user argument back down to a user object?
<CM-Punk>
Uhm...for example I say
<CM-Punk>
~slap DOMINIKH
<dominikh>
I showed you how to do that three times in the last 10 minutes :)
<CM-Punk>
No
<CM-Punk>
For the response
leftylink has joined #cinch
<CM-Punk>
Just hear me out pls :P
<dominikh>
...
<dominikh>
go ahead.
<CM-Punk>
So I say ~flower DOMINIKH or something like that
<CM-Punk>
I want the bot to respond with
* CM-Punk
gives dominikh a flower
<CM-Punk>
not
* CM-Punk
gives DOMINIKH a flower
<dominikh>
!eval User("DOMINIKH").nick
<Cinchy>
"dominikh"
<catepillar>
seems about right
<catepillar>
that's what *should* happen
<CM-Punk>
Right, I know the code recognizes it....
<CM-Punk>
Here, hold on
Keli has joined #cinch
<CM-Punk>
Okay this is the code you helped me with, just nao
<CM-Punk>
~revive DOMINIKH
* Keli
throws a Phoenix Down on DOMINIKH, effectively reviving them!
<dominikh>
onewheelskyward: well, there are several solutions, but none of which would allow me to manipulate the bot's state ;)
<onewheelskyward>
Right.
<dominikh>
sandboxing for the purpose of executing untrusted code? Dia on OS X, or some container solution (docker et al) for Linux
<CM-Punk>
By the way dominikh, your Plugin Management plugin has been a life saver
<dominikh>
yeah, it's pretty neat
<CM-Punk>
I don't have to keep shutting down my bot to change things in the code
<CM-Punk>
So, thank you so much, I am learning :D
<onewheelskyward>
oh, what's that all about?
<leftylink>
I wanted to make it so that with one line similar to match /blahblah/, :method => :blahblah I can have the bot respond to "!blahblah" publicly, "blahblah" privately, and "botsnick: blahblah" publicly
<Cinchy>
[gist] multiple matchers in one (at gist.github.com, leftylink on 2014-02-03 20:34)
<leftylink>
seem reasonable?
<CM-Punk>
onewheelskyward, who?
<onewheelskyward>
Plugin management.
<dominikh>
leftylink: almost reasonable – even though I'd probably #dup the args hash for every method call. I don't know if anything stores the hashes you pass in
<dominikh>
or if we'll ever do.
<leftylink>
ah
<leftylink>
it currently works because code currently uses values_at but can't hurt to do that for future proofing
<dominikh>
yeah
<dominikh>
it'd also be the sort of bug you'd never find
<CM-Punk>
Then it never uses a function that uses "check_user" again until I restart it
<leftylink>
hmm, what if i were to take my thing a step further
<leftylink>
I want to use the xmatch across multiple plugins, but without having to paste that code into each plugin. do I make something in the style of Cinch::Plugin that can be included in and that contains xmatch?
<dominikh>
that'd be the cleanest approach
<leftylink>
all right
<onewheelskyward>
I've been getting closer with plugin unit testing.
<onewheelskyward>
All it's required so far is a complete refactor. :)
<dominikh>
of your plugins or of cinch?
<CM-Punk>
heh
<CM-Punk>
So dominikh, other than the misplaced
<leftylink>
oh plugin testing
<leftylink>
I considered cinch-test
<leftylink>
but I just kinda rolled my own
<dominikh>
fwiw, Cinch itself has no test suite, and I'm not a big tester, so yeah… no idea how easily plugins are tested
<leftylink>
it was not too terrible
<leftylink>
created fake Message, User, Channel classes
<leftylink>
use rspec to stub out various functions in Cinch::Bot and the plugin
<dominikh>
so in essence you mocked/stubbed most of cinch