TinyPortal

Development => Resources => Topic started by: eli on March 31, 2008, 02:36:38 PM

Title: Emote (/me) in shoutbox?
Post by: eli on March 31, 2008, 02:36:38 PM
I'm aware that [me={name}]action text[/me] works. However, I would like to make the /me command work as well. I'm quite surprised it doesn't, but I haven't explored the Subs.php or Post.php enough to figure out if the /me is altered through Post or Subs.

Anyways, the original question, how can I alter the TP Shoutbox (verion 0.9.8 and SMF v 1.1.4) to allow for /me?

And to answer the question that's likely to arrive, I have searched. The search function returned 8 pages or results, out of which I found only one other topic which actually spoke of the /me command, but found no solutions there, only discussion.
Title: Re: Emote (/me) in shoutbox?
Post by: G6Cad on March 31, 2008, 02:50:12 PM
There are no such function for the shoutbox, dont think it will be implemented eather for the next release
Title: Re: Emote (/me) in shoutbox?
Post by: JPDeni on March 31, 2008, 03:08:16 PM
The translation of /me takes place in Subs-Post.php and what it does is


// Replace /me.+?\n with [me=name]dsf[/me]\n.


The code for the replacement follows that line.

I suppose you could try copying that code to the shoutbox function in TPortal.php, or possibly you could move it all to the doBBC function so that it's only in one place.
Title: Re: Emote (/me) in shoutbox?
Post by: eli on March 31, 2008, 05:18:51 PM
I've looked through the TPortal.php, and it only makes the call to doUBBC for the content of the shouts, so I don't think there's anyplace appropriate to put that in there.

The only alternative is the doParseBBC function, but I can't seem to find a good place to put it. I think it would probably need reworking. I suppose I could ask over at SMF.org for more support on that.
Title: Re: Emote (/me) in shoutbox?
Post by: JPDeni on March 31, 2008, 05:50:14 PM

I've looked through the TPortal.php, and it only makes the call to doUBBC for the content of the shouts, so I don't think there's anyplace appropriate to put that in there.

You might be able to put it before the call do doUBBC, I think. It would have to be there anyway, because the code from Subs-Post.php just translates it into BBC.

The SMF folks will likely tell you to come here. :)
Title: Re: Emote (/me) in shoutbox?
Post by: eli on March 31, 2008, 06:58:28 PM
You wouldn't happen to be able to show where, would you? Have you looked at the code?
Title: Re: Emote (/me) in shoutbox?
Post by: JPDeni on March 31, 2008, 07:08:42 PM
This is purely a guess. I'm guaranteeing nothing. :)

In Tinyportal.php, before

$shouts .= doUBBC(censorText($myshout));


add


$myshout = preg_replace('~(?:\A|\n)/me(?: | )([^\n]*)(?:\z)?~i', '[me=' . $user_info['name'] . ']$1[/me]', $myshout);


I haven't worked with preg_replace a whole lot and I'm not a whiz at regular expressions, so I'm just copying the SMF code as it is.

I doubt that this will cause a rift in the time/space continuum if it doesn't work ;) but I wouldn't try it first on an active site. Be sure that you use a test site first.