Module:Messages

-- The following pages are related: https://fapceo.miraheze.org/wiki/Module:Messages https://fapceo.miraheze.org/wiki/Module:Messages/data

local getArgs = require('Module:Arguments').getArgs local p = {} local inboxes = mw.loadData('Module:Messages/data') -- Keep "Girls" in alphabetical order. Everything else in release date order. local inbox_groups = { ["Girls"] = { "Alexis", "Amanda", "Amber", "Anika", "Aysha", "Ayumi", "Blossom", "Cassandra", "Charlotte", "Chloe", "Cressida", "Dalla", "Delilah", "Dita", "Dominique", "Eira", "Faye", "Holly", "Ingrid", "Irene", "Jade", "Judy", "Kelly", "Lana", "Laura", "Lisa", "Lizzie", "Lorelei", "M.I.A.", "M.I.A. 2.0", "Maria", "Mrs. Claus", "Mrs. Rider", "Nova", "Olivia", "Penny", "PrincessCumXXX", "Renée", "Rose", "Roxanne", "Sara", "Saya", "Scarlett", "Skyler", "Solazola", "Tasha", "Victoria", "Vivian", "Yrelianna", "Zoe" }, ["Group Chats"] = { "Group Chat", "Sex Night", "Black Friday", "Godly Encounters", "Service Girls", "Stellar Whores", "Wild Things", "Game on!", "FAP Heroverse!", "Gangbang Diamond Heist", "Beach House Orgy", "Wasteland Howlers", "Catfight! Group Chat" }, ["Panoramas"] = { "Summer Chat", "Winter Wonderland", "Before Sunset", "After Midnight", "Summer Sundays", "Dungeon of Lust", "Holiday Wonderland", "Easter Island", "Christmas Runaway" }, ["Newsfeed"] = { "Newsfeed" }, }

--[[

-- Generate table for current girl (her page). -- Generate table for INBOX_NAME. -- Generate single table with threads from inbox_groups[GROUP] inboxes. -- Generate table with threads that picture/video contain current girl (her page). -- Generate table with threads that picture/video contain GIRL_NAME. -- Generate table with statistics about gallery. Count Pics, Videos and Panorama Parts. -- Generate panorama with all pictures. -- Generate categories for all girls in the given panorama.

INBOX_NAME and GROUP should be typed without quotations "" Mrs. Rider NOT "Mrs. Rider" Group Chats NOT "Group Chats"

]]

function p.main(frame) local args = getArgs(frame, {parentFirst = true}) if args[1] == "GenerateInbox" and args[2] ~= nil then return p.messages_single(args[2]) elseif args[1] == "GenerateInbox" then local girl_name = mw.title.getCurrentTitle.subpageText return p.messages_single(girl_name) elseif args[1] == "GenerateGroup" and args[2] ~= nil then return p.messages_group(args[2]) elseif args[1] == "GenerateGirlPresent" and args[2] ~= nil then return p.messages_girl_present(args[2]) elseif args[1] == "GenerateGirlPresent" then local girl_name = mw.title.getCurrentTitle.subpageText return p.messages_girl_present(girl_name) elseif args[1] == "GalleryStats" then local girl_name = mw.title.getCurrentTitle.subpageText return p.gallery_stats elseif args[1] == "Panorama" and args[2] ~= nil then return p.panorama_page(args[2]) elseif args[1] == "PanoramaCategories" and args[2] ~= nil then return p.panorama_page_categories(args[2]) end

return "" end

function count_elems(arr) local count = 0 for _, elem in pairs(arr) do   count = count + 1 end return count end

-- This function returns rows of a given thread. -- 'girl' parameter is optional to specify to include only pictures with a given girl. -- The beginning and end of the table should be added separately! function add_thread(thread, inbox_name, girl) -- Check if rewards is present in Module:Messages/data if thread.rewards == nil then return " Missing rewards list in Module:Messages/data "..inbox_name.." in "..thread.title end -- Construct Title column. local title = {} local rowspan = 0 local tab = {} if girl == nil then rowspan = count_elems(thread.rewards) else rowspan = count_girl_in_thread(girl, thread) -- No pictures with girl. Return nothing! if rowspan == 0 then return "" end end

title[#title+1] = "style=\"text-align: left;\" " if rowspan > 1 then title[#title+1] = "rowspan=\""..rowspan.."\" " end title[#title+1] = "| " if thread.thumbnail ~= nil then title[#title+1] = "" title[#title+1] = "" title[#title+1] = "" end title[#title+1] = ""..thread.title.."" if thread.thumbnail ~= nil then title[#title+1] = " " end table.insert(tab, "| "..table.concat(title, ""))

-- Go through rewards. for _, reward in ipairs(thread.rewards) do     -- girl == nil -> We want all threads. -- girl ~= nil -> We want only those where girl is present. if girl == nil or is_girl_present(girl, reward.girls, thread.title) then local cell_settings = {"| style=\"vertical-align:middle; "}       if string.find(reward.type, "Picture") then          table.insert(cell_settings, "background-color:#FFBBCC\" ") elseif string.find(reward.type, "Video") then table.insert(cell_settings, "background-color:#EEBBFF\" ")       elseif string.find(reward.type, "Panorama") then          table.insert(cell_settings, "background-color:#FFCCBB\" ") else table.insert(cell_settings, "background-color:#00EFFC\" ")       end        -- Insert Reward column.        table.insert(tab, table.concat(cell_settings, "").."| "..reward.type)

if reward.thumbnail == nil then table.insert(tab, table.concat(cell_settings, "").." | N/A") else table.insert(tab, table.concat(cell_settings, "").." | ") end

-- Check if unlock is present in Module:Messages/data if reward.unlock == nil then return " Missing unlock list in Module:Messages/data "..name.." in "..thread.title end

local u = {} for _, unlock in ipairs(reward.unlock) do         if unlock.event ~= nil and unlock.cost ~= nil then if unlock.name ~= nil then u[#u+1] = unlock.cost.." from "..""..unlock.name.."" else u[#u+1] = unlock.cost.." from "..""..unlock.event.."" end elseif unlock.other ~= nil then u[#u+1] = unlock.other else u[#u+1] = "Insert Data to Module:Messages/data." end end -- Insert Unlocked For column. Each Event in new line table.insert(tab, "| "..table.concat(u, " ")) -- Insert end of row. table.insert(tab, "|-") end end return table.concat(tab, "\n") end

-- This function returns inside of the table. -- The beginning and end of the table should be added separately! --[[   local tab = {    '{| class="wikitable" style="width:70%;"',    '|-',      }

table.insert(tab, get_inbox_data(name, inbox_data))

-- End table. table.insert(tab, "|}") ]] function get_inbox_data(name, inbox_data) if inbox_data == nil then return " Missing chat in Module:Messages/data "..name end

local tab = {} table.insert(tab, "! colspan=\"4\" style=\"text-align: center;\" "..                   "|  "..                    inbox_data.title.." "..                    "") table.insert(tab, "|-") table.insert(tab, "! Title") table.insert(tab, "! Reward") table.insert(tab, "! Thumbnail") table.insert(tab, "! Unlocked For") table.insert(tab, "|-")

-- Check if threads is present in Module:Messages/data if inbox_data.threads == nil then return table.concat(tab, "\n") --return " Missing threads list in Module:Messages/data "..name end

for _, thread in ipairs(inbox_data.threads) do   table.insert(tab, add_thread(thread, name)) end return table.concat(tab, "\n") end

function p.messages_group(group) if inbox_groups[group] ~= nil then local tab = { '{| class="wikitable" style="width:85%; text-align: center;"', '|-',       }    for _, chat_name in ipairs(inbox_groups[group]) do      table.insert(tab, get_inbox_data(chat_name, inboxes[chat_name])) end -- End table. table.insert(tab, "|}") return table.concat(tab, "\n") end return "" end

function p.messages_single(single) if inboxes[single] ~= nil then local tab = { '{| class="wikitable" style="width:85%; text-align: center;"', '|-',       }

table.insert(tab, get_inbox_data(single, inboxes[single])) -- End table. table.insert(tab, "|}") return table.concat(tab, "\n") end return "" end

-- Count total occurrences in the whole thread. For rowspan of chat column. function count_girl_in_chat(girl, chat) if chat == nil or chat.threads == nil then return 0 end local count = 0 -- Go through threads for _, thread in ipairs(chat.threads) do   count = count + count_girl_in_thread(girl, thread) end return count end

-- Count total occurrences in the whole thread. For rowspan of thread column. function count_girl_in_thread(girl, thread) if thread == nil then return 0 end local count = 0 -- Go through rewards. for _, reward in ipairs(thread.rewards) do   -- Go through rewards. if is_girl_present(girl, reward.girls, thread.title) then count = count + 1 end end return count end

-- Simple search if the girl is present in the list. function is_girl_present(girl, girls, title) if girls ~= nil then for _, girl_name in ipairs(girls) do     if girl_name == girl then return true end end else mw.log("Missing _girls_ list in thread: " .. title) end return false end

-- Get list of available inboxes from current groups. Starts with Girls. function list_of_inboxes local list = {} for _, girl in ipairs(inbox_groups["Girls"]) do   list[#list+1] = girl end

for group_name, group in pairs(inbox_groups) do   if group_name ~= "Girls" then for _, girl in ipairs(group ) do       list[#list+1] = girl end end end return list end

function p.messages_girl_present(girl) local tab = { '{| class="wikitable" style="width:85%; text-align: center;"', '|-',     }    table.insert(tab, "! colspan=\"5\" | "..                     girl.." can also be found in those Chats and Threads") table.insert(tab, "|-") table.insert(tab, "! Chat") table.insert(tab, "! Title") table.insert(tab, "! Reward") table.insert(tab, "! Thumbnail") table.insert(tab, "! Unlocked For") table.insert(tab, "|-") local count = 0 -- Iterate through all inboxes. for _, name in ipairs(list_of_inboxes) do   local inbox_data = inboxes[name] local count_all = 0 if (girl ~= name) then count_all = count_girl_in_chat(girl, inbox_data) end if count_all > 0 then count = count + 1 -- Construct Chat column. local chat = {} -- Make rowspan correct. if count_all > 1 then chat[#chat+1] = "rowspan=\""..count_all.."\" " end -- Add separator 'settings | data/text' chat[#chat+1] = "| " if inbox_data.picture ~= nil then chat[#chat+1] = " " end chat[#chat+1] = " "..inbox_data.title.."" table.insert(tab, "| style=\"vertical-align:middle;\" "..table.concat(chat, "")) -- Add valid threads. for _, thread in ipairs(inbox_data.threads) do       t = add_thread(thread, name, girl) if t ~= nil and t ~= "" then table.insert(tab, t)       end end end end

-- End table. table.insert(tab, "|}") if count > 0 then return table.concat(tab, "\n") else return "" -- Possible return value if there are no other threads showcasing the girl. end end

function p.gallery_stats local pictures = 0 local videos = 0 local panoramas = 0

for _, group in pairs(inbox_groups) do   for _, thread in ipairs(group) do      inbox = inboxes[thread] for _, reply in ipairs(inbox.threads) do       for _, reward in ipairs(reply.rewards) do          if reward.type == "Picture" then pictures = pictures + 1 elseif reward.type == "Video" then videos = videos + 1 elseif reward.type == "Panorama" then panoramas = panoramas + 1 else mw.log("Unrecognised reward type: " .. reward.type) end end end end end

local tab = { '{| class="wikitable" style="width:250px; text-align: center;"', '! colspan="2" style="background-color:#c0c0c0;" | Gallery Statistics', '|-',   '! Pictures', } table.insert(tab, "|"..pictures) table.insert(tab, "|-") table.insert(tab, "! Videos") table.insert(tab, "|"..videos) table.insert(tab, "|-") table.insert(tab, "! Panorama Parts") table.insert(tab, "|"..panoramas) table.insert(tab, "|}") return table.concat(tab, "\n") end

function p.panorama_page(panorama) local tab = {} local girls = nil local present = false --mw.log(panorama) -- Get panorama pictures and girls in the panorama for _, thread in ipairs(inbox_groups["Panoramas"]) do   inbox = inboxes[thread] for _, reply in ipairs(inbox.threads) do     for _, reward in ipairs(reply.rewards) do        --mw.log(reward.name) if reward.name == panorama then present = true table.insert(tab, "") if girls == nil then girls = reward.girls end end end end end if not present then return "" end return table.concat(tab, "") end

function girl_name(girl) if girl == "Grace" then return "Kelly" end return string.gsub(girl,"[^A-Zéa-z0-9]","") end

function p.panorama_page_categories(panorama) local girls = nil

-- Get panorama pictures and girls in the panorama for _, thread in ipairs(inbox_groups["Panoramas"]) do   inbox = inboxes[thread] for _, reply in ipairs(inbox.threads) do     for _, reward in ipairs(reply.rewards) do        if reward.name == panorama then if girls == nil then girls = reward.girls end end end end end if girls == nil then return "" end -- Add category part tab = {} for _, girl in ipairs(girls) do   table.insert(tab, "") end return table.concat(tab, "\n") end

return p