<commit_before>PLUGIN.Title = "madrust-announce"
PLUGIN.Description = "Broadcast announcements using a subreddit as the source."
PLUGIN.Version = "0.1"
PLUGIN.Author = "<NAME>"

function PLUGIN:Init()
  self.Announcement = {}
  print("init madrust-announce")	
  self:AddChatCommand( "announce", self.cmdAnnounce )

  print("requesting data from subreddit")

  webrequest.Send ("http://www.reddit.com/r/madrust/.json", 
    function(respCode, response)
      print("subreddit request callback [HTTP " .. respCode .. "]")
      local resp = json.decode(response)
      for _, _listing in pairs(resp.data.children) do
        local title = _listing.data.title
        if string.sub(string.upper(title), 0, 15) == "[ANNOUNCEMENT] " then
          print("announcement is " .. title)
          self.Announcement = { 
              title = string.sub(_listing.data.title, 16)
          }
          break
        end
      end
    end
  )

  print("subreddit request sent")
 end
 
function PLUGIN:OnUserConnect( netuser )
  rust.SendChatToUser( netuser, "[ANNOUNCE]", "Brian is the bomb.com" )
end

function PLUGIN:cmdAnnounce( netuser, cmd, args )
  rust.BroadcastChat( "[ANNOUNCE]", self.Announcement.title )
end<commit_msg>Add more data to the announcement model.<commit_after>PLUGIN.Title = "madrust-announce"
PLUGIN.Description = "Broadcast announcements using a subreddit as the source."
PLUGIN.Version = "0.1"
PLUGIN.Author = "<NAME>"

function PLUGIN:Init()
  self.Announcement = {}
  print("init madrust-announce")	
  self:AddChatCommand( "announce", self.cmdAnnounce )

  print("requesting data from subreddit")

  webrequest.Send ("http://www.reddit.com/r/madrust/.json", 
    function(respCode, response)
      print("subreddit request callback [HTTP " .. respCode .. "]")
      local resp = json.decode(response)
      for _, _listing in pairs(resp.data.children) do
        local title = _listing.data.title
        if string.sub(string.upper(title), 0, 15) == "[ANNOUNCEMENT] " then
          print("announcement is " .. title)
          self.Announcement = { 
              title = string.sub(_listing.data.title, 16),
              id = _listing.data.id
              created_utc = _listing.data.created_utc
          }
          break
        end
      end
    end
  )

  print("subreddit request sent")
 end
 
function PLUGIN:OnUserConnect( netuser )
  rust.SendChatToUser( netuser, "[ANNOUNCE]", "Brian is the bomb.com" )
end

function PLUGIN:cmdAnnounce( netuser, cmd, args )
  rust.BroadcastChat( "[ANNOUNCE]", self.Announcement.title )
end
{'fraction_non_alphanumeric': 0.12372748629600626, 'fraction_numerical': 0.00548159749412686, 'mean_word_length': 3.029968454258675, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4970408', 'n_tokens_mistral': 839, 'n_tokens_neox': 808, 'n_words': 185}