From 7196a2a4de2965c9a628032eed7a18735067fad1 Mon Sep 17 00:00:00 2001 From: Ketho Date: Sun, 18 Apr 2021 03:30:11 +0200 Subject: [PATCH] Add `/owo guild` option Test bc classic packaging --- .github/workflows/release.yml | 6 ++++- OwoSpeak.lua | 41 +++++++++++++++++++++++++---------- OwoSpeak.toc | 10 ++++----- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 196fa7a..e1a9e5d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,11 @@ jobs: - uses: BigWigsMods/packager@master with: - args: release.sh -g 1.13.4 + args: release.sh -g classic + + - uses: BigWigsMods/packager@master + with: + args: release.sh -g bc - uses: BigWigsMods/packager@master with: diff --git a/OwoSpeak.lua b/OwoSpeak.lua index fd883a3..163a259 100644 --- a/OwoSpeak.lua +++ b/OwoSpeak.lua @@ -9,8 +9,9 @@ local owos = { } local defaults = { - db_version = 1, + db_version = 2, enabled = true, + guild = true, } local db @@ -18,10 +19,13 @@ local hyperlinks = {} local function OnEvent(self, event, addon) if addon == "OwoSpeak" then - if not OwoSpeakDB or OwoSpeakDB.db_version < defaults.db_version then - OwoSpeakDB = CopyTable(defaults) - end + OwoSpeakDB = OwoSpeakDB or CopyTable(defaults) db = OwoSpeakDB + for k, v in pairs(defaults) do + if db[k] == nil then + db[k] = v + end + end self:UnregisterEvent("ADDON_LOADED") end end @@ -40,10 +44,20 @@ local function RestoreLink(s) return hyperlinks[n] end +local function ShouldOwo(chatType) + if db.enabled then + if chatType == "GUILD" then + return db.guild + else + return true + end + end +end + local makeowo = SendChatMessage -function SendChatMessage(msg, ...) - if db.enabled then +function SendChatMessage(msg, chatType, ...) + if ShouldOwo(chatType) then wipe(hyperlinks) local owo = owos[random(#owos)] local whatsthis = random(10) @@ -71,9 +85,9 @@ function SendChatMessage(msg, ...) s = whatsthis == 1 and s.." "..owo or s:gsub("!$", " "..owo) -- pwease owo wesponsibwy s = #s <= 255 and s:gsub("owo%d", RestoreLink) or msg - makeowo(s, ...) + makeowo(s, chatType, ...) else - makeowo(msg, ...) + makeowo(msg, chatType, ...) end end @@ -85,7 +99,12 @@ local EnabledMsg = { SLASH_OWOSPEAK1 = "/owo" SLASH_OWOSPEAK2 = "/owospeak" -SlashCmdList.OWOSPEAK = function() - db.enabled = not db.enabled - print("OwoSpeak: "..EnabledMsg[db.enabled]) +SlashCmdList.OWOSPEAK = function(msg) + if msg == "guild" then + db.guild = not db.guild + print("OwoSpeak: Guild - "..EnabledMsg[db.guild]) + else + db.enabled = not db.enabled + print("OwoSpeak: "..EnabledMsg[db.enabled]) + end end diff --git a/OwoSpeak.toc b/OwoSpeak.toc index 1c09bc9..f48b27e 100644 --- a/OwoSpeak.toc +++ b/OwoSpeak.toc @@ -1,9 +1,7 @@ -#@retail@ -## Interface: 80300 -#@end-retail@ -#@non-retail@ -# ## Interface: 11304 -#@end-non-retail@ +## Interface: 90005 +## Interface-Retail: 90005 +## Interface-Classic: 11306 +## Interface-BC: 20501 ## Version: @project-version@ ## Title: OwoSpeak ## Notes: Pwease owo wesponsibwy