<dyoung522>
implemented that tonight, as a test. Works great. It will store any object you want in the value (serialized via YAML)
<dyoung522>
may not need the initialize method either... but I'm too tired to test it without at this point. I'm heading to bed. =)
<dominikh>
#exists? – why not #has_key? like hashes, if you're already emulating a basic kv store
<dyoung522>
you can do that too
<dominikh>
anyway, will it be a dumb kv store?
<dyoung522>
maybe. hmm. I'll have to verify that, but that's a good point. I'll check it.
<dyoung522>
dumb as in?
<dominikh>
dumb as in being a kv store ;)
<dominikh>
no way to e.g. make use of advanced queries (think filter)
<dyoung522>
that was the point, to be a simple kv store. But the value can be any object you want, including classes, and it will persist (via database)
<dominikh>
okay. that was the initial idea for Cinch's storage API that I dropped ;)
<dyoung522>
you can all #db on the object directly and use Sequels data methods
<dominikh>
not that I still care at this point, in 2 years I haven't managed to come up with an alternative
<dyoung522>
I think for this use, kv works great.
<dominikh>
well, if I write a plugin, I don't know what storage backend the user uses
<dominikh>
so I can't just assume Sequel
<dyoung522>
I'm thinking user lists and configuration storage
<dyoung522>
that's why it defaults to using sqlite (via Sequel)
<dyoung522>
so, the defaults will work fine for most users.
<dyoung522>
they don't even need to know or care about the backend. But if they want to, they have full access.
<dominikh>
yeah but that is the point. as soon as they make use of that access, shit will explode if the backend changes
<dyoung522>
the idea was to be as simple and easy as possible. hence, kv
<dominikh>
if I distribute a plugin that relies on there being Sequel, and the user doesn't use Sequel, shit explodes
<dyoung522>
Sequel is just a gem.
<dyoung522>
it's not reliant on anything but the sequel gem and sqlite3. If they *want* to use MySQL or Postgres for the data store, they carn.
<dyoung522>
*can
<dominikh>
I don't think you're getting my point.
<dyoung522>
you don't like being dependent on other gems
<dominikh>
if the plugin has access to the underlying storage object, like the sequel db, and it makes use of it, you no longer have an abstract storage api that allows transparently changing the backend
<dominikh>
I don't care about being dependant on other gems
<dominikh>
I'm saying the API is too lax
<dyoung522>
I don't think you understand. Sequel is just an O/RM
<dominikh>
dude, I know what Sequel is
<dyoung522>
then what are we relying on?
<dyoung522>
if, out of the box, we give them everything they need... no extra configuration or special local env. I don't see what the problem is?
<dyoung522>
it's not dependent on anything but two gems.
<dominikh>
so, I write a plugin. for some reason I use #db and expect access to sequel's data methods. I distribute that plugin. some other user doesn't actually use sequel, because hey, it's a transparent storage API and I prefer YAML
<dominikh>
the plugin doesn't work.
<dominikh>
the point of a storage API is to not expose the backend to the plugin.
<dyoung522>
oh, well yea #db isn't recommended or even in the docs
<dyoung522>
it's just there for power-users
<dyoung522>
99% of the users will use the interface as-is
<dominikh>
(a power user wouldn't use an undocumented method since it's not part of the contract)
<dyoung522>
then no worries, right?
<dyoung522>
I can alwasys remove the #db method. It's not necessary for functionality
<dyoung522>
(at least not the API)
<dominikh>
yeah, I don't think it should be in there, if you're going for backend agnostic storage API
<dyoung522>
for 99% of the users, the simple "storage[key] = value" is all they need to know.
<dominikh>
and I'm saying make it 100% ;)
<dyoung522>
sure, I'm not married to it.
<dominikh>
either stand behind your API or don't, don't sneak in a #db so the fat goth chick will like you
<dyoung522>
heh
<dyoung522>
heavens no
<dyoung522>
no sneaking about it... it's already there in the backend, exposing it to the interface wasn't a big deal.
<dyoung522>
it's just a class variable.
<dyoung522>
but, sure, removing it isn't a big deal.
<dominikh>
ok
<dyoung522>
in fact, I only mentioned it because you said you wanted more low-level access to the data in the first place. lol
<dyoung522>
or, more filter-like syntax (I think is more what you said)
<dyoung522>
anyway. I'm going to bed.
<dominikh>
no, I was asking if there were plans for an public API to allow that
<dyoung522>
and I'm pretty sure #has_key? works (via method_missing)
<dominikh>
in the end you'll want to write an API that every backend has to implement to support the storage API
<dominikh>
as in, #[], #[]=, #has_key? and whatever else you've got
<dyoung522>
yeah
<dominikh>
that is, define an interface
<dyoung522>
haven't even really started on the API docs yet
<dyoung522>
still fleshing itout
<dominikh>
yeah, just saying
<dyoung522>
I hear ya, yeah.
<dyoung522>
do you see any issue with serializing data through YAML?
<dyoung522>
I know there's been a recent exploit with it.
<dominikh>
not if you lock properly to avoid writing broken files.
<dyoung522>
not writing any files... all strings written to the database
<dominikh>
ah, yeah, nvm
<dominikh>
there used to be a YAML backend :)
<dominikh>
you'd have to look into the exploit itself, I don't remember the details
<dyoung522>
apparently you could run arbitrary code during import... but since the back-end data isn't exposed anyway, I don't see that being a problem.
<dominikh>
depends what user input can do with the objects
<dyoung522>
but will need to investigate for sure
<dominikh>
there's always JSON
<dyoung522>
maybe put a wrapper around it if necessary
<dyoung522>
yeah, I tried JSON, it doesn't support serializing data nearly as well... and won't support complex objects either.
<dyoung522>
but it is an option
<dyoung522>
anywho... I'm beat. I'm heading to bed. talk at you later!
<dominikh>
night
txdv has quit [Read error: Operation timed out]
rikai_ has joined #cinch
rikai has quit [Ping timeout: 256 seconds]
rikai has joined #cinch
rikai_ has quit [Ping timeout: 248 seconds]
Spami has quit [Quit: This computer has gone to sleep]
rikai has quit [Ping timeout: 240 seconds]
rikai has joined #cinch
rikai has quit [Read error: Connection reset by peer]
rikai has joined #cinch
rikai has quit [Remote host closed the connection]
kludge` has quit [Ping timeout: 248 seconds]
kludge` has joined #cinch
postmodern has quit [Quit: Leaving]
ex0a has quit [Ping timeout: 260 seconds]
ex0a has joined #cinch
v0n has joined #cinch
v0n has quit [Ping timeout: 260 seconds]
max96at has joined #cinch
space has joined #cinch
UberDragon has joined #cinch
<UberDragon>
hi all.. anyone alive?
<UberDragon>
I'm trying to figure out how to catch You're not a channel operator messages so the bot attempts to get ops from chanserv
<UberDragon>
on :catchall, /(.+?)not (a |)channel operator(.+?)/ do |m|
<UberDragon>
doesn't seem to work but I can /(.+)/ and catch every thing.. from there find the message.. problem is.. this causes a thread every time the bot sees anything (very unnecessarily)
space has quit [Remote host closed the connection]
<Cinchy>
[URL] Class: Cinch::Channel — Documentation for cinchrb/cinch (master)
Spami has joined #cinch
Spami has quit [Changing host]
Spami has joined #cinch
<UberDragon>
I hadn't seen that yet.. that will be much simplier even though now I've sent in a pull request to add an event listener to raw 482 lol
<UberDragon>
I just started playing with cinch bot a couple days ago
Spami has quit [Quit: This computer has gone to sleep]
<UberDragon>
so bot sees command !op, if it doesnt have op it gets it from chanserv, how would I wait at this point for bot to get opped before applying the .op command?
<UberDragon>
sleep works, but I'd rather do it where it waits for the +o on itself
<waxjar>
listen to the :op event and check the user?
<UberDragon>
can I trigger listening to the :op event within a method like that?
<waxjar>
im sure it's possible, but why bother?
<UberDragon>
well the bot is basically waiting to give +o as commanded.. it needs to wait until it gets op from chanserv
<UberDragon>
sleep(5) works as long as the lag is good on the server
<UberDragon>
would be great to simply wait until it gets op, then send the mode #chan +o user command (.op)
<UberDragon>
the pastebin code works as expected... just hate having hard coded number of seconds to wait it's not reliable
<waxjar>
you don't really have to wait, you can just listen to the :op event from the start
Spami has joined #cinch
<waxjar>
queue the nicks up, op them when :op is triggered and the user is you
<UberDragon>
hmm
<UberDragon>
queuing up the nicks is either out of my cinch knowledge or ruby knowledge in general ... can you give me any head start on how I would que up nicks to get ops in channel after the bot obtains op?
<UberDragon>
or maybe better question.. how do I listen for an event within a plugin? (match seems to force a !trigger type not an event type)
<waxjar>
have an instance variable that's an Array, add nicks to it when #bot_has_ops? returns false
* UberDragon
nods
<UberDragon>
makes sense
<waxjar>
then pop off the elements when you receive the :op event
<waxjar>
listen_to listens for events i believe, or just listen. im not sure
<UberDragon>
listen_to looks like
<UberDragon>
thanks for your help. I plan to build a pretty robust bot with cinch :) You may see me here often for a while lol
<waxjar>
you'll have to synchronise access to the array with a mutex then, if you really want to be robust :P
<UberDragon>
hehe.. maybe not that robust.. at least not yet :P
<UberDragon>
I only started coding in ruby a couple months ago :)
* UberDragon
has over a decade of PHP and C experience
<waxjar>
i think there's a synchronised queue in the stdlib though
Spami has quit [Quit: This computer has gone to sleep]
rob_ has joined #cinch
<rob_>
hi
<rob_>
is it possible to do listen_to :connect
<rob_>
to perform an action when the bot connects to a network, e.g message nickserv?
<resure>
Strange thing: when I'm trying to store "server" config option, cinch fails with "Could not connect to the IRC server. Please check your network: getaddrinfo: Name or service not known". What can it be?
<rob_>
resure: cant resolve the name of the network
<resure>
rob_: it works well when I write server name as literal
<resure>
Debug output of ENV["SERVER"] is fine too
<rob_>
resure: dont understand what you mean, maybe paste code
<UberDragon>
waxjar: got it working with a queue using :on thanks!
<UberDragon>
err :op
<waxjar>
yw :)
<UberDragon>
seperate queue for each channel :)
<UberDragon>
hehe
<UberDragon>
just incase it's waiting on multiple chans to give out ops
<Cinchy>
[gist] Procfile (at gist.github.com, resure on 2013-08-24 20:29)
<rob_>
resure: getaddrinfo means it cant resolve the name, im not sure why your code doesnt work..
<rob_>
resure: ah, it could be that you cant access ENV from inside that block..
<rob_>
resure: so you're getting c.server = nil rather than what you think
<rob_>
resure: maybe try putting the puts inside the Cinch::Bot.new
<resure>
rob_, :6667:29 worker.1 | [2013/08/25 00:25:29.363] II Connecting to "chat.freenode.net" - looks like it has access to the ENV
<waxjar>
try replacing chat with irc :D
<rob_>
resure: what happens if you do 'dig A chat.freenode.net'
<rob_>
waxjar: i just checked, chat does seem to resolv..
<resure>
I get IPs
<resure>
Code works well when I'm replacing ENV['SERVER'] with 'chat.freenode.net'
<rob_>
resure: its odd, because that getaddrinfo is def a name reoslution failure
<resure>
rob_: yep. Another strange thing is that if I'm configure server with string literal it fails at the next line - "erroneous nick", and then on SASL auth
<resure>
And everything works if I'm configure it without ENV at all
<resure>
The same errors I got on heroku
postmodern has joined #cinch
<dominikh>
UberDragon: replied to your PR.
<dominikh>
well, both.
<UberDragon>
hmm k
<UberDragon>
not seeing it on git yet
<dominikh>
uh, what the heck
* UberDragon
shrugs
<UberDragon>
:)
<dominikh>
yeah, no, I don't see it, either
<dominikh>
well then I'll just write the message again…
space has joined #cinch
<UberDragon>
Did it basically I'm silly I should just use the :op event ? (which is what I ultimately did with a queue)
<dominikh>
UberDragon: no, it said to use the numeric directly, or the constant ERR_CHANOPRIVSNEEDED
<UberDragon>
:)
<dominikh>
you can use the numerics as events, and I don't think adding all possible error numerics as their own events has much merit
<UberDragon>
hmm I look forward to reading it.. yeah that makes sense I didn't realize you could listen for numerics
<dominikh>
yeah not much to look forward to, that's all I said, just lengthier
<UberDragon>
at the time I was stuck trying use :catchall and sifting thru that info to get what I wanted
<UberDragon>
how do you listen for the raw numeric?
<dominikh>
just use the number instead of a symbol
<UberDragon>
ah k
<dominikh>
on 482 do ..
<UberDragon>
thanks
<dominikh>
or, preferably, the constant
* UberDragon
nods
space has quit [Remote host closed the connection]