User Control Panel
Advertisements

HELP US, HELP YOU!

Favourites

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Commands
View unanswered posts
Author Message
GiL
Not Yet a God
Not Yet a God


Joined: 06 Jan 2004
Posts: 344

Reputation: 35.3Reputation: 35.3Reputation: 35.3Reputation: 35.3

PostPosted: Wed Mar 03, 2004 10:19 am    Post subject: Reply with quote

This is basically a Personal Favourites List. It took me about 1 hour to do and I only did it because I was bored Razz. Thanks for the idea Eric! I hope everyone likes it and yes it is fully tested and yes it is for andromeda!!
Code:
sub favourites<br />{<br />   my ($bot,$self,$user,$msg) = @_;<br />   $self->{settings}->{callback} = "favourites";<br />   my $reply;<br />   <br />   if ($msg eq '')<br />   {<br />  my @faves = split (/,/,$bot->{users}->{$user}->{favourites});<br />  my $favecount = 0;<br />  foreach my $fave (@faves)<br />  {<br />     $favecount++;<br />  }<br />  $reply = "Welcome to your Favourites List!\n\nYou currently have " . $favecount . " favourites on your list!\n";<br />  $reply .= "To add a favourite to your list type 'add' and follow the steps!\n";<br />  $reply .= "To delete a favourite from your list type 'delete' and follow the steps!\n";<br />  $reply .= "To view your list of favourites type 'view'!\n\n";<br />  $reply .= "To stop viewing, editing your Favourites List type 'stop'!";<br />   }<br />   elsif ($msg eq 'stop')<br />   {<br />  $self->{settings}->{callback} = '';<br />  delete $self->{settings}->{doing};<br />  $reply = "You have exited your Favourites List!";<br />   }<br />   elsif ($self->{settings}->{doing} eq 'delete')<br />   {<br />  my $favecount = 0;<br />  foreach my $fave (keys %{$bot->{users}->{$user}->{favourites}})<br />  {<br />     $favecount++;<br />     if ($msg eq $favecount)<br />     {<br />    my $oldfave = $bot->{users}->{$user}->{favourites}->{$fave};<br />    delete $bot->{users}->{$user}->{favourites}->{$fave};<br />    foreach my $favedelete (@faves)<br />    {<br />       $bot->{users}->{$user}->{favourites}->{$fave} = 1 if $msg ne $favecount;<br />    }<br />     }<br />  }<br />  $self->{settings}->{doing} = '';<br />  $reply = "Successfully deleted the favourite off your list!";<br />   }<br />   elsif ($self->{settings}->{doing} eq 'add')<br />   {<br />  $bot->{users}->{$user}->{favourites}->{$msg} = 1;<br />  $reply = "You have successfully stored the URL " . $msg . " into your Favourites List!";<br />  $self->{settings}->{doing} = '';<br />   }<br />   elsif ($msg eq 'view')<br />   {<br />  my $faveritcount = 0;<br />  foreach my $faverit (keys %{$bot->{users}->{$user}->{favourites}})<br />  {<br />     $faveritcount++;<br />  }<br />  if ($faveritcount == 0)<br />  {<br />     $reply = "You have no favourites in your list.";<br />  }<br />  else<br />  {<br />     $reply = "Your Favourites List:\n\n";<br />     foreach my $fave (keys %{$bot->{users}->{$user}->{favourites}})<br />     {<br />    $reply .= $fave . "\n";<br />     }<br />     $reply =~ /\n$/;<br />  }<br />   }<br />   elsif ($msg eq 'add')<br />   {<br />  my $faveritcount = 0;<br />  foreach my $faverit (keys %{$bot->{users}->{$user}->{favourites}})<br />  {<br />     $faveritcount++;<br />  }<br />  if ($faveritcount == 30)<br />  {<br />     $reply = "Sorry but you already have the maxium of 30 favourites in your list. Delete some to make room.";<br />  }<br />  else<br />  {<br />     $reply = "Please type in the URL that you would like to store into your Favourites List.";<br />     $self->{settings}->{doing} = 'add';<br />  }<br />   }<br />   elsif ($msg eq 'delete')<br />   {<br />  my $faveritcount = 0;<br />  foreach my $faverit (keys %{$bot->{users}->{$user}->{favourites}})<br />  {<br />     $faveritcount++;<br />  }<br />  if ($faveritcount == 0)<br />  {<br />     $reply = "You already don't have any favourites!";<br />  }<br />  else<br />  {<br />     $reply = "Please choose from the list below which favourite you would like to delete.\n\n";<br />     my $favecount = 0;<br />     foreach my $fave (keys %{$bot->{users}->{$user}->{favourites}})<br />     {<br />    $favecount++;<br />    $reply .= $favecount . ") " . $fave . "\n";<br />    $reply .= "\nChoose by typing the number.";<br />     }<br />     $self->{settings}->{doing} = 'delete';<br />  }<br />   }<br />   return $reply;<br />}<br /><br />{<br />   Category    => 'Cool Stuff',<br />   Usage       => 'favourites',<br />   Description => 'Store, View, Delete your favourite websites.',<br />};


Have Fun!
-Gil

P.S. I have to put it into a ZIP File because the forum isn't accepting pl extenstions for some reason.
Back to top
Dazzy
Agent
Agent


Joined: 09 Jan 2004
Posts: 1731

Reputation: 72.3

PostPosted: Wed Mar 03, 2004 2:58 pm    Post subject: Reply with quote

nice once again....if rep comes back ill give you some...you deserve it for the top5 and this!
Back to top
zander
God Like
God Like


Joined: 14 Jan 2004
Posts: 540
Location: england
Reputation: 66.6

PostPosted: Wed Mar 03, 2004 5:57 pm    Post subject: Reply with quote

yer *lazy* will get +1 of me aswell
Back to top
GiL
Not Yet a God
Not Yet a God


Joined: 06 Jan 2004
Posts: 344

Reputation: 35.3Reputation: 35.3Reputation: 35.3Reputation: 35.3

PostPosted: Wed Mar 03, 2004 9:09 pm    Post subject: Reply with quote

lol thanks but it isnt much. its really easy to do. can *lazy* imagine that i only started to look at perl on the 23 of january this year
Back to top
Myzterio
Not Yet a God
Not Yet a God


Joined: 13 Dec 2003
Posts: 429

Reputation: 38.1Reputation: 38.1Reputation: 38.1Reputation: 38.1

PostPosted: Thu Mar 04, 2004 12:22 am    Post subject: Reply with quote

Hey, this is a ELSiF/IF Favorites Command but not as good as gils so Enjoy
Code:
  if ($msg =~ /^\!add favs(.*)$/)<br />{<br />     open (DATA, ">>favorites/$username.txt");<br />     print DATA "$1\n";<br />     close(DATA);<br />     $self->sendmsg("Your Favorite Link were successfully saved\nTo View your Favs say !view favs or to delete favs say !delete favs");<br />    }<br />       elsif($msg =~ /^\!view favs/)<br />    {<br />     open (DATA, "favorites/$username.txt");<br />     @line = <DATA>;<br />     close(DATA);<br />     $self->sendmsg("Here are you listed favorite Links :\n@line"); <br />    }<br />    <br />            elsif($msg =~ /^\!delete favs/)<br />    {<br />     $self->sendmsg("Oi.. Favorite Links Has Now been Deleted"); <br />     open (DATA, ">favorites/$username.txt");<br />     print DATA "";<br />     close(DATA);<br />    }<br /><br />    <br />                  if ($msg =~ /(^\!favorites)/i) {<br />&send($self,"<:o) Favorite Section :\n<br />!add favs <TEXT> - Add a Link to your Favorites<br />!view favs - View your Favorites Book<br />!delete favs - Delete all your Favorites","$username");<br />return;<br />}
Back to top
Keenie
Almost An Agent
Almost An Agent


Joined: 31 Oct 2003
Posts: 1071

Reputation: 52.4

PostPosted: Thu Mar 04, 2004 12:50 am    Post subject: Reply with quote

just because you use the cram it into one file style aka if/elsif
doesnt meen you have to you text files to store things, id rather one file, then 10,000 text files (per command)
Back to top
Myzterio
Not Yet a God
Not Yet a God


Joined: 13 Dec 2003
Posts: 429

Reputation: 38.1Reputation: 38.1Reputation: 38.1Reputation: 38.1

PostPosted: Thu Mar 04, 2004 12:56 am    Post subject: Reply with quote

Well.. sorry :S Ill do it next time when i start posting commnads like that
Back to top
devil_dawg
Young One
Young One


Joined: 17 Feb 2004
Posts: 62

Reputation: 28.2Reputation: 28.2Reputation: 28.2

PostPosted: Thu Mar 04, 2004 9:42 am    Post subject: Reply with quote

Razz your Els i command should be a sparate comment
Back to top
JoeX
Agent
Agent


Joined: 02 Jan 2004
Posts: 2153

Reputation: 72.7

PostPosted: Sat Mar 06, 2004 11:04 am    Post subject: Reply with quote

Nice work, Yet AGAIN Razz lol

keep it UPPPPP!

_________________
Heroes NBC
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