Skip to content

Commit

Permalink
Patch for several issues
Browse files Browse the repository at this point in the history
Delinting using http://www.coffeelint.org/

Adding throttle parameter to config (but set to false) to highlight
that it exists

Adding tripple mustaches to deal with issue #116

Adding namespace logic to anon and config to support issue #118
This allows filtering out edits in talk namespaces etc,
if namespace is left out of config all namespaces are accepted

Added logic to disregard @metadata entries in ranges to support issue #115
this allows source, dates etc. to be added to the ranges
  • Loading branch information
lokal-profil committed Sep 9, 2014
1 parent 00b4aa4 commit 55f5a9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion anon.coffee
Expand Up @@ -51,6 +51,7 @@ getConfig = (path) ->
for account in config.accounts
if typeof account.ranges == 'string'
account.ranges = loadJson account.ranges
delete account.ranges['@metadata']
console.log "loaded config from", path
config

Expand Down Expand Up @@ -100,6 +101,8 @@ inspect = (account, edit) ->
and account.whitelist[edit.wikipedia][edit.page]
status = getStatus edit, edit.user, account.template
tweet account, status, edit
else if account.namespaces? and \
(edit.namespace not in account.namespaces) then
else if account.ranges and edit.anonymous
for name, ranges of account.ranges
if isIpInAnyRange edit.user, ranges
Expand All @@ -119,7 +122,8 @@ canTweet = (account, error) ->
twitter.get 'search/tweets', q: 'cats', (err, data, response) ->
if err
error err + " for access_token " + a
else if not response.headers['x-access-level'] or response.headers['x-access-level'].substring(0,10) != 'read-write'
else if not response.headers['x-access-level'] or \
response.headers['x-access-level'].substring(0,10) != 'read-write'
error "no read-write permission for access token " + a
else
error null
Expand Down
4 changes: 3 additions & 1 deletion config.json.template
Expand Up @@ -6,7 +6,7 @@
"consumer_secret": "",
"access_token": "",
"access_token_secret": "",
"template": "{{page}} Wikipedia article edited anonymously from {{name}} {{&url}}",
"template": "{{{page}}} Wikipedia article edited anonymously from {{{name}}} {{&url}}",
"ranges": {
"US House of Representatives": [
"143.231.0.0/16",
Expand All @@ -20,6 +20,8 @@
"156.33.0.0/16"
]
},
"throttle": false,
"namespaces": ["article", "file", "media", "main"],
"whitelist": {
"English Wikipedia": {
"Sherrod Brown": true,
Expand Down

0 comments on commit 55f5a9d

Please sign in to comment.