2013-11-03 10:14
dominikh changed the topic of #cinch to: The IRC Framework | Latest version: Cinch 2.0.10
00:00
<
ayonix >
what are you trying to do?
00:00
<
ayonix >
bot.channels returns an array of the channels the bot is in
00:01
<
CM-Punk >
I want the bot to check if it's in a channel
00:01
<
CM-Punk >
Before it carries out an action
00:12
<
CM-Punk >
Like in line 11
00:54
Spami has quit [Read error: Connection reset by peer]
00:55
Spami has joined #cinch
00:55
Spami has quit [Changing host]
00:55
Spami has joined #cinch
02:27
sacc91 has joined #cinch
02:30
sacc91 has quit [Client Quit]
04:02
<
CM-Punk >
Does anyone here have any knowledge on the cinch-authentication gem? O
04:02
<
CM-Punk >
I am trying to figure out how to save the users I register
04:03
<
mpapis >
cinch-identify I think
04:05
<
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.
04:06
<
CM-Punk >
Because when the bot disconnects it loses all registrations I implemented
04:06
<
mpapis >
oh, that is different
04:12
<
CM-Punk >
So what I
04:13
<
CM-Punk >
So what I'm trying to find out is how to save it.
04:14
<
CM-Punk >
But what's the use of this command if I can't keep the registered users in the even of a quit
04:15
<
CM-Punk >
s/even/event
04:53
<
mpapis >
ah just use a file to read/write them
04:54
<
mpapis >
there can be concurrency problems if you add two users at once - but that's not important for low traffic
04:58
<
CM-Punk >
Alright, well now I gotta figure out how to do that...I'm new to Ruby
05:05
<
Cinchy >
[URL] Module: Marshal (Ruby 2.0.0)
05:06
<
Cinchy >
[URL] ruby - How can I save an object to a file? - Stack Overflow
05:38
<
CM-Punk >
Thank you for all the information mpapis
05:38
<
CM-Punk >
I'm having trouble still but yeah
05:39
<
catepillar >
CM-Punk: it's probably better to write a couple of functions that can help
05:39
<
catepillar >
save the important information stored by each instance
05:39
<
catepillar >
and then load that
05:40
<
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
05:44
<
catepillar >
well, there's a couple of things that make this easier, someone already pointed out YAML, i believe
05:44
<
catepillar >
you could also go with a database of some sort
05:44
<
catepillar >
or you could write something completely custom
05:45
<
catepillar >
what are the necessary things to reload the instance of the class that you want to save?
05:49
<
CM-Punk >
The necessary things are user, pass, and level
05:51
<
catepillar >
this code is either way out of context or doing nothing
05:52
<
catepillar >
:users and :admins are symbols, they aren't variables, and you are doing nothing with them
05:52
<
mpapis >
it should be something like @users = Marshal.load
05:53
<
catepillar >
I think it should be like @users = Marshal.load("lib/eve/plugins/config/userdb")
05:53
<
mpapis >
I assume to much
05:54
<
catepillar >
heh, i have the same problem
05:56
<
CM-Punk >
And where should that be?
05:56
<
CM-Punk >
I mean that's my problem...
05:56
Azure has quit [Remote host closed the connection]
05:56
<
CM-Punk >
When it comes to this stuff...I am lost...but I want to learn
05:56
<
catepillar >
in place of the last 2 lines in your paste
05:58
<
CM-Punk >
Hold on a sec please, because I am eager to learn.
06:03
Spami has quit [Quit: This computer has gone to sleep]
06:03
<
CM-Punk >
And the lambdas in the first file
06:05
<
catepillar >
make sure you include the "end" for you on :connect
06:06
<
CM-Punk >
Oh thanks mpapis
06:07
<
CM-Punk >
Alright catepiller
06:07
<
catepillar >
CM-Punk: you are probably going to have to add your changes to the UserLogin class
06:07
<
catepillar >
cause it doesn't contain the support necessary for persistant logins like you want
06:07
<
CM-Punk >
Right, okay.
06:08
* CM-Punk
takes a breath
06:08
<
catepillar >
you could run something off the register method, but that feels dirty
06:08
<
CM-Punk >
So how do I do that?
06:08
<
catepillar >
you will need an initialize method
06:08
<
CM-Punk >
Makes sense.
06:08
<
catepillar >
just a sec, let me write one
06:08
<
CM-Punk >
I get that :D
06:10
<
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
06:10
<
catepillar >
this plugin is a bit weird
06:11
<
catepillar >
seems to be running everything from a config variable
06:11
<
CM-Punk >
Hold on catepillar
06:11
<
catepillar >
im unfamiliar with that
06:13
<
catepillar >
ok, so it looks like you can do this without modifying that class at all
06:15
<
catepillar >
where did you find this plugin?
06:18
<
CM-Punk >
Yeah I read all that
06:18
<
catepillar >
about half way down it talks about how to save
06:18
<
CM-Punk >
That's for :list
06:18
<
CM-Punk >
Not :login
06:19
<
catepillar >
so you have a list of users that are allowed to login?
06:20
<
catepillar >
i suppose they each have a nickname and password and type?
06:20
<
catepillar >
and that is all saved to a file?
06:20
<
CM-Punk >
Well kinda
06:20
Spami has joined #cinch
06:21
<
CM-Punk >
And when the bot comes on I can do !register user pass
06:21
<
CM-Punk >
But when the bot disconnects it loses that information
06:21
<
catepillar >
right, and you don't want to have this hardcoded right?
06:21
<
catepillar >
you would like that list to be loaded from a file
06:22
<
catepillar >
and saved
06:22
<
CM-Punk >
Yes, and added to when I !register a user
06:23
<
catepillar >
your best bet is to do something like $users=Marshal.load("filepath/filename")
06:23
<
catepillar >
instead of the 3 lines there already
06:23
<
catepillar >
and not use the on :connect thing
06:23
<
CM-Punk >
Now, will that write to it when I !register?
06:24
<
catepillar >
in the registration lamba
06:25
<
catepillar >
add a line that contains "File.open('filepath/filename','w') { |f| f.write Marshal.dump($users) }"
06:26
<
catepillar >
that should take care of it
06:26
<
catepillar >
if you get a lot of users, this is probably a very poor way to handle it
06:26
<
catepillar >
cause you are writing that file over each time someone new registers
06:26
<
CM-Punk >
No, I only plan on handling a few
06:27
<
catepillar >
if you wanna go anything larger, you are probably gonna wanna look into prebuilt databases
06:27
<
catepillar >
that's bascially what I did when I built my very limited auth system
06:28
<
CM-Punk >
Eve.rb:66:in `block (4 levels) in <main>': undefined method `nickname' for #<String:0x8a459e0> (NoMethodError)
06:29
<
CM-Punk >
When I try to login
06:29
<
CM-Punk >
Eve.rb is the main file that we just messed with
06:29
<
catepillar >
whats on line 66?
06:30
<
CM-Punk >
The fetch_user lambda $users.find { |user| user.nickname == nickname }
06:31
<
catepillar >
it's probably an issue with the Marshal.load thing
06:31
<
catepillar >
I have never used marshal in teh past to see how it works
06:32
<
CM-Punk >
Should we go with yaml then?
06:33
<
catepillar >
never used yaml iether
06:34
<
catepillar >
if i need persistant storage, i go with sqlite
06:34
<
catepillar >
and that's a whole other can of worms
06:35
<
catepillar >
did you do that by hand?
06:36
<
CM-Punk >
I copy/pasted the two lines that were there.
06:36
<
catepillar >
yea, don't do that
06:37
Spami has quit [Quit: This computer has gone to sleep]
06:37
<
catepillar >
if you really need those 2 accounts
06:37
<
catepillar >
i would push them back after your Marshal.load statement
06:37
<
catepillar >
actually
06:38
<
catepillar >
you should check to see if the file exists
06:38
<
catepillar >
if so, then continue with marshal.load
06:38
<
catepillar >
create the $users array
06:38
<
catepillar >
and push those 2 users
06:49
<
catepillar >
possibly
06:49
<
catepillar >
you might not need the $users= in teh $users=Marshal.load("lib/eve/plugins/config/userdb.marshal")
06:49
<
catepillar >
and that's coming from my inexperience with marshal
06:53
DeepBlue has joined #cinch
07:03
<
CM-Punk >
Okay catepillar I changed it to yaml
07:03
<
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)
07:30
sleetdrop has joined #cinch
07:30
sleetdrop has quit [Max SendQ exceeded]
07:31
sleetdrop has joined #cinch
07:31
sleetdrop has quit [Max SendQ exceeded]
07:41
sleetdrop has joined #cinch
08:10
DeepBlue has quit [Quit: Konversation terminated!]
09:35
rampageRipper has joined #cinch
10:39
<
CM-Punk >
Is there any reason that even though I set the prefix to ~ it's still responding to ! and *
10:50
kludge` has quit [Ping timeout: 252 seconds]
10:54
kludge` has joined #cinch
12:41
rampageRipper has quit [Quit: Konversation terminated!]
13:02
DeepBlue has joined #cinch
15:02
DeepBlue has quit [Quit: Konversation terminated!]
15:09
DeepBlue has joined #cinch
18:25
DeepBlue has quit [Ping timeout: 264 seconds]
18:46
DeepBlue has joined #cinch
18:54
Spami has joined #cinch
19:37
Spami has quit [Quit: This computer has gone to sleep]
19:38
Spami has joined #cinch
19:55
notAzure has joined #cinch
20:15
Azure has joined #cinch
21:09
FiXato has quit [Max SendQ exceeded]
21:11
FiXato has joined #cinch
21:23
FiXato has quit [Quit: time for a reboot]
21:27
FiXato has joined #cinch
22:15
DeepBlue has quit [Ping timeout: 265 seconds]
22:32
DeepBlue has joined #cinch
23:24
DeepBlue has quit [Ping timeout: 245 seconds]
23:26
DeepBlue has joined #cinch