User Control Panel
Advertisements

HELP US, HELP YOU!

Double Line breaks

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


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun Apr 24, 2005 8:41 am    Post subject: Reply with quote

in many of my commands i have things like this:

Code:
my $websmenu = <br />"   Google query here - Search google.<br />   spellcheck word - Check a words spelling<br />   translate text*fromlanguage*tolanguage - Translator<br />   dict word - Dictionary<br />   hsec - Get The US Homeland security level.<br />   acro acronym - Gets the meaning of an acronym<br />   speech - Text to speech with many voices!<br />   horoscope sign - Get you daily horoscope!<br />   whatpulse user - Get a what pulse profile";<br /><br />&send($self, $websmenu,$username, Color => "005500");<br />


When it is printed in the console it appears correctly, but when it is received over MSN, extra line breaks are inserted, ie.

Quote:
hsec - Get The US Homeland security level.
acro acronym - Gets the meaning of an acronym
speech - Text to speech with many voices!


becomes

Quote:
hsec - Get The US Homeland security level.

acro acronym - Gets the meaning of an acronym

speech - Text to speech with many voices!




This is the sending part of my bot:

Code:
<br />   print colored ("----------------------------------------------------------------------------\n", ' bold red');<br />   print colored ("<$bot_name> MSN ($time): $response\n", ' bold green');<br />   print colored ("----------------------------------------------------------------------------\n", ' bold red');<br />   <br />   $self->sendMessage($response, %{$bot->{Settings}->{Style}}, @_);


Any ideas on why this is happening?
Back to top
Dazzy
Agent
Agent


Joined: 09 Jan 2004
Posts: 1731

Reputation: 72.3

PostPosted: Sun Apr 24, 2005 9:22 am    Post subject: Reply with quote

try putting \n at the end of every line where you want a new one to begin....
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun Apr 24, 2005 9:27 am    Post subject: Reply with quote

then i would have even more breaks unless i put it all on one line with is disorganised, i think its an msn.pm issue or something Sad
Back to top
malefactor
Member
Member


Joined: 27 Jan 2005
Posts: 109
Location: Lewiston, ME
Reputation: 17.7Reputation: 17.7

PostPosted: Sun Apr 24, 2005 11:01 am    Post subject: Reply with quote

take out the hard line breakes and use \n

Code:
my $websmenu =<br />" Google query here - Search google.\nspellcheck word - Check a words spelling";<br /><br />or<br /><br />my $websmenu =" Google query here - Search google.";<br />my $websmenu .="\nspellcheck word - Check a words spelling";<br />


AOL does the same thing to trillian users when I load data from a file and dump it directly in a message without chomping and using \n.
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun Apr 24, 2005 2:45 pm    Post subject: Reply with quote

shame there isnt a way around, now i will have to change everything including my text file menus....
Back to top
Cer
Upgraded Agent
Upgraded Agent


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

PostPosted: Sun Apr 24, 2005 7:28 pm    Post subject: Reply with quote

Try chomping it.

chomp $websmenu;

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Mon Apr 25, 2005 5:29 am    Post subject: Reply with quote

chomped it is the same, i dont remember having this issue when my bot was on windows, only now its on linux does it seem to have occured.
Back to top
Cer
Upgraded Agent
Upgraded Agent


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

PostPosted: Mon Apr 25, 2005 11:46 am    Post subject: Reply with quote

QUOTE(draget @ Apr 25 2005, 01:29 AM)
chomped it is the same, i dont remember having this issue when my bot was on windows, only now its on linux does it seem to have occured.
[right][snapback]48003[/snapback][/right]


Yeah, I wrote a chat script using a Windows server and in Linux it had that line break problem. I had to go in and do more with the stuff manually.....

But my problem was in opening files with multiple lines, and I fixed it by just turning \r\n\r\n into \n or something like that. I don't think that helps you much though since you're not using arrays and foreach loops.

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Mon Apr 25, 2005 1:08 pm    Post subject: Reply with quote

maya commands are not added by requiring.

they are text files that are read in.


can you expand on your solution?


thanks

draget
Back to top
Dazzy
Agent
Agent


Joined: 09 Jan 2004
Posts: 1731

Reputation: 72.3

PostPosted: Mon Apr 25, 2005 3:00 pm    Post subject: Reply with quote

ah, that may be the link with what cer said, if you used the files on linux then its formatted with \n\r or something i think but \n for windows, somethink like that anyway,

tried opening the file on linux? and saving...
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Mon Apr 25, 2005 4:39 pm    Post subject: Reply with quote

\n works fine on Linux.
_________________
Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Back to top
malefactor
Member
Member


Joined: 27 Jan 2005
Posts: 109
Location: Lewiston, ME
Reputation: 17.7Reputation: 17.7

PostPosted: Mon Apr 25, 2005 4:56 pm    Post subject: Reply with quote

perhaps instead of altering each file the way I suggested you could just transliterate it and get rid of the \r in you im handler before it gets sent.

Something like:
$websmenu =~ tr/\r//;
Back to top
Cer
Upgraded Agent
Upgraded Agent


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

PostPosted: Mon Apr 25, 2005 7:33 pm    Post subject: Reply with quote

What I ended up doing (since my chat script is a line-by-line basis) is just removing \r and \n from each line.

Here's an example of the code (I know it's poorly coded but I coded my chat room a good long time ago Wink ).
Code:
# Load the configuration.<br />%cfg;<br />open (CFG, "$path{config}");<br />@data = <CFG>;<br />close (CFG);<br />chomp @data;<br />foreach $line (@data) {<br />     if ($line !~ /^\#/) {<br />          ($what,$is) = split(/=/, $line, 2);<br />          $what = lc($what);<br />          $what =~ s/ //g;<br /><br />          chomp $is;<br />          chomp $what;<br /><br />          $is =~ s/\n//g;<br />          $is =~ s/\r//g;<br />          $what =~ s/\n//g;<br />          $what =~ s/\r//g;<br /><br />          $cfg{$what} = $is;<br />     }<br />}


I don't know how well it will work for your case though, since Perl codes usually need more than one line. Of course you could go on a foreach through the @filedata array and push each line onto an @newarray or something when you're done with it.

_________________
Current Site (2008) http://www.cuvou.com/
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Tue Apr 26, 2005 2:12 am    Post subject: Reply with quote

Dazzy!


Opened and resaved in pico and now it works wonderfully!

thanks
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