User Control Panel
Advertisements

HELP US, HELP YOU!

Note Command NexusBot

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Commands
View unanswered posts
Author Message
Cheater
Senior Member
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Thu Jun 16, 2005 3:09 pm    Post subject: Note Command NexusBot Reply with quote

Here is a note command made for Nexusbot. I can't really say I made it alone. Cer helped a LOT, and I asked a ton of questions here. But here it is. Make sure you have a folder called "notes" in your main bot directory.

Create Note:
Code:
sub create {
   my ($self,$client,$msg,$listener) = @_;

if (!-d "./notes/$client") {
mkdir ("./notes/$client");
}
use strict;
use warnings;
my ($title, $note) = split(/:/, $msg, 2);
my $time = localtime();
open(FILE,">./notes/$client/$title.txt");
print FILE "$time\n\n$note\n";
close(FILE);
#$reply = "$title Created";
#return $reply;
}
1;


Open Note:
Code:
sub open {
   my ($self,$client,$msg,$listener) = @_;
open (FILE, "./notes/$client/$msg.txt");
my @data = <FILE>;
close (FILE);
chomp @data; # removes \r's from each line
return join ("\n", @data);
$reply = "@data";
return $reply;
}
1;


Delete 1 Note:
Code:
sub delete {
   my ($self,$client,$msg,$listener) = @_;
$myfile ="./notes/$client/$msg.txt";
unlink $myfile;
$reply = "$msg Deleted";
return $reply;
}
1;


Delete All Notes:
Code:
sub erase {
   my ($self,$client,$msg,$listener) = @_;

opendir(DIR, "./notes/$client");
@files = readdir(DIR);
closedir(DIR);

foreach $file (@files) {
   unlink ("./notes/$client/$file");
}

$reply = "All Notes Deleted";
return $reply;
}
1;


List All Notes:
Code:
sub view {
   my ($self,$client,$msg,$listener) = @_;
$dir = "./notes/$client/";
opendir (DIR, $dir);
$reply = "Notes:\n\n";
foreach my $file (sort(grep(!/^\./, readdir(DIR)))) {

$file =~ s/\.(txt|html|pl|db|etc|etc)$//ig;
$reply .= "$file\n";
}
close (DIR);
return $reply;
}
1;

Note Centeral (Help):
Code:
sub note {
   my ($self,$client,$msg,$listener) = @_;

$reply = "Note Centeral\n\nTo write a note to yourself, enter: !create NoteTitle:Note\nExamples:\n!create Remember:To walk the dog\n!create Call:Your mom 555-5555\n!create ToDo:Homework,baseball,study\n\nTo open a note, enter: !open NoteTitle\nExamples:\n!open Remember\n!open Call\n!open ToDo\n\nTo delete a note, enter: !delete NoteTitle\nExamples:\n!delete Remember\n!delete Call\n!delete ToDo\n\nTo delete all your notes, enter: !erase\nExamples:\n!erase\n\nTo list all your notes, enter: !view\nExamples:\n!view\n\nTo send a note to someone else, enter: !send ScreenName:NoteTitle:Note\nExamples:\n!send JohnDoe64:Remember:To walk the dog\n!send TimJohnson22:Call:Your mom\n!send FredSmith58:ToDo:Homework,baseball,study\n\nTo get back here, enter: !note\nExamples:\n!note";
return $reply

 
}
1;


Send Note to other People:
Code:
sub send {
my ($self,$client,$msg,$listener) = @_;

my ($user, $title, $note) = split /:/, $msg, 3;

if (!-d "./notes/$user") {
mkdir ("./notes/$user");
}
use strict;
use warnings;
my $time = localtime();
open(FILE,">./notes/$user/$client.$title.txt");
print FILE "$time\n\n$note\n";
close(FILE);
}
1;



Some of the commands are missing a reply from the bot. I was having problems, and getting errors. If you want to add it in, post the code here.

Ideas For Improvement:
1: Print the Note
Print the Note, and JUST the note from the printer of the client

If you have other ideas for improvement, post them here.


Last edited by Cheater on Mon Jun 27, 2005 9:48 pm; edited 1 time in total
Back to top
Cer
Upgraded Agent
Upgraded Agent


Joined: 03 Feb 2004
Posts: 3776
Location: Michigan
Reputation: 146.9
votes: 4

PostPosted: Fri Jun 17, 2005 2:22 am    Post subject: Reply with quote

Good job. Your send notes command is close though, you just need to do the split first so that you have $user when you want to check its existence...

Quote:
sub send {
my ($self,$client,$msg,$listener) = @_;

my ($user, $title, $note) = split /:/, $msg, 3;

if (!-d "./notes/$user") {
mkdir ("./notes/$user");
}
use strict;
use warnings;
my $time = localtime();
my ($user, $title, $note) = split /:/, $msg, 3;
open(FILE,">./notes/$user/$client.$title.txt");
print FILE "$time\n\n$note\n";
close(FILE);
}
1;


(red = remove that, blue = add that)
Back to top
Cheater
Senior Member
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Fri Jun 17, 2005 12:53 pm    Post subject: Reply with quote

Thanks once again Cer. I'm glad you didn't just make it for me. Even if I had to ask a million questions to make it, I still learned a lot (and made my bot better).
Back to top
X-Worm
Newbie
Newbie


Joined: 12 May 2005
Posts: 36

Reputation: 35.7Reputation: 35.7Reputation: 35.7Reputation: 35.7

PostPosted: Sat Oct 15, 2005 5:44 pm    Post subject: Reply with quote

Hmm, I think that you can exploit that command by using a "|" in front of the title and then run system commands, I don't know for sure though.

Last edited by X-Worm on Mon Oct 17, 2005 4:52 am; edited 1 time in total
Back to top
Cheater
Senior Member
Senior Member


Joined: 10 Jun 2005
Posts: 236

Reputation: 15.8Reputation: 15.8

PostPosted: Sun Oct 16, 2005 1:14 am    Post subject: Reply with quote

Once again X-Worm, this was the first real command I made, and I am no longer working on it. Feel free to edit it and make your own version, but please stop posting about it
Back to top
X-Worm
Newbie
Newbie


Joined: 12 May 2005
Posts: 36

Reputation: 35.7Reputation: 35.7Reputation: 35.7Reputation: 35.7

PostPosted: Mon Oct 17, 2005 4:51 am    Post subject: Reply with quote

Once again?
*shuts up*
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Commands All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group