/me (slash me) command

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Ideas Centre
Locked
MeDammit
Registered User
Posts: 3
Joined: Fri Apr 15, 2011 12:01 am

/me (slash me) command

Post 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
MeDammit
Registered User
Posts: 3
Joined: Fri Apr 15, 2011 12:01 am

Re: /me (slash me) command

Post 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
User avatar
AmigoJack
Registered User
Posts: 5757
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: /me (slash me) command

Post 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.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
MeDammit
Registered User
Posts: 3
Joined: Fri Apr 15, 2011 12:01 am

Re: /me (slash me) command

Post 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!
DJMO79
Registered User
Posts: 5
Joined: Mon Nov 05, 2012 9:14 pm

Re: /me (slash me) command

Post 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?
User avatar
AmigoJack
Registered User
Posts: 5757
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: /me (slash me) command

Post 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 ***/  
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
DJMO79
Registered User
Posts: 5
Joined: Mon Nov 05, 2012 9:14 pm

Re: /me (slash me) command

Post 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:
User avatar
AmigoJack
Registered User
Posts: 5757
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: /me (slash me) command

Post 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.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
DJMO79
Registered User
Posts: 5
Joined: Mon Nov 05, 2012 9:14 pm

Re: /me (slash me) command

Post 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!
User avatar
AmigoJack
Registered User
Posts: 5757
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: /me (slash me) command

Post 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 ***/
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
DJMO79
Registered User
Posts: 5
Joined: Mon Nov 05, 2012 9:14 pm

Re: /me (slash me) command

Post 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 :|
User avatar
ViolaF
Registered User
Posts: 1525
Joined: Tue Aug 14, 2012 11:52 pm

Re: /me (slash me) command

Post 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
DJMO79
Registered User
Posts: 5
Joined: Mon Nov 05, 2012 9:14 pm

Re: /me (slash me) command

Post 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_
Wulfric
Registered User
Posts: 26
Joined: Fri Nov 13, 2009 8:09 am

Re: /me (slash me) command

Post 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)
User avatar
AmigoJack
Registered User
Posts: 5757
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: /me (slash me) command

Post 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>
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.
Locked

Return to “[3.0.x] MOD Requests”