vd-plugins/Moyai/index.js
2026-07-02 11:39:19 +00:00

1 line
2.1 KiB
JavaScript

(function(o,y,d,n,f){"use strict";const{ScrollView:R}=d.findByProps("ScrollView"),{TableRowGroup:b,TableSwitchRow:w,Stack:m}=d.findByProps("TableSwitchRow","TableRowGroup","Stack");function T(){const[,e]=n.React.useReducer(function(t){return~t},0);return n.React.createElement(R,{style:{flex:1}},n.React.createElement(m,{style:{padding:16},spacing:16},n.React.createElement(b,{title:"General"},n.React.createElement(w,{label:"Play on reactions",subLabel:"Play the sound when someone reacts with moyai",value:f.plugin.storage.allowReactions??!0,onValueChange:function(t){f.plugin.storage.allowReactions=t,e()}}))))}const{DCDSoundManager:c}=n.ReactNative.NativeModules,h=d.findByStoreName("SelectedChannelStore"),A="https://raw.githubusercontent.com/Metastruct/garrysmod-chatsounds/master/sound/chatsounds/autoadd/memes/overused%20thud.ogg",u=6969;let g=-1;const D=function(){return new Promise(function(e){try{c.prepare(A,"media",u,function(t,a){return e(a)})}catch{e({duration:1e3})}})};let i=null,s=!1;async function E(){if(r)try{s&&(i!=null&&clearTimeout(i),c.stop(u),s=!1),s=!0,await c.play(u),i=setTimeout(function(){s=!1,r&&c.stop(u),i=null},g)}catch{s=!1}}const v=/🗿|<a?:.*?moy?ai.*?:\d+>/gi;function S(e){try{if(e.message?.content&&e.channelId==h.getChannelId()&&!e.message.state){const t=e.message.content.match(v);if(t)for(let a=0;a<t.length;a++)setTimeout(E,a*350)}}catch{}}const l=new Set;function p(e){try{if((y.storage.allowReactions??!0)&&e.channelId==h.getChannelId()){const t=e.emoji?.name;if(t==="\u{1F5FF}"||t&&/moy?ai/i.test(t)){const a=`${e.messageId}:${t}`;if(l.has(a))return;l.add(a),setTimeout(function(){return l.delete(a)},500),E()}}}catch{}}let r=!1;var C={onLoad:function(){r||D().then(function(e){r=!0,g=e.duration}),n.FluxDispatcher.subscribe("MESSAGE_CREATE",S),n.FluxDispatcher.subscribe("MESSAGE_REACTION_ADD",p)},onUnload:function(){n.FluxDispatcher.unsubscribe("MESSAGE_CREATE",S),n.FluxDispatcher.unsubscribe("MESSAGE_REACTION_ADD",p),l.clear()},settings:T};return o.default=C,Object.defineProperty(o,"__esModule",{value:!0}),o})({},vendetta.plugin,vendetta.metro,vendetta.metro.common,vendetta);