dominikh changed the topic of #cinch to: The IRC Framework | Latest version: Cinch 2.0.10
<ayonix> what are you trying to do?
<ayonix> bot.channels returns an array of the channels the bot is in
<CM-Punk> I want the bot to check if it's in a channel
<CM-Punk> Before it carries out an action
<CM-Punk> http://pastebin.com/70Rr4vFs I want it to work in these blocks ayonix
<CM-Punk> Like in line 11
Spami has quit [Read error: Connection reset by peer]
Spami has joined #cinch
Spami has quit [Changing host]
Spami has joined #cinch
sacc91 has joined #cinch
sacc91 has quit [Client Quit]
<CM-Punk> Does anyone here have any knowledge on the cinch-authentication gem? O
<CM-Punk> I am trying to figure out how to save the users I register
<mpapis> cinch-identify I think
<CM-Punk> No, that's to identify to servers. I'm trying to figure out where my bot saves the information when I trigger a registration after installing the cinch-authentication gem.
<CM-Punk> Because when the bot disconnects it loses all registrations I implemented
<mpapis> oh, that is different
<CM-Punk> Yeah
<mpapis> CM-Punk, https://github.com/britishtea/cinch-authentication/blob/master/lib/cinch/configuration/authentication.rb#L9 this one suggests it's just pure hash without any persistence
<CM-Punk> So what I
<CM-Punk> So what I'm trying to find out is how to save it.
<CM-Punk> And you can hardcode admins, like I did, the example can be found here: https://github.com/britishtea/cinch-authentication/blob/master/examples/user_login.rb
<CM-Punk> But what's the use of this command if I can't keep the registered users in the even of a quit
<CM-Punk> s/even/event
<mpapis> ah just use a file to read/write them
<mpapis> there can be concurrency problems if you add two users at once - but that's not important for low traffic
<CM-Punk> Alright, well now I gotta figure out how to do that...I'm new to Ruby
<mpapis> most problematic might be proper format, but I guess you could use http://ruby-doc.org/core-2.0.0/Marshal.html
<Cinchy> [URL] Module: Marshal (Ruby 2.0.0)
<Cinchy> [URL] ruby - How can I save an object to a file? - Stack Overflow
<CM-Punk> Thank you for all the information mpapis
<CM-Punk> I'm having trouble still but yeah
<catepillar> CM-Punk: it's probably better to write a couple of functions that can help
<catepillar> save the important information stored by each instance
<catepillar> and then load that
<CM-Punk> Catepillar I feel over my head. I'm just trying to get it to load what I already have and it won't I know I'm messing up somewhere
<catepillar> well, there's a couple of things that make this easier, someone already pointed out YAML, i believe
<catepillar> you could also go with a database of some sort
<catepillar> or you could write something completely custom
<catepillar> what are the necessary things to reload the instance of the class that you want to save?
<CM-Punk> The necessary things are user, pass, and level
<CM-Punk> http://pastebin.com/zL86E722 Based on examples I provided mpapis above I have written this...
<catepillar> this code is either way out of context or doing nothing
<catepillar> :users and :admins are symbols, they aren't variables, and you are doing nothing with them
<mpapis> it should be something like @users = Marshal.load
<catepillar> I think it should be like @users = Marshal.load("lib/eve/plugins/config/userdb")
<mpapis> :)
<mpapis> I assume to much
<catepillar> heh, i have the same problem
<CM-Punk> And where should that be?
<CM-Punk> I mean that's my problem...
Azure has quit [Remote host closed the connection]
<CM-Punk> When it comes to this stuff...I am lost...but I want to learn
<CM-Punk> http://pastebin.com/XmAKVuFh That's my main file
<catepillar> in place of the last 2 lines in your paste
<CM-Punk> Okay.
<CM-Punk> So...
<CM-Punk> Hold on a sec please, because I am eager to learn.
<CM-Punk> So this should look like this: http://pastebin.com/SsgD9s7Z based on this plugin: http://pastebin.com/ugUgifnD
Spami has quit [Quit: This computer has gone to sleep]
<CM-Punk> And the lambdas in the first file
<mpapis> CM-Punk, you could check https://gist.github.com - it allows multiple files and editing
<catepillar> make sure you include the "end" for you on :connect
<CM-Punk> Oh thanks mpapis
<CM-Punk> Alright catepiller
<catepillar> CM-Punk: you are probably going to have to add your changes to the UserLogin class
<catepillar> cause it doesn't contain the support necessary for persistant logins like you want
<CM-Punk> Right, okay.
* CM-Punk takes a breath
<catepillar> you could run something off the register method, but that feels dirty
<CM-Punk> So how do I do that?
<catepillar> you will need an initialize method
<CM-Punk> Makes sense.
<catepillar> just a sec, let me write one
<CM-Punk> I get that :D
<CM-Punk> Okay
<CM-Punk> By the way, I have my bot in GitHub if you guys are interested XD I just don't have all this on it yet of course
<catepillar> this plugin is a bit weird
<catepillar> seems to be running everything from a config variable
<CM-Punk> Hold on catepillar
<catepillar> im unfamiliar with that
<catepillar> ok, so it looks like you can do this without modifying that class at all
<CM-Punk> http://pastebin.com/TRpK8mi6 this is the config file, and this is the extension file
<CM-Punk> Oh?
<catepillar> where did you find this plugin?
<catepillar> ok
<CM-Punk> Yeah I read all that
<catepillar> about half way down it talks about how to save
<CM-Punk> That's for :list
<CM-Punk> Not :login
<catepillar> ok
<catepillar> so you have a list of users that are allowed to login?
<catepillar> i suppose they each have a nickname and password and type?
<catepillar> and that is all saved to a file?
<CM-Punk> Well kinda
Spami has joined #cinch
<CM-Punk> If you look at http://pastebin.com/SsgD9s7Z and the $users that's where it's saved
<CM-Punk> And when the bot comes on I can do !register user pass
<CM-Punk> But when the bot disconnects it loses that information
<catepillar> right, and you don't want to have this hardcoded right?
<catepillar> you would like that list to be loaded from a file
<catepillar> and saved
<CM-Punk> Yes, and added to when I !register a user
<catepillar> right
<catepillar> your best bet is to do something like $users=Marshal.load("filepath/filename")
<catepillar> instead of the 3 lines there already
<CM-Punk> Okay.
<catepillar> and not use the on :connect thing
<CM-Punk> Now, will that write to it when I !register?
<catepillar> in the registration lamba
<catepillar> add a line that contains "File.open('filepath/filename','w') { |f| f.write Marshal.dump($users) }"
<catepillar> that should take care of it
<catepillar> if you get a lot of users, this is probably a very poor way to handle it
<catepillar> cause you are writing that file over each time someone new registers
<CM-Punk> No, I only plan on handling a few
<catepillar> if you wanna go anything larger, you are probably gonna wanna look into prebuilt databases
<catepillar> that's bascially what I did when I built my very limited auth system
<CM-Punk> Ugh
<CM-Punk> Eve.rb:66:in `block (4 levels) in <main>': undefined method `nickname' for #<String:0x8a459e0> (NoMethodError)
<CM-Punk> When I try to login
<CM-Punk> Eve.rb is the main file that we just messed with
<catepillar> whats on line 66?
<CM-Punk> The fetch_user lambda $users.find { |user| user.nickname == nickname }
<catepillar> it's probably an issue with the Marshal.load thing
<catepillar> I have never used marshal in teh past to see how it works
<CM-Punk> Should we go with yaml then?
<catepillar> never used yaml iether
<catepillar> if i need persistant storage, i go with sqlite
<catepillar> and that's a whole other can of worms
<CM-Punk> http://pastebin.com/kfz2Q2M7 That's what my userdb.marshal looks like
<catepillar> did you do that by hand?
<CM-Punk> I copy/pasted the two lines that were there.
<catepillar> yea, don't do that
<CM-Punk> Oh...
Spami has quit [Quit: This computer has gone to sleep]
<CM-Punk> Okay.
<catepillar> if you really need those 2 accounts
<catepillar> i would push them back after your Marshal.load statement
<catepillar> actually
<catepillar> you should check to see if the file exists
<catepillar> if so, then continue with marshal.load
<catepillar> else
<catepillar> create the $users array
<catepillar> and push those 2 users
<CM-Punk> http://pastebin.com/AyXhP7Wc like this catepillar?
<catepillar> possibly
<catepillar> you might not need the $users= in teh $users=Marshal.load("lib/eve/plugins/config/userdb.marshal")
<catepillar> and that's coming from my inexperience with marshal
DeepBlue has joined #cinch
<CM-Punk> Okay catepillar I changed it to yaml
<CM-Punk> And I have this exception: Eve.rb:61:in `block (3 levels) in <main>': undefined method `one?' for "lib/eve/plugins/config/userdb.yaml":String (NoMethodError)
sleetdrop has joined #cinch
sleetdrop has quit [Max SendQ exceeded]
sleetdrop has joined #cinch
sleetdrop has quit [Max SendQ exceeded]
sleetdrop has joined #cinch
DeepBlue has quit [Quit: Konversation terminated!]
rampageRipper has joined #cinch
sleetdrop has quit [Quit: Textual IRC Client: www.textualapp.com]
<CM-Punk> Is there any reason that even though I set the prefix to ~ it's still responding to ! and *
<CM-Punk> ?
kludge` has quit [Ping timeout: 252 seconds]
kludge` has joined #cinch
rampageRipper has quit [Quit: Konversation terminated!]
DeepBlue has joined #cinch
DeepBlue has quit [Quit: Konversation terminated!]
DeepBlue has joined #cinch
DeepBlue has quit [Ping timeout: 264 seconds]
DeepBlue has joined #cinch
Spami has joined #cinch
Spami has quit [Quit: This computer has gone to sleep]
Spami has joined #cinch
notAzure has joined #cinch
notAzure has quit [Quit: Textual IRC Client: www.textualapp.com]
Azure has joined #cinch
FiXato has quit [Max SendQ exceeded]
FiXato has joined #cinch
FiXato has quit [Quit: time for a reboot]
FiXato has joined #cinch
DeepBlue has quit [Ping timeout: 265 seconds]
DeepBlue has joined #cinch
DeepBlue has quit [Ping timeout: 245 seconds]
DeepBlue has joined #cinch