dominikh changed the topic of #cinch to: The IRC Framework | Latest version: Cinch 2.1.0
Spami has joined #cinch
txdv has quit [Ping timeout: 276 seconds]
txdv has joined #cinch
Spami has quit [Quit: Leaving]
kludge` has quit [Ping timeout: 258 seconds]
kludge` has joined #cinch
postmodern has quit [Quit: Leaving]
aclearman037 has joined #cinch
aclearman037 has quit []
aclearman037 has joined #cinch
Dwarf has quit [Ping timeout: 252 seconds]
postmodern has joined #cinch
aclearman037 has quit []
Dwarf has joined #cinch
ahh has joined #cinch
<ahh> hey guys
<dominikh> Hi.
<ahh> trying to setup a very basic cinch bot to send messages when people swipe a fob. having a hard time figuring out how to just send a simple message. I have the basic example up and running but most actions are on events and reactive
<ahh> like the on :message reply. how can i just run a method when i want and send a message ?
<dominikh> I have no idea what "swipe a fob" means :)
<ahh> like a person uses an rfid fob. tries to access the building. we wanted it to send a message in our hacklab irc room :)
<ahh> should be pretty simple but i must be missing something in the examples/docs
<dominikh> if you want to send messages without using Cinch's event system: There are Channel#send and User#send methods (technically both are just Target#send). so you could do, for example. bot.Channel("#hacklab").send("intruder") – or if you don't like the ugly casing, there's bot.channel_list.find_ensured("#hacklab"), that's the raw API
<dominikh> the examples don't really cover that use
<ahh> ah I tried the Channel but i made a method inside the Bot.new doh. let me try it
<dominikh> Cinch has both a full framework for the whole events, message matching and so on stuff, and a pretty decent normal API you can use like any other
<dominikh> and treat the Bot instance just as a connection
<dominikh> and I had no idea those things were called fobs :)
<ahh> he he thanks for the info. I just built a door unlock system for our building with magnetic locks etc.. it uses those rfid (fobs) that are assigned to people and has authentication for people. hardware/software
<ahh> the bot is kind of fun
<dominikh> sounds like one of the more interesting uses of Cinch :)
<ahh> i'm pretty new to ruby
<ahh> i got some basic event driven stuff and will probably write a small plugin at some point :)
<dominikh> :)
<ahh> it's a great plugin so far so thank you for the good work
<dominikh> you're welcome
<ahh> sigh. not able to get the Channel working
<dominikh> paste your code on a pastebin
<ahh> i showed 3 ways i tried
<ahh> probably just basic ruby mistakes
<dominikh> first one can't possibly work. there's not even a variable "bot". second one can't work because a) how does the bot know where to connect and what channels to join? b) even if you provided that information, you still need to tell the bot to actually connect
<dominikh> aside from that, without a delay, even if you did it correctly, it won't work, because you'll try to send the message before it finished connecting.
<ahh> hmm ok
<dominikh> something akin to http://sprunge.us/WiGA (untested) should work
<ahh> fantastic that worked :)
<ahh> so next a method that does this for me :)
<dominikh> a suggestion: your bot should not connect, post and quit for each person that walks into the lab. it should connect once and wait for some external event
<ahh> doing like the example ?
<dominikh> the one I just showed you? yeah, that'd be how you don't want it to be, generally
<dominikh> it creates noise with the joining/leaving, and if 10 people swipe in a minute, freenode might get annoyed by the reconnects as well
<ahh> is there a way to do this with a plugin and this sample you had on your site? https://gist.github.com/prussiap/11068736
<dominikh> well, you'll want some way to communicate between whatever is registering the swipes and the bot. how you want to do that depends on a number of things
<dominikh> for example if said script is fired once per swipe or is a daemon, if it's written in Ruby or not, etc
<ahh> script is written in ruby and will be running locally. it makes a curl call to rails app to ask for permissions
<ahh> but I could just to make my life easy run cinch in the rfid ruby script to start
<ahh> all in one file :)
<dominikh> if that script is a long-lived process, then yes
<ahh> it will be running yes
<ahh> basically a while loop with some interrupts
<ahh> all running on a raspberry pi