|
| Author |
Message |
ugly.breath Newbie

Joined: 09 Mar 2005 Posts: 18
 
|
Posted: Fri Mar 11, 2005 5:45 am Post subject: |
|
|
Hello, I am trying to make a command to be able to PM ppl.
But I need it to go like: !pm name@address.com Hello blah blah blah
But when I excicute the command it goes: 'You have pm'd name@address.com' Hello blah blah blah with the message ' '!
This is the code I am making so far:
| Code: | | <br />{<br /> open (DATA, ">>./$1.txt");<br /> print DATA " <MESSAGE FROM @username: $2>... ";<br /> close(DATA); <br /> &send($self, "You PM'd: '$1' with the message: :'$2'");<br />} |
PLZ HELP |
|
| Back to top |
|
 |
M4RTIN Member

Joined: 31 Dec 2004 Posts: 134
  
|
Posted: Fri Mar 11, 2005 7:11 am Post subject: |
|
|
To read your pm's it should be this.
| Code: | | {<br /> open (DATA, "./$user.txt");<br /> close(DATA); <br />&send($self, "(*) PM's\n\n $DATA");<br />} |
|
|
| Back to top |
|
 |
M4RTIN Member

Joined: 31 Dec 2004 Posts: 134
  
|
Posted: Fri Mar 11, 2005 7:14 am Post subject: |
|
|
Sorry for double posting, I read what you first said wrong,
And I'm not sure why that isnt working for you. |
|
| Back to top |
|
 |
Mojave Almost An Agent

Joined: 01 Nov 2003 Posts: 1434
 
|
Posted: Fri Mar 11, 2005 7:35 am Post subject: |
|
|
You're actually not showing us the most crucial code - the regular expression you are using to get the email and the message. It looks like that is faulty and is grabbing the message into the email.
Let's say you have everything after the !pm (and spaces) inside $msg:
| Code: | | my ($email, $message) = ('', '');<br />if( $msg =~ /^(.+?)\s+(.+)$/i )<br />{<br /> ($email, $message) = ($1, $2);<br />} |
That will break the message on the first space, getting the email and message. Notice how I store the values in separate variables rather than using $1 and $2 - you should always do this since $1 and $2 are special variables and can redefined (especially if you do another regular expression). You could get the parts $1 and $2 stored in the new variables in one line, but that might confuse you too much. So it's best to be explicit. |
|
| Back to top |
|
 |
ugly.breath Newbie

Joined: 09 Mar 2005 Posts: 18
 
|
Posted: Fri Mar 11, 2005 12:01 pm Post subject: |
|
|
| Im having truble, can yoou explain in more detail. I cant get ti to work still!!! PLZ help |
|
| Back to top |
|
 |
JTW God Like

Joined: 07 Mar 2004 Posts: 582 Location: Maidstone
  votes: 4
|
Posted: Fri Mar 11, 2005 12:54 pm Post subject: |
|
|
WHy not use the call sub/function in the msn.pm ? _________________ "Help us, Help you" - BotDepot |
|
| Back to top |
|
 |
ugly.breath Newbie

Joined: 09 Mar 2005 Posts: 18
 
|
Posted: Fri Mar 11, 2005 10:19 pm Post subject: |
|
|
Well i'm sort of getting no-where. The code you supplied Mojave, is having some troubles.
I write: !pm email@domain.com PLZ WORK and it still says: You PM'd: 'pm' with the message: :'email@domain.com PLZ WORK'
But then if i write: !pmemail@domain.com PLZ WORK it goes: You PM'd: 'pmemail@domain.com' with the message: :'PLZ WORK'
And it doesnt even save the file. Ill give you a full script of what ive got:
| Code: | | <br /><br /><br />{<br /> open (DATA, ">>.logs/users/notes/pm/$email.txt");<br /> my ($email, $message) = ('', '');<br />if( $msg =~ /^(.+?)\s+(.+)$/i )<br />{<br /> ($email, $message) = ($1, $2);<br />}<br /> print DATA " <MESSAGE FROM @username: $message>... ";<br /> close(DATA); <br /> &send($self, "You PM'd: '$email' with the message: :'$message'");<br />} |
PLZ help!! 
EDIT EDITED TYPOS |
|
| Back to top |
|
 |
M4RTIN Member

Joined: 31 Dec 2004 Posts: 134
  
|
Posted: Sat Mar 12, 2005 8:30 am Post subject: |
|
|
Ok,
Here's a simple PM code I wrote just now.
Hopefully this should help.
+-----------------------------------------------------------------------------------------+ Create a new command called: pm.pl +-----------------------------------------------------------------------------------------/
| Code: | | <br />if ($msg eq "PM") {<br /><br />&send($self, "(#) PM System (#)\n\nError, Type: PM <email>,<message>");<br /><br />}<br /><br />if ($msg =~ /^PM (.*),(.*)$/) {<br /><br />open(FILE, "./PM System/$1");<br />print(FILE "+ PM from $user - $2");<br />close(FILE);<br /><br />}<br /> |
+-----------------------------------------------------------------------------------------/ Save and close. +-----------------------------------------------------------------------------------------+
Now, Here is the reading system.
+-----------------------------------------------------------------------------------------+ Create a new command called: readpm.pl +-----------------------------------------------------------------------------------------/
| Code: | | <br />if ($msg eq "ReadPM")<br />{<br /><br />open (DATA, "./PM System/$user.txt");<br />close(DATA); <br />&send($self, "(#) PM System (#)\n\n You have these PM's,\n$DATA");<br /><br />}<br /> |
+-----------------------------------------------------------------------------------------/ Save and close. +-----------------------------------------------------------------------------------------+
There. <_< |
|
| Back to top |
|
 |
Mojave Almost An Agent

Joined: 01 Nov 2003 Posts: 1434
 
|
Posted: Sat Mar 12, 2005 8:56 am Post subject: |
|
|
| Quote: | Well i'm sort of getting no-where. The code you supplied Mojave, is having some troubles.
I write: !pm email@domain.com PLZ WORK and it still says: You PM'd: 'pm' with the message: :'email@domain.com PLZ WORK'
But then if i write: !pmemail@domain.com PLZ WORK it goes: You PM'd: 'pmemail@domain.com' with the message: :'PLZ WORK' |
As I said:
| Quote: | | Let's say you have everything after the !pm (and spaces) inside $msg: |
So, you need to remove the !pm from the beginning of the message. Most command bots I've seen automatically remove that so I assumed yours did too. In any case, you could just rewrite the regular expression to deal with it. Seriously, this is BASIC regular expressions. You should read and learn about them, they are extremely powerful. Martin has shown you how to do it correctly. |
|
| Back to top |
|
 |
ugly.breath Newbie

Joined: 09 Mar 2005 Posts: 18
 
|
Posted: Sun Mar 13, 2005 5:59 am Post subject: |
|
|
^
Thanks, but as you know I am new and still learning
EDIT Btw I have a mayabot v4 which doesnt use . pl files, it uses .maya files, what do I do there?
PLZ reply |
|
| Back to top |
|
 |
M4RTIN Member

Joined: 31 Dec 2004 Posts: 134
  
|
Posted: Sun Mar 13, 2005 7:03 am Post subject: |
|
|
Take my command, and just instead of making a .pl file, just make a maya file. Simple.
They may need a little converting ^_^ |
|
| Back to top |
|
 |
Cer Upgraded Agent

Joined: 03 Feb 2004 Posts: 3776 Location: Michigan
  votes: 4
|
Posted: Mon Mar 14, 2005 1:06 am Post subject: |
|
|
QUOTE(ugly.breath @ Mar 13 2005, 12:59 AM) ^
Thanks, but as you know I am new and still learning
EDIT Btw I have a mayabot v4 which doesnt use . pl files, it uses .maya files, what do I do there?
PLZ reply [right][snapback]46837[/snapback][/right]
|
Some people don't use the .pl extension on purpose (because PL files can be double-clicked and executed, and most of the bot's sub-files (like commands or other external files) won't run correctly if you just run them by themselves. So some bot coders only leave the main file a PL, or they use a batch file, but all the external files are TXT's or any other extension). _________________ Current Site (2008) http://www.cuvou.com/ |