• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Add-on /me

Chris D

XenForo developer
Staff member
#1
This should be a relatively simple one, but I can't quite get there with it. I want to add a code so that it turns

/me would like to learn XenForo addons

into

*Yorick would like to learn XenForo addons



Now obviously this could be done, and relatively easily, by using a [me] bbcode, but that's just not the same. So then it occurs to me that since the http://xenforo.com/community/threads/bd-tag-me.6762 Addon works by using @ in posts, that it should be possible to do a /me, and would in fact be a lot simpler since there's no need to query the database for users, no need for options or an alerts system. But I'm not 100% sure on how to go about it.
 

Chris D

XenForo developer
Staff member
#4

bambua

Well-known member
#5
The difficulty with this vs. say in mIRC, in mIRC you are entering a command...in a forum setting your using some mechanism to do a find and replace in the post. That's why bbcodes have the opening and closing tags, it makes it easy to find the beginning and end in a programmatic way. The reason the @ addon works is that in general names don't have spaces in them, it makes it a lot easier to match. A multiple word command with only the first character to find it becomes very costly to look for.
 

Chris D

XenForo developer
Staff member
#6
The difficulty with this vs. say in mIRC, in mIRC you are entering a command...in a forum setting your using some mechanism to do a find and replace in the post. That's why bbcodes have the opening and closing tags, it makes it easy to find the beginning and end in a programmatic way. The reason the @ addon works is that in general names don't have spaces in them, it makes it a lot easier to match. A multiple word command with only the first character to find it becomes very costly to look for.
That makes a lot of sense to me, except that aren't I only using trying to use a single word command with /me?

Here's where I am with this now:
I've gotten /me to work, but it only does it if there's a line of text before AND after it. Something to do with the regex query. I also think that I should be able to call the poster as the replacement text, but $message.username is coming up as undefined because it's, obviously, not global. So I need to figure out how to define that properly. And then this might eventually work.