dominikh changed the topic of #cinch to: The IRC Framework | Latest version: Cinch 2.1.0
djbkd has quit [Remote host closed the connection]
Azure has quit [Read error: Connection reset by peer]
Azure has joined #cinch
hobo has joined #cinch
<hobo>
hi, how do i use cinch to send priv msgs?
<leftylink>
User('hobo').send('a message')
<hobo>
thanks leftylink
FIQ has quit [Ping timeout: 252 seconds]
hobo has quit [*.net *.split]
CM-Punk has quit [*.net *.split]
dominikh has quit [*.net *.split]
hobo has joined #cinch
<hobo>
so if i'm writing a plugin for cinch, and i want to match for a command, is it possible to match that command again?
<hobo>
like if my command is !privmsg user message, i want to check for the privmsg in the message object
FredrIQ has joined #cinch
dominikh has joined #cinch
CM-Punk has joined #cinch
FredrIQ is now known as FIQ
FIQ has quit [Excess Flood]
<hobo>
hm nvm i dont think it's possible
Guest70999 has joined #cinch
hobo has left #cinch [#cinch]
Spami has joined #cinch
Spami__ has joined #cinch
Azure has quit [Quit: My MBP went to sleep.]
postmodern has quit [Quit: Leaving]
Edelwin has joined #cinch
<Edelwin>
\o
thews has quit [Ping timeout: 272 seconds]
thews has joined #cinch
thews has joined #cinch
<Gizmokid2005>
\2 questions. 1) Is there a user attribute or method that will return whether or not the user is an op on a channel?
<dominikh>
Channel#op?, pass in the user object
<dominikh>
or #opped?, I don't remember the exact name
<Gizmokid2005>
2) what's the best way to verify that a user is auth'd and is currently the correct user to allow "admin" commands? I see there's an authed? method, as well as authname attribute
<Gizmokid2005>
Humm...I was looking at user, not channel.
<Gizmokid2005>
that makes more sense.
<Gizmokid2005>
looks like it's opped? - thanks for that one dominikh
<dominikh>
if the IRC network supports authentication, (quakenet, freenode, anything modern with nickserv), #authed? will tell you whether the user is authenticated, and #authname will tell you with what name he is authenticated. so yeah, that name can be used to bind permissions to.
<dominikh>
if you accept commands in a private message to the bot, make sure to User#refresh, to invalidate cached information between commands. if you only accept commands in channels, the bot will already notice quits/parts/authentication changes and update the cache appropriately
<Gizmokid2005>
being that I'm not actually checking whether or not things are a pm or channel message, I suppose I should just make habit of User#refresh then
<Gizmokid2005>
since these checks are in a helper method on their own.
<Gizmokid2005>
But I should be using both, check whether they're authed with authed? and then validate against the authname
<dominikh>
do note that every #refresh causes a WHOIS to be sent to the server
<dominikh>
so it's not ideal if you receive a high amount of commands
<Gizmokid2005>
Hmm, so I should pass whether or not it's a channel and if not to just do the refresh then...
<dominikh>
would be an idea
<Gizmokid2005>
any other suggestions for that which would fit better with cinch's abilities?
<dominikh>
Gizmokid2005: well no, that's really your option there
<Gizmokid2005>
that's fair enough. I'm trying to get a good feel for both finch and some more advanced Ruby stuff at the same time so I figure it's best to ask lest I do it a "bad" way to start :)
<Gizmokid2005>
...*cinc*
<Gizmokid2005>
*sigh* cinch....which I'm loving by the way.
<dominikh>
if you were my girlfriend, I'd be wondering why you're screaming the names of other men...
<Gizmokid2005>
haha. Call it becoming mindless is the throes of euphoria.
<dominikh>
anyway, yeah, you wouldn't want to get the authentication stuff wrong
<Gizmokid2005>
exactly. I'm trying to be careful with it, but the more I think about it the more I come up with that I need to watch for.
<Gizmokid2005>
could you take a look at this snipped of my bot and direct me to how I'm (seemingly obvious but I'm being oblivous to) failing with the user.authed? check? https://gist.github.com/Gizmokid2005/49239adee54b301f6e50
<dominikh>
first of general Ruby: "true if foo" == "foo"
<Gizmokid2005>
That's what I was thinking as well, and I could be derping. it's just weird that the check worked without the user.authed? added to it
<Gizmokid2005>
but it might be the way it's just handling the single check?
<dominikh>
no.
<dominikh>
line 38 is bollocks tho
<dominikh>
is_admin? expects a User object, you're giving it an authname, a string.
<Gizmokid2005>
ohhey...so I am
<Gizmokid2005>
let me just take care of that right now...
<Gizmokid2005>
That felt odd last night in my late hours of coding...
<Gizmokid2005>
thanks dominikh. pulling .authname from line 38 and doing this in the helpers: true if $alladmins.include?(user.authname.to_s) && user.authed? == true -- seems to have done what I was aiming for.
<dominikh>
still, drop the "true if" part. saying "true if true" is the same as saying "true", and saying "true if false" is the same as saying "false". ergo "true if x" is the same as "x"
<Gizmokid2005>
ahh, right.
<Gizmokid2005>
no need to be redundant...
<dominikh>
right
<Gizmokid2005>
though, if I do that I have to break it into a full if..then?
<Gizmokid2005>
or am I misunderstanding how ruby handles that?
<dominikh>
why?
<dominikh>
a method's return value is that of the last expression
<dominikh>
def foo; 1; end returns 1. def foo; some && boolean || expression; end returns the value of that expression.
<dominikh>
an explicit way of saying the same would be def foo; return boolean && expression; end – but the "return" keyword can be ommitted
<dominikh>
this is entirely unrelated to postfix if though
<Gizmokid2005>
Ah, right. Makes more sense. Thanks dominikh. I was forgetting about not needing 'if' as well
Guest70999 has quit [Changing host]
Guest70999 has joined #cinch
Guest70999 is now known as FIQ
djbkd has joined #cinch
djbkd has quit [Remote host closed the connection]
Spami has quit [Quit: This computer has gone to sleep]
Spami__ has quit [Quit: This computer has gone to sleep]
<Gizmokid2005>
This may be a super stupid question, but how can I ensure that my helper methods from my main file are accessbile in my plugins?
<dominikh>
don't define them in the helper block, to begin with. you shouldn't be mixing that DSL and the plugin API
<Gizmokid2005>
so far I've only accessed them from the main bot, but now I need to add functionality that is available in the plugins too. If I dump them out of the helper block it should then function as desired, no?
<dominikh>
yea
djbkd has joined #cinch
<Gizmokid2005>
The defs should just need to be defined inside the bot block correct? bot = Cinch::Bot.new do
<dominikh>
no. on the global level. or, if you want neat code, define them as module methods in a module.
<Gizmokid2005>
a module sounds much better.
<Gizmokid2005>
I'm sorry if these questions are inane
<dominikh>
I've had worse
djbkd has quit [Remote host closed the connection]
<Gizmokid2005>
:) thanks
<Gizmokid2005>
are there any examples of a helper module I could piggy-back from?
<dominikh>
module MyStuff; def self.some_method; ...; end; end
djbkd has joined #cinch
<dominikh>
or without the self. if you want to mix it in, of course
<Gizmokid2005>
and then just require/require_relative like plugins?
<dominikh>
practically, sure. technically, it only needs to be required once, before requiring the plugins
<Gizmokid2005>
right, so I could require it in the same spot that I'm requiring the gems
<Gizmokid2005>
if I understand correctly
<dominikh>
yea
<Gizmokid2005>
neato
<Gizmokid2005>
No need for module Cinch?
<dominikh>
no.
<Gizmokid2005>
Is this all I need to load them into the bot? require_relative 'customhelpers'
<Gizmokid2005>
if this is the module: module CustomHelpers
<dominikh>
if the path is correct, yes.
<Gizmokid2005>
and file is customhelpers.rb
<Gizmokid2005>
well it definitely doesn't complain about a missing file when I run it
<Gizmokid2005>
but I don't know any other way to verify
<dominikh>
then it works.
<Gizmokid2005>
I didn't quite understand your comment about self, but with or without self. prepending my methods I keep getting an undefined method error for them.