{"action":"created","issue":{"url":"https://api.github.com/repos/Zarel/Pokemon-Showdown/issues/3868","repository_url":"https://api.github.com/repos/Zarel/Pokemon-Showdown","labels_url":"https://api.github.com/repos/Zarel/Pokemon-Showdown/issues/3868/labels{/name}","comments_url":"https://api.github.com/repos/Zarel/Pokemon-Showdown/issues/3868/comments","events_url":"https://api.github.com/repos/Zarel/Pokemon-Showdown/issues/3868/events","html_url":"https://github.com/Zarel/Pokemon-Showdown/pull/3868","id":248625553,"number":3868,"title":"Chat: Refactor chat filter out of Config","user":{"login":"panpawn","id":5314189,"avatar_url":"https://avatars3.githubusercontent.com/u/5314189?v=4","gravatar_id":"","url":"https://api.github.com/users/panpawn","html_url":"https://github.com/panpawn","followers_url":"https://api.github.com/users/panpawn/followers","following_url":"https://api.github.com/users/panpawn/following{/other_user}","gists_url":"https://api.github.com/users/panpawn/gists{/gist_id}","starred_url":"https://api.github.com/users/panpawn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/panpawn/subscriptions","organizations_url":"https://api.github.com/users/panpawn/orgs","repos_url":"https://api.github.com/users/panpawn/repos","events_url":"https://api.github.com/users/panpawn/events{/privacy}","received_events_url":"https://api.github.com/users/panpawn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":30,"created_at":"2017-08-08T07:33:53Z","updated_at":"2017-08-26T01:17:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Zarel/Pokemon-Showdown/pulls/3868","html_url":"https://github.com/Zarel/Pokemon-Showdown/pull/3868","diff_url":"https://github.com/Zarel/Pokemon-Showdown/pull/3868.diff","patch_url":"https://github.com/Zarel/Pokemon-Showdown/pull/3868.patch"},"body":"This turns Config.chatfilter into Chat.filter.\r\n\r\nAlso, each chat-plugin can potentially alter the chat filter by exporting 'chatfilter', just as they can export 'commands'.\r\n\r\nNote:\r\n1. returning a string in a chatfilter will make that be a user's message sent to the room\r\n2. returning false will make a user's message not send to the room\r\n3. returning undefined will send a user's original message to the room"},"comment":{"url":"https://api.github.com/repos/Zarel/Pokemon-Showdown/issues/comments/325068901","html_url":"https://github.com/Zarel/Pokemon-Showdown/pull/3868#issuecomment-325068901","issue_url":"https://api.github.com/repos/Zarel/Pokemon-Showdown/issues/3868","id":325068901,"user":{"login":"Zarel","id":551184,"avatar_url":"https://avatars3.githubusercontent.com/u/551184?v=4","gravatar_id":"","url":"https://api.github.com/users/Zarel","html_url":"https://github.com/Zarel","followers_url":"https://api.github.com/users/Zarel/followers","following_url":"https://api.github.com/users/Zarel/following{/other_user}","gists_url":"https://api.github.com/users/Zarel/gists{/gist_id}","starred_url":"https://api.github.com/users/Zarel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zarel/subscriptions","organizations_url":"https://api.github.com/users/Zarel/orgs","repos_url":"https://api.github.com/users/Zarel/repos","events_url":"https://api.github.com/users/Zarel/events{/privacy}","received_events_url":"https://api.github.com/users/Zarel/received_events","type":"User","site_admin":false},"created_at":"2017-08-26T01:17:30Z","updated_at":"2017-08-26T01:17:30Z","body":"```\r\nChat.filter = function (message, user, room, connection, targetUser) {\r\n\tconst originalMessage = message;\r\n\tfor (const filter of chatfilters) {\r\n\t\tconst output = filter.call(this, message, user, room, connection, targetUser, originalMessage);\r\n\t\tif (output !== undefined) message = output;\r\n\t\tif (!message) return message;\r\n\t}\r\n\r\n\treturn message;\r\n};\r\n```\r\n\r\nHere's an implementation of `Chat.filter` that does everything Slayer95 was asking for, and is much simpler than your code."}}
{"actor":{"display_login":"Zarel"}}