Git Product home page Git Product logo

mw-discord's Introduction

Hey! My name is Jayden. I'm a full stack developer most proficient in Node.js, JS/TS, React, and related tech. I usually weave my enjoyment of programming with my other hobby: gaming. If you're a content creator, you can find some of my work in the Aitum software - I recommend checking it out!

Since 2018, I've been one of the system administrators for the official RuneScape and OSRS Wikis (@weirdgloop), and I also develop MediaWiki extensions and customised forks of existing projects for use across those wikis.

mw-discord's People

Contributors

designerthan95 avatar dinoguy1000 avatar dodocodes avatar jayktaylor avatar joeytje50 avatar lewisakura avatar probableprime avatar szmyk avatar translatewiki avatar xunto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mw-discord's Issues

Different emoji for page creations

Currently page creations use the pencil emoji, the same as non-creation edits. For quick visual distinction, it would be useful for them to use a different emoji, though I don't have any suggestions for a new one.

Differentiate page creations from other edits

Currently creations and edits are presented identically, except that creations lack a "diff" link after the page name, which makes it hard to spot them by just scanning through. It would be better if page creations said "created" instead of "edited", and/or were distinguished from non-creation edits in other ways.

$wgDiscordDisabledNS works?

So I have $wgDiscordDisabledNS = ["MediaWiki"]; set, and still get notifications for MediaWiki:Common.css.
Am I doing something wrong?
This is on 1.39.

Handle high-frequency editing/logs

Discord rate-limits individual channels to 5 messages a second (though the documentation says to use API headers instead of hard-coding assumptions about rate limits); when a wiki is experiencing action rates greater than this (e.g. if $wgDiscordNoBots is set to false, and a few bots are running simultaneously (or one really high-rate bot is running)), messages will fail to send. Possible solutions are to retry sending on receiving an error (reasonable for sudden transient spikes) or collecting multiple actions into a single message (would be required for longer durations of high-frequency actions). Dropping messages should probably be avoided unless explicitly opted-in (maybe accompanied by dropping an extra message to be able to send a "X messages dropped, see recent changes on-wiki" notification).

IP edits shouldn't link to the IP's userpage

Currently three links are offered for the user that made an edit: the user's page, their talk page, and their contributions. However, IP user pages are almost never created, and as a result links to them are generally useless clutter. Therefore, the link to the IP's userpage should be removed and the IP address should instead link to their contributions.

Minor issues reported on Weird Gloop repo

A couple of issues are still happening with the recent changes bot. Most notably is the fact that templates on page creation/uploads are being subst'd, as is known. Additionally, editing a file page, to say, add a license or tag for speedy deletion also doesn't show up.

Another issue is that file names get italicised if they have slashes in them. I'm not sure if this is preventable, but I also didn't remember it being a problem with TyBot so I'll put that here too.

Error when trying to block user

[2ce78c058445ead74961222b] /Specjalna:Blokuj/CarmaRoof83 Error from line 210 of /.../wiki.mikronacje.info/mediawiki/extensions/Discord/src/DiscordHooks.php: Cannot access protected property MediaWiki\Block\DatabaseBlock::$mReason

Backtrace:

#0 /.../wiki.mikronacje.info/mediawiki/includes/HookContainer/HookContainer.php(320): DiscordHooks::onBlockIpComplete(MediaWiki\Block\DatabaseBlock, User, NULL)
#1 /.../wiki.mikronacje.info/mediawiki/includes/HookContainer/HookContainer.php(131): MediaWiki\HookContainer\HookContainer->callLegacyHook(string, array, array, array)
#2 /.../wiki.mikronacje.info/mediawiki/includes/HookContainer/HookRunner.php(1078): MediaWiki\HookContainer\HookContainer->run(string, array)
#3 /.../wiki.mikronacje.info/mediawiki/includes/specials/SpecialBlock.php(1023): MediaWiki\HookContainer\HookRunner->onBlockIpComplete(MediaWiki\Block\DatabaseBlock, User, NULL)
#4 /.../wiki.mikronacje.info/mediawiki/includes/specials/SpecialBlock.php(1235): SpecialBlock::processForm(array, RequestContext)
#5 /.../wiki.mikronacje.info/mediawiki/includes/htmlform/HTMLForm.php(707): SpecialBlock->onSubmit(array, OOUIHTMLForm)
#6 /.../wiki.mikronacje.info/mediawiki/includes/htmlform/HTMLForm.php(597): HTMLForm->trySubmit()
#7 /.../wiki.mikronacje.info/mediawiki/includes/htmlform/HTMLForm.php(613): HTMLForm->tryAuthorizedSubmit()
#8 /.../wiki.mikronacje.info/mediawiki/includes/specialpage/FormSpecialPage.php(187): HTMLForm->show()
#9 /.../wiki.mikronacje.info/mediawiki/includes/specialpage/SpecialPage.php(600): FormSpecialPage->execute(string)
#10 /.../wiki.mikronacje.info/mediawiki/includes/specialpage/SpecialPageFactory.php(635): SpecialPage->run(string)
#11 /.../wiki.mikronacje.info/mediawiki/includes/MediaWiki.php(307): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext)
#12 /.../wiki.mikronacje.info/mediawiki/includes/MediaWiki.php(940): MediaWiki->performRequest()
#13 /.../wiki.mikronacje.info/mediawiki/includes/MediaWiki.php(543): MediaWiki->main()
#14 /.../wiki.mikronacje.info/mediawiki/index.php(53): MediaWiki->run()
#15 /.../wiki.mikronacje.info/mediawiki/index.php(46): wfIndexMain()
#16 {main}

"Warning: Parameter 1 to DiscordHooks::onArticleRevisionVisibilitySet() expected to be a reference, value given"

This error is produced on changing the visibility of a revision (specifically on changing the visibility of the revision text, though I'm sure it would happen on changing the visibility of the summary or actor name, or any combination of them). Comparing the parameters of onArticleRevisionVisibilitySet() to other functions, the former uses &$title while e.g. onArticleUndelete() instead uses Title $title (but looking at more functions suggests there's no real set pattern to what exactly is passed in for the page title of the action performed, I'm guessing because the hooks used just aren't consistent either?)

Note that this was encountered on MW 1.31, so changes in subsequent versions of MW may have fixed this (the parameter references are identical between the REL1_31 and main branches of this extension).

Track log entries instead of hooks for log actions

The current hook-based design of this extension means it can only show actions that trigger a hook, and data accessible via that hook (see #23, #28, #30, probably other things no one's noticed or bothered to file an issue for). I'm assuming this won't be a straightforward drop-in replacement, so definitely more of a wishlist item than anything.

Sending forged user right changes to the webhook

It appears it is possible to send forged user right notifications to the webhook, maybe even other log entries. No changes actually happen. I have no idea how this is done, however, but it did stop once the offender was blocked.

image

Figured out how it works.

Mediawiki won't outright reject your POST request for usergroup changes when you don't actually have permisions to do that. While whatever you do in the UserRights form will silently fail in the background, this is enough to throw a Discord notification with the Reason text supplied. This can be done even if you are not logged in and the wiki does not allow IP edits.

Works with another Discord extesnsion too. Could be a a mediawiki bug.

HTML character entity references in edit summaries are not interpreted

Character entity references used in edit summaries are not replaced with their character literal. For example:

Dinoguy1000 (t|c) moved Category:Cards needing a passcode redirect to Category:Cards needing a password redirect passcode → password (diff) (m) (+0)

which should be

Dinoguy1000 (t|c) moved Category:Cards needing a passcode redirect to Category:Cards needing a password redirect passcode → password (diff) (m) (+0)

"Error: Call to undefined method LocalFile::getUser()" While I'm uploading the image

Hello everyone, I encountered a problem that when the add-on is enabled, uploading pictures to the wiki does not work. If you turn it off, the pictures are quietly unloaded.

[7c377a646d61f5d4db582efd] /index.php/%D0%A1%D0%BB%D1%83%D0%B6%D0%B5%D0%B1%D0%BD%D0%B0%D1%8F:%D0%97%D0%B0%D0%B3%D1%80%D1%83%D0%B7%D0%BA%D0%B0 Error: Call to undefined method LocalFile::getUser()

Backtrace:

from /var/www/domain.example/extensions/Discord/src/DiscordHooks.php(261)
#0 /var/www/domain.example/includes/HookContainer/HookContainer.php(338): DiscordHooks::onUploadComplete()
#1 /var/www/domain.example/includes/HookContainer/HookContainer.php(137): MediaWiki\HookContainer\HookContainer->callLegacyHook()
#2 /var/www/domain.example/includes/HookContainer/HookRunner.php(4080): MediaWiki\HookContainer\HookContainer->run()
#3 /var/www/domain.example/includes/upload/UploadBase.php(940): MediaWiki\HookContainer\HookRunner->onUploadComplete()
#4 /var/www/domain.example/includes/specials/SpecialUpload.php(568): UploadBase->performUpload()
#5 /var/www/domain.example/includes/specials/SpecialUpload.php(232): SpecialUpload->processUpload()
#6 /var/www/domain.example/includes/specialpage/SpecialPage.php(701): SpecialUpload->execute()
#7 /var/www/domain.example/includes/specialpage/SpecialPageFactory.php(1475): SpecialPage->run()
#8 /var/www/domain.example/includes/MediaWiki.php(327): MediaWiki\SpecialPage\SpecialPageFactory->executePath()
#9 /var/www/domain.example/includes/MediaWiki.php(923): MediaWiki->performRequest()
#10 /var/www/domain.example/includes/MediaWiki.php(576): MediaWiki->main()
#11 /var/www/domain.example/index.php(50): MediaWiki->run()
#12 /var/www/domain.example/index.php(46): wfIndexMain()
#13 {main}

Investigate using RequestContext.php in place of $wgUser

In src/DiscordHooks.php, some functions require a $user parameter to be passed in, whereas others use the $wgUser global. This is inconsistent and potentially a source of errors (e.g. I almost didn't notice the discrepancy in #8 ). If there's a functional difference between these, it needs to be clearly documented.

There might be places where RequestContext.php could be used instead of the current $wgUser.

Support ApprovedRevs

ApprovedRevs provides the following hooks that can be turned into a webhook message:

ApprovedRevsRevisionApproved
ApprovedRevsRevisionUnapproved
ApprovedRevsFileRevisionApproved
ApprovedRevsFileRevisionUnapproved

Unfortunately, they are not documented. Cargo uses them though, so you might be able to get the arguments the hook sends there.

This would be great for projects that have public editing but require you to have your edits approved. Since we use mw-discord as a public audit log in Discord, it would be useful to be able to have these hooks be used so we can see when a revision gets approved/unapproved and maybe include an approve link in a page creation/update for our moderation team to easily click on.

No messages are sent on Mediawiki 1.39

I haven't tested all the hooks but I no longer receive messages from the bot for page edits or uploads after upgrading to 1.39. I have also tried reinstalling the extension.

Undefined variable user_abbr

If $wgDiscordMaxCharsUsernames is set to null, this variable never gets set and breaks the user link sent to Discord. (This was observed on the REL1_31 branch, but the relevant code is functionally identical in the current main branch, so the breakage should also happen there.)

Messages should include a timestamp

...because Discord's logic on when to display timestamps isn't great for this purpose.

Probably a compact human-readable format would be best, a modified version of ISO 8601 or something.

Discord Feed attempting to access the property.

[6d47fe4abf2e849c3be39ccd] /index.php/Special:Block/testuser Error from line 210 of /var/www/neko.kazdel.com/mediawiki/extensions/Discord/src/DiscordHooks.php: Cannot access protected property MediaWiki\Block\DatabaseBlock::$mReason

When attempting to block a user The Discord Extension is causing this, and when i remove the Discord feed it fixes it however i want to have wiki feed without this error Can you Please perhaps Fix this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.