Browse Source

标记匿名标签刷新 超过一天未使用自动刷新

pull/4/head
欧醚 4 years ago
parent
commit
192657c54b
1 changed files with 10 additions and 1 deletions
  1. +10
    -1
      app/controllers/api/v1/statuses_controller.rb

+ 10
- 1
app/controllers/api/v1/statuses_controller.rb View File

@ -4,14 +4,23 @@ class AnonTag
@@namelist = (f = Rails.configuration.x.anon_namelist) ? File.readlines(f).collect(&:strip) : ['Alice', 'Bob', 'Carol', 'Dave']
@@used_name = []
@@map = {}
@@last_use = Time.now
def self.get_or_generate(pid)
if Time.now - @@last_use > 1.day
@@last_use = Time.now
@@map = {}
@@used_name = []
end
pre = @@map.empty? ? '*' : ''
if !@@map[pid]
@@map[pid] = (@@namelist - @@used_name).sample()
@@used_name.append(@@map[pid])
end
@@map[pid]
pre + @@map[pid]
end
end

Loading…
Cancel
Save