#include server.js const MamiCompat = (current, path, handler) => { if(typeof path !== 'string') throw 'path must be a string'; if(typeof handler !== 'function') throw 'handler must be a function'; path = path.split('.'); const final = path.pop(); if(final === undefined) throw 'invalid path'; for(const part of path) { if(!(part in current)) current[part] = {}; current = current[part]; } if(!(final in current)) current[final] = handler; }; // Backwards compat for scripts // Keep in sync with for as long as possible MamiCompat(Umi, 'Server.SendMessage', text => Umi.Server.sendMessage(text)); MamiCompat(Umi, 'Protocol.SockChat.Protocol.Instance.SendMessage', text => Umi.Server.sendMessage(text)); MamiCompat(Umi, 'Protocol.SockLegacy.Protocol.Instance.SendMessage', text => Umi.Server.sendMessage(text)); MamiCompat(Umi, 'Parser.SockChatBBcode.EmbedStub', () => {}); // intentionally a no-op MamiCompat(Umi, 'UI.View.SetText', text => console.log(`Umi.UI.View.SetText(text: ${text})`)); MamiCompat(Umi, 'UI.Menus.Add', (baseId, title, initiallyHidden) => console.log(`Umi.UI.Menus.Add(baseId: ${baseId}, title: ${title}, initiallyHidden: ${initiallyHidden})`)); MamiCompat(Umi, 'UI.Menus.Get', (baseId, icon) => console.log(`Umi.UI.Menus.Get(baseId: ${baseId}, icon: ${icon})`));