User Control Panel
Advertisements

HELP US, HELP YOU!

TRying to make PM

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Perl
View unanswered posts
Author Message
ugly.breath
Newbie
Newbie


Joined: 09 Mar 2005
Posts: 18

Reputation: 14.5

PostPosted: Fri Mar 11, 2005 5:45 am    Post subject: Reply with quote

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
Member


Joined: 31 Dec 2004
Posts: 134

Reputation: 19.2Reputation: 19.2

PostPosted: Fri Mar 11, 2005 7:11 am    Post subject: Reply with quote

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
Member


Joined: 31 Dec 2004
Posts: 134

Reputation: 19.2Reputation: 19.2

PostPosted: Fri Mar 11, 2005 7:14 am    Post subject: Reply with quote

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
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Fri Mar 11, 2005 7:35 am    Post subject: Reply with quote

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
Newbie


Joined: 09 Mar 2005
Posts: 18

Reputation: 14.5

PostPosted: Fri Mar 11, 2005 12:01 pm    Post subject: Reply with quote

Im having truble, can yoou explain in more detail. I cant get ti to work still!!! PLZ help
Back to top
JTW
God Like
God Like


Joined: 07 Mar 2004
Posts: 582
Location: Maidstone
Reputation: 73.3
votes: 4

PostPosted: Fri Mar 11, 2005 12:54 pm    Post subject: Reply with quote

WHy not use the call sub/function in the msn.pm ?
_________________
"Help us, Help you" - BotDepot
Back to top
ugly.breath
Newbie
Newbie


Joined: 09 Mar 2005
Posts: 18

Reputation: 14.5

PostPosted: Fri Mar 11, 2005 10:19 pm    Post subject: Reply with 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'

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!! Surprised

EDIT EDITED TYPOS
Back to top
M4RTIN
Member
Member


Joined: 31 Dec 2004
Posts: 134

Reputation: 19.2Reputation: 19.2

PostPosted: Sat Mar 12, 2005 8:30 am    Post subject: Reply with quote

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
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Sat Mar 12, 2005 8:56 am    Post subject: Reply with quote

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
Newbie


Joined: 09 Mar 2005
Posts: 18

Reputation: 14.5

PostPosted: Sun Mar 13, 2005 5:59 am    Post subject: Reply with quote

^

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
Member


Joined: 31 Dec 2004
Posts: 134

Reputation: 19.2Reputation: 19.2

PostPosted: Sun Mar 13, 2005 7:03 am    Post subject: Reply with quote

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
Upgraded Agent


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

PostPosted: Mon Mar 14, 2005 1:06 am    Post subject: Reply with quote

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/
Back to top
ugly.breath
Newbie
Newbie


Joined: 09 Mar 2005
Posts: 18

Reputation: 14.5

PostPosted: Mon Mar 21, 2005 8:31 am    Post subject: Reply with quote

umm.... its nto working on my bot for sum reason. PLZ PLZ PLZ help and sorry about all these problems!!!! Surprised
Back to top
JTW
God Like
God Like


Joined: 07 Mar 2004
Posts: 582
Location: Maidstone
Reputation: 73.3
votes: 4

PostPosted: Mon Mar 21, 2005 8:57 am    Post subject: Reply with quote

1.Learn Perl
2. look at code examples (keenies help system)

_________________
"Help us, Help you" - BotDepot
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