User Control Panel
Advertisements

HELP US, HELP YOU!

How to get this code doing things....

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


Joined: 01 Jan 2004
Posts: 233
Location: The Netherlands
Reputation: 39.8Reputation: 39.8Reputation: 39.8Reputation: 39.8

PostPosted: Fri Jan 02, 2004 10:44 pm    Post subject: Reply with quote

Ok,

i've downloaded (shame shame Razz) this code from Wiredbots and it contains 3 files to use 'messaging' so that you can leave a message for someone (email-addy based)

The original code was intended to give a message to the user if they have a message but it looks like even IF you delete he keeps telling you to check your messages because you have a new one...

That's why i removed (commented) that part of the code (it was a handler)

But now i'd like to have it back and to act a bit different.

I want it this way: If a user gets a msg he gets 1 (one) message and after that he won't be notified - unless he gets another message.

I think it is possible.. It's a bit like the 'silence' command posted on this board.. After the msg was sent the bot sets '$sentnotif 1; ' and that if $sentnotif = 1; he won't reply and if it is $sentnotif=0; he does..

Is this possible?
If so: how ? What do i have to change?

Here's the code:

Read Messages:
Code:
<br />sub rm {<br />open (FILE, "./logs/messages/$victim.txt");<br />my @msgs = <FILE>;<br />close (FILE);<br />$end = ("Here are all your messages:\n @msgs\n End of messages");<br />return $end;<br />}<br />1;<br />


Leave Messages:
Code:
sub lm {<br /><br />#get ours arrays sorted<br /><br />$timestamp = (scalar localtime);<br /><br />$adminonly = 0;<br /><br />#open the admin txt <br />open (FILE, "admin.txt");<br />$admin = <FILE>;<br />close(FILE);<br /><br />   $victim = shift;<br />   $msg = shift;<br />   <br />   # get vars after split<br />   ($note, $what) = split(/ /, $msg, 2);<br />   ($from, $to) = split(/>/, $what, 2);<br />   <br />   if ($from eq "" || $to eq "") {<br />   $reply = "You can leave a message for"<br />   ." other users by typing "<br />   ."!lm user> message so"<br />   ."!lm jij @ hotmail.com > you rock"<br />   ."  would leave a message for " <br />   ."jij @ hotmail.com with the message "<br />   ."you rock\n";<br />   }<br />elsif($adminonly == 1 && $victim ne "$admin") {<br /><br />  $reply = "Sorry, This is for administrators";<br /><br />   #otherwise, leave the message <br />   } else {   <br />   $cfgln = "[$victim said:] $to ";<br />  $filename = "$from.txt";<br />  open (DATA, ">>logs/messages/$filename");<br />  print DATA "$cfgln at [$timestamp on $datestamp]\n";<br />  close (DATA);<br />  open (DATA, ">>logs/messages/locks/$victim.lck");<br />  print DATA "1";<br />  close (DATA);<br />  $reply = "Message stored!";<br />}<br /><br />return $reply;<br />}<br />1;



Delete messages:
Code:
sub delmess {<br /><br />$adminonly = 0;<br />$reply = "4If you don't want them deleted, then don't delete them!!";<br /><br />#open admin yada yada<br />open (FILE, "admin.txt");<br />$admin = <FILE>;<br />close(FILE);<br /><br />$victim = shift;<br />$msg = shift;<br /><br />($del, $conf) = split(/ /, $msg, 2);<br /><br />if ($conf eq "") {<br />   $reply = "You can use this to"<br />   ." delete your messages by typing "<br />   ."!delmess yes"<br />   ." if you do not include the yes"<br />   ."  your messages will not be " <br />   ."deleted. And a note of caution, "<br />   ."once you delete them, they are gone!!";<br /><br />} <br />elsif($adminonly == 1 && $victim ne "$admin") {<br /><br />  $reply = "Sorry, This is for administrators";<br /><br />   #leave the message<br />   } else {<br />   if ($conf eq "yes") {<br />     $reply = "Messages deleted";<br />     unlink (FILE, "./logs/messages/$victim.txt");<br />}<br />elsif($adminonly == 1 && $victim ne "$admin") {<br /><br />  $reply = "Sorry, This is for administrators";<br />}<br /><br />return $reply;<br />}<br />}<br />1;<br />


This is the thing needed for that notification:

Code:
sub mess {<br /><br />$greet = "Attention $victim";<br /><br />if (!-e "./logs/messages/locks/$victim.lck") <br />{ <br />#$msgs = thought ();<br />#$msgs = mess ();<br />}<br />else <br />{<br />$msgs = "$greet, You have new messages on the bot.\n";<br />unlink (FILE, "./logs/messages/locks/$victim.lck");<br />}<br />$reply = $msgs;<br />return $reply;<br />}<br /><br />1;


Tnx

Btw: I modified it slightly Razz

_________________
Sypher
Developer of Codera
Back to top
Vorx
Senior Member
Senior Member


Joined: 21 Dec 2003
Posts: 152

Reputation: 32Reputation: 32Reputation: 32

PostPosted: Sat Jan 03, 2004 12:21 am    Post subject: Reply with quote

A note for anyone who hasn't used this code before - LM actually means Leave Message not list messages.
Back to top
Micky G
Member
Member


Joined: 30 Dec 2003
Posts: 144

Reputation: 31.5Reputation: 31.5Reputation: 31.5

PostPosted: Sat Jan 03, 2004 1:28 pm    Post subject: Reply with quote

1 question! :unsure: Where did you download this wiredbots code? Was it on wiredbots forum or :blink: where?
Back to top
Sypher
Senior Member
Senior Member


Joined: 01 Jan 2004
Posts: 233
Location: The Netherlands
Reputation: 39.8Reputation: 39.8Reputation: 39.8Reputation: 39.8

PostPosted: Sat Jan 03, 2004 1:43 pm    Post subject: Reply with quote

WiredBots Downloads Smile
_________________
Sypher
Developer of Codera
Back to top
Nate
God Like
God Like


Joined: 12 Nov 2003
Posts: 553

Reputation: 41.3Reputation: 41.3Reputation: 41.3Reputation: 41.3

PostPosted: Sat Jan 03, 2004 4:45 pm    Post subject: Reply with quote

lol... the one WiredBots made was designed to work with MSN P2, that's why I updated the code to use a more recent module. Very Happy So use the one from the "Downloads/Bots" forum here.
Back to top
Sypher
Senior Member
Senior Member


Joined: 01 Jan 2004
Posts: 233
Location: The Netherlands
Reputation: 39.8Reputation: 39.8Reputation: 39.8Reputation: 39.8

PostPosted: Sun Jan 04, 2004 11:10 pm    Post subject: Reply with quote

I think he meant the msg-code? Smile

But does someone knows how to? Smile

_________________
Sypher
Developer of Codera
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl 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