Skip to content

Commit

Permalink
some fixes and allow multiple ids in rcgcdw message
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus-Rost committed Aug 5, 2024
1 parent 7c26212 commit ac40444
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions cmds/rcscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function cmd_rcscript(lang, msg, args, line, wiki) {
if ( reaction ) reaction.removeEmoji();
return msg.replyMsg( {content: lang.get('test.MediaWiki', 'MediaWiki 1.30', body.query.general.generator) + '\nhttps://www.mediawiki.org/wiki/MediaWiki_1.30', components}, true );
}
if ( body.query.allmessages[0]['*']?.trim() !== msg.guildId && !( msg.isOwner() && msg.evalUsed ) ) {
if ( !body.query.allmessages[0]['*']?.split('\n').some( guild => guild.trim() === msg.guildId ) && !( msg.isOwner() && msg.evalUsed ) ) {
if ( reaction ) reaction.removeEmoji();
return msg.replyMsg( {content: lang.get('rcscript.sysmessage', 'MediaWiki:Custom-RcGcDw', msg.guildId) + '\n<' + wikinew.toLink('MediaWiki:Custom-RcGcDw', 'action=edit') + '>', components}, true );
}
Expand Down Expand Up @@ -330,7 +330,7 @@ export default function cmd_rcscript(lang, msg, args, line, wiki) {
if ( reaction ) reaction.removeEmoji();
return msg.replyMsg( {content: lang.get('test.MediaWiki', 'MediaWiki 1.30', body.query.general.generator) + '\nhttps://www.mediawiki.org/wiki/MediaWiki_1.30', components}, true );
}
if ( body.query.allmessages[0]['*']?.trim() !== msg.guildId && !( msg.isOwner() && msg.evalUsed ) ) {
if ( !body.query.allmessages[0]['*']?.split('\n').some( guild => guild.trim() === msg.guildId ) && !( msg.isOwner() && msg.evalUsed ) ) {
if ( reaction ) reaction.removeEmoji();
return msg.replyMsg( {content: lang.get('rcscript.sysmessage', 'MediaWiki:Custom-RcGcDw', msg.guildId) + '\n<' + wikinew.toLink('MediaWiki:Custom-RcGcDw', 'action=edit') + '>', components}, true );
}
Expand Down
4 changes: 2 additions & 2 deletions dashboard/functions/rcscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ function update_rcscript(res, userSettings, guild, type, settings) {
if ( body.query.general.generator.replace( /^MediaWiki 1\.(\d\d).*$/, '$1' ) < 30 ) {
return res(`/guild/${guild}/rcscript/new`, 'mwversion', body.query.general.generator, body.query.general.sitename);
}
if ( body.query.allmessages[0]['*']?.trim() !== guild ) {
if ( !body.query.allmessages[0]['*']?.split('\n').some( guildId => guildId.trim() === guild ) ) {
return res(`/guild/${guild}/rcscript/new`, 'sysmessage', guild, wiki.toLink('MediaWiki:Custom-RcGcDw', 'action=edit'));
}
return db.query( 'SELECT reason FROM blocklist WHERE wiki = $1', [wiki.href] ).then( ({rows:[block]}) => {
Expand Down Expand Up @@ -742,7 +742,7 @@ function update_rcscript(res, userSettings, guild, type, settings) {
if ( body.query.general.generator.replace( /^MediaWiki 1\.(\d\d).*$/, '$1' ) < 30 ) {
return res(`/guild/${guild}/rcscript/${type}`, 'mwversion', body.query.general.generator, body.query.general.sitename);
}
if ( row.wiki !== wiki.href && body.query.allmessages[0]['*']?.trim() !== guild ) {
if ( row.wiki !== wiki.href && !body.query.allmessages[0]['*']?.split('\n').some( guildId => guildId.trim() === guild ) ) {
return res(`/guild/${guild}/rcscript/${type}`, 'sysmessage', guild, wiki.toLink('MediaWiki:Custom-RcGcDw', 'action=edit'));
}
return db.query( 'SELECT reason FROM blocklist WHERE wiki = $1', [wiki.href] ).then( ({rows:[block]}) => {
Expand Down
4 changes: 2 additions & 2 deletions dashboard/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ function dashboard_api(res, input, guild = null) {
logo: '',
oauth: false,
MediaWiki: false,
RcGcDw: '',
RcGcDw: [],
customRcGcDw: wiki?.toLink('MediaWiki:Custom-RcGcDw', 'action=edit')
};
if ( !wiki ) {
Expand Down Expand Up @@ -440,7 +440,7 @@ function dashboard_api(res, input, guild = null) {
result.MediaWiki = true;
}
if ( body.query.allmessages[0]['*'] ) {
result.RcGcDw = body.query.allmessages[0]['*'];
result.RcGcDw = body.query.allmessages[0]['*'].split('\n').map( guildId => guildId.trim() );
}
result.customRcGcDw = wiki.toLink('MediaWiki:Custom-RcGcDw', 'action=edit');
if ( wiki.wikifarm === 'fandom' ) return;
Expand Down
3 changes: 3 additions & 0 deletions dashboard/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,9 @@ button.addmore:not([hidden]) {
display: block;
margin-left: 20%;
}
.wb-settings-wiki-check-notice .wiki-logo {
max-width: 100%;
}
.wb-settings-optgroup {
font-weight: bold;
}
Expand Down
3 changes: 2 additions & 1 deletion dashboard/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ for ( var w = 0; w < wikis.length; w++ ) (function(wiki) {
var wikiEmbedStrong = document.createElement('strong');
wikiEmbedStrong.textContent = response.sitename;
var wikiEmbedImg = document.createElement('img');
wikiEmbedImg.className = 'wiki-logo';
wikiEmbedImg.src = response.logo;
wikiEmbedImg.alt = response.sitename;
var wikiEmbedSmall = document.createElement('small');
Expand Down Expand Up @@ -253,7 +254,7 @@ for ( var w = 0; w < wikis.length; w++ ) (function(wiki) {
wikichecknotice.append(noticeTitle, noticeText, noticeLink, ...noticeExtraParts);
return;
}
if ( response.RcGcDw?.trim() !== guild && ( document.location.pathname.split('/')[4] === 'new' || wiki.value !== wiki.defaultValue ) ) {
if ( !response.RcGcDw.includes( guild ) && ( document.location.pathname.split('/')[4] === 'new' || wiki.value !== wiki.defaultValue ) ) {
wikichecknotice.classList.add('notice-info');
var noticeTitle = document.createElement('b');
noticeTitle.textContent = lang('sysmessage.title');
Expand Down
6 changes: 3 additions & 3 deletions functions/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function verify(lang, logLang, channel, member, username, wiki, r
embed: null
}
};
return got.get( wiki + 'api.php?action=query&meta=siteinfo' + ( wiki.wikifarm === 'fandom' ? '|allmessages&siprop=general&ammessages=importJS&list=users|usercontribs&ucprop=&uclimit=10&ucuser=%1F' + encodeURIComponent( username.replaceAll( '\x1F', '\ufffd' ) ) : '&siprop=general&list=users' ) + '&usprop=blockinfo|groups|editcount|registration|gender&ususers=%1F' + encodeURIComponent( username.replaceAll( '\x1F', '\ufffd' ) ) + '&format=json', {
return got.get( wiki + 'api.php?action=query&meta=siteinfo' + ( wiki.wikifarm === 'fandom' ? '|allmessages&siprop=general&ammessages=importJS&list=users|usercontribs&ucprop=&uclimit=10&ucuser=%1F' + encodeURIComponent( username.replaceAll( '\x1F', '\ufffd' ) ) : '&siprop=general&list=users' ) + '&usprop=blockinfo|groups|editcount|registration|gender&ususers=%1F' + encodeURIComponent( username.replaceAll( '\x1F', '\ufffd' ) ) + '&format=json&cache=' + Date.now(), {
context: {
guildId: channel.guildId
}
Expand Down Expand Up @@ -443,7 +443,7 @@ export default function verify(lang, logLang, channel, member, username, wiki, r
result.add_button = false;
} );

return got.get( wiki + 'api.php?action=query' + ( wiki.hasCentralAuth() ? '&meta=globaluserinfo&guiprop=groups&guiuser=' + encodeURIComponent( username ) : '' ) + '&prop=revisions&rvprop=content|user&rvslots=main&titles=%1FUser:' + encodeURIComponent( username.replaceAll( '\x1F', '\ufffd' ) ) + '/Discord%1FSpecial:MyPage/Discord&format=json', {
return got.get( wiki + 'api.php?action=query' + ( wiki.hasCentralAuth() ? '&meta=globaluserinfo&guiprop=groups&guiuser=' + encodeURIComponent( username ) : '' ) + '&prop=revisions&rvprop=content|user&rvslots=main&titles=%1FUser:' + encodeURIComponent( username.replaceAll( '\x1F', '\ufffd' ) ) + '/Discord%1FSpecial:MyPage/Discord&format=json&cache=' + Date.now(), {
context: {
guildId: channel.guildId
}
Expand Down Expand Up @@ -754,7 +754,7 @@ globalThis.verifyOauthUser = function(state, access_token, settings) {
var useLogging = ( verifynotice.logchannel ? true : false );
var logLang = lang;
if ( !state && (verifynotice.flags & 1 << 0) === 1 << 0 ) lang = lang.uselang(settings?.interaction?.locale);
got.get( wiki + 'api.php?action=query&meta=siteinfo' + ( wiki.hasCentralAuth() ? '|globaluserinfo&guiprop=groups&guiuser=' + encodeURIComponent( username ) : '' ) + '&siprop=general&list=users&usprop=blockinfo|groups|editcount|registration|gender&ususers=%1F' + encodeURIComponent( username.replaceAll( '\x1F', '\ufffd' ) ) + '&format=json', {
got.get( wiki + 'api.php?action=query&meta=siteinfo' + ( wiki.hasCentralAuth() ? '|globaluserinfo&guiprop=groups&guiuser=' + encodeURIComponent( username ) : '' ) + '&siprop=general&list=users&usprop=blockinfo|groups|editcount|registration|gender&ususers=%1F' + encodeURIComponent( username.replaceAll( '\x1F', '\ufffd' ) ) + '&format=json&cache=' + Date.now(), {
context: {
guildId: channel.guildId
}
Expand Down

0 comments on commit ac40444

Please sign in to comment.