Page 1 of 1

/me (slash me) command

Posted: Fri Apr 15, 2011 12:06 am
by MeDammit
So I'm sure that has be covered somewhere in the 750 pages of requests, however no method of searching with a "/" in the textbox returns results.

So here is my question:

Where would I need to modify code to add /me into phpBB 3.0.8? If you could point me to where this has already been covered, thanks. If it hasn't been done (unlikey), please point me in the direction of the php file to modify and where the approximate code block is that posts are entered into the db.

Thanks,
Robert

Re: /me (slash me) command

Posted: Fri Apr 15, 2011 2:34 am
by MeDammit
Thanks for approving me. Definitely hoping to get the resolved and hopefully the "slash" in the description will help other people looking to find this

Re: /me (slash me) command

Posted: Fri Apr 15, 2011 7:09 am
by AmigoJack
The following will naively replace any occuring /me (case insensitive) surrounded by whitespaces with the current username when creating (not editing) a post. Hence if the author's nickname changes in the future the substituted username in the post itself won't be updated. This is the least obstructive solution without impacting performance at all.

Open /posting.php and find:

Code: Select all

    // Parse Attachments - before checksum is calculated
    $message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh); 
After, add:

Code: Select all

    /*** 2011-04-15 BEGIN AmigoJack
        Convert "/me" to current poster ***/
    if( $mode!= 'edit' ) {
        $message_parser-> message= preg_replace( '#(^|\\s)/me($|\\s)#i', '$1'. $user-> data['username']. '$2', $message_parser-> message );
    }
    /*** 2011-04-15 END ***/ 
Tested.

Re: /me (slash me) command

Posted: Sat Apr 16, 2011 4:27 am
by MeDammit
Thank you very much. Quick easy implementation, works great.

I appreciate it, hopefully someone else will be able to find this helpful as well!

Re: /me (slash me) command

Posted: Mon Nov 05, 2012 9:20 pm
by DJMO79
i love this mod, but is there a possibility to replace the /me command with *username? so with the asterisk before the username?

Re: /me (slash me) command

Posted: Tue Nov 06, 2012 6:02 am
by AmigoJack
That would be:

Code: Select all

    /*** 2011-04-15 BEGIN AmigoJack
        Convert "/me" to current poster ***/
    if( $mode!= 'edit' ) {
        $message_parser-> message= preg_replace( '#(^|\\s)/me($|\\s)#i', '$1*'. $user-> data['username']. '$2', $message_parser-> message );
    }
    /*** 2011-04-15 END ***/  

Re: /me (slash me) command

Posted: Tue Nov 06, 2012 8:10 am
by DJMO79
AmigoJack wrote:That would be:

Code: Select all

    /*** 2011-04-15 BEGIN AmigoJack
        Convert "/me" to current poster ***/
    if( $mode!= 'edit' ) {
        $message_parser-> message= preg_replace( '#(^|\\s)/me($|\\s)#i', '$1*'. $user-> data['username']. '$2', $message_parser-> message );
    }
    /*** 2011-04-15 END ***/
thanx! It works great. Yet another question from on of the users on my forum, is if there is a possibility to get the converted text in a anothor color :oops:

Re: /me (slash me) command

Posted: Tue Nov 06, 2012 9:07 am
by AmigoJack
Yes. Compare my last code with the original code - I'm sure you'll find out where to add any text you want. So you can add aswell [color=] and such.

Re: /me (slash me) command

Posted: Mon Nov 12, 2012 5:08 pm
by DJMO79
AmigoJack wrote:Yes. Compare my last code with the original code - I'm sure you'll find out where to add any text you want. So you can add aswell [color=] and such.
well, together with my friend studied about it, but the colorizing of it in my theme has something do with the css orso. Didn't understand what me ment exactly, but thnx voor the help!

Re: /me (slash me) command

Posted: Mon Nov 12, 2012 5:44 pm
by AmigoJack
Seriously.

Code: Select all

    /*** 2011-04-15 BEGIN AmigoJack
        Convert "/me" to current poster with leading asterisk in green color ***/
    if( $mode!= 'edit' ) {
        $message_parser-> message= preg_replace( '#(^|\\s)/me($|\\s)#i', '$1[color=green]*'. $user-> data['username']. '[/color]$2', $message_parser-> message );
    }
    /*** 2011-04-15 END ***/

Re: /me (slash me) command

Posted: Mon Nov 12, 2012 9:32 pm
by DJMO79
AmigoJack wrote:Seriously.

Code: Select all

    /*** 2011-04-15 BEGIN AmigoJack
        Convert "/me" to current poster with leading asterisk in green color ***/
    if( $mode!= 'edit' ) {
        $message_parser-> message= preg_replace( '#(^|\\s)/me($|\\s)#i', '$1[color=green]*'. $user-> data['username']. '[/color]$2', $message_parser-> message );
    }
    /*** 2011-04-15 END ***/ 
i love it that you want to help me, because i don't have got any knowledge of PHP. And yes, your last solution posts the user name in the green color, but i want the whole sentence (or action) in the same color.

to be more specific, i wish i could use it aswell at as a BBcode ..

for example:
[me=DJMO] is going to throw her computer out of the window[/me] en that is would be post as:
*DJMO is going to throw her pc out of te window
And than the whole sentence in a different color of the main colors.

i know i'm difficult :|

Re: /me (slash me) command

Posted: Mon Nov 12, 2012 9:56 pm
by ViolaF
Go to your ACP > Posting > BBcodes

BBCode usage

Code: Select all

[me={TEXT1}]{TEXT2}[/me] 
HTML replacement

Code: Select all

<span style="color:green;">*{TEXT1} {TEXT2}</span> 
change green with whatever color

Re: /me (slash me) command

Posted: Mon Nov 12, 2012 10:40 pm
by DJMO79
ViolaF wrote:Go to your ACP > Posting > BBcodes

BBCode usage

Code: Select all

[me={TEXT1}]{TEXT2}[/me]
HTML replacement

Code: Select all

<span style="color:green;">*{TEXT1} {TEXT2}</span>
change green with whatever color

i'm ever gratefull to you _O_

Re: /me (slash me) command

Posted: Thu May 23, 2013 3:03 pm
by Wulfric
==:: Another Method ::==

The way I achieved this was

File: includes/functions_content.php
FIND:

Code: Select all

?>
ADD BEFORE
Post the content on a new line BEFORE the above find.

Code: Select all

/**
* Wulfric
* Parses to replace /me with username and color
* Gives HTML output, use only before final output
*/

function replace_slash_me_display($text, $username, $color) {
    $text = preg_replace( '#(^)/me(\s+.+)($)#im', '$1<i><b>* <font color="#'. $color . '">' . $username . '</font></b><font color="red">$2</font></i>$3', $text );
    return $text;
}
File: viewtopic.php
FIND:

Code: Select all

    $message = bbcode_nl2br($message);
 
ADD BEFORE
Post the content on a new line BEFORE the above find.

Code: Select all

        // BEGIN Wulfric - replace '/me'
        $message = replace_slash_me_display($message, $row['username'], $row['user_colour']);
        // END - replace '/me'
 
The reason I chose to do this way was:
  • It does not actually change the input being sent, only modifies the display
  • When user group/colour is changed it will always adapt
  • Editing is easier without extra BBCODE to handle
(It's basically the same method using preg_replace, just a different concept. (Only changing the display parsing)

Re: /me (slash me) command

Posted: Thu May 23, 2013 3:28 pm
by AmigoJack
Wulfric wrote:

Code: Select all

<font
We have 2013 and you're still using this dinosaur? Use at least proper XHTML, like:

Code: Select all

<em style="font-weight: bold; color: #FFF">theusername</em>