phanx-wow / PhanxChat

WoW AddOn — Removes chat frame clutter and adds some functionality.
Other
2 stars 3 forks source link

Smart group channel #9

Closed 2ndHouse closed 7 years ago

2ndHouse commented 7 years ago

Hoping for a lightweight addon that creates a smart group (/gr or /group) channel. The main reason I want this is for macros to print to the correct channel. Currently the command "/i" does not work correctly for premade parties and raids.

I know both Prat and Chatter can do this but they both do way more than I want. Is it something you might implement? If not, then do you know of any addons other than Prat or Chatter that might have this functionality?

Phanx commented 7 years ago

Stick this in somewhere and let me know if it works:

local Send = SendChatMessage

function SendChatMessage(text, chatType, ...)
    chatType = strupper(chatType or "SAY")

    if chatType == "INSTANCE_CHAT" and not IsInGroup(LE_PARTY_CATEGORY_INSTANCE) and IsInGroup(LE_PARTY_CATEGORY_HOME) then
        -- Convert /i to /ra or /p
        chatType = IsInRaid() and "RAID" or "PARTY"
    elseif (chatType == "RAID" or chatType == "RAID_WARNING") and not IsInRaid() and IsInGroup() then
        -- Convert /ra and /rw to /i or /p
        chatType = IsInGroup(LE_PARTY_CATEGORY_INSTANCE) and "INSTANCE_CHAT" or "PARTY"
    end

    Send(text, chatType, ...)
end
2ndHouse commented 7 years ago

I was trying out an addon called MacroTalk to fix this, but it was handling it wrong. A user on it's project page posted this code, and it seems to be simple and works...although need to test in premades still. It just needs assigned to a /gr or /group command.

local channel = IsInGroup(2) and "INSTANCE_CHAT" or IsInRaid() and "RAID" or IsInGroup() and "PARTY"

Phanx commented 7 years ago

Please try the code I posted. Rather than add a new command, it just fixes the existing channel commands to downsize in smaller groups, which seems better (doesn't require learning a new command or editing existing macros) for users.

No other changes occur; you'll still get "You aren't in a party" etc. if you aren't in a group at all, and no upsizing is done (eg. using /p in a raid won't send to /ra).

2ndHouse commented 7 years ago

OK, inserted your code into core.lua and tested it out tonight. It seems to be working correctly using /i in my macros, even in premades. Also didn't see any errors. Working great, thanks!

2ndHouse commented 7 years ago

Well test in a raid premade at least, have not had the opportunity to test in a party premade yet, but guessing it will work.