Skip to content

Commit

Permalink
details improved
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Germain committed Jan 5, 2024
1 parent bfc39d0 commit 0fe2add
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion huginn_roblox_agent.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Gem::Specification.new do |spec|
spec.name = "huginn_roblox_agent"
spec.version = '0.1.11'
spec.version = '0.1.12'
spec.authors = ["Nicolas Germain"]
spec.email = ["ngermain@hihouhou.com"]

Expand Down
22 changes: 13 additions & 9 deletions lib/huginn_roblox_agent/roblox_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ def check_conversations()
log_curl_output(response.code,response.body)

payload = JSON.parse(response.body)
payload_memory = payload.dup

if payload != memory['last_status']
payload.each do |conversation|
Expand Down Expand Up @@ -258,22 +259,25 @@ def check_conversations()
if !memory['last_status'].nil? and memory['last_status'].present?
date1 = last_status.find { |conversationter| conversationter["id"] == conversation['id'] }
end
if !date1.nil?
if date1
date1 = DateTime.parse(date1['lastUpdated'])
JSON.parse(get_conversations(conversation['id'])).each do |line|
date2 = DateTime.parse(line['sent'])
userid = conversation['participants'].find { |p| p['targetId'] == line['senderTargetId'] }
newline = "#{line['sent']} #{userid['name']} : #{line['content']}"
if date1 < date2
conversation['details_content'] << newline
end
else
date1 = DateTime.now - 1
end
JSON.parse(get_conversations(conversation['id'])).reverse.each do |line|
log line
date2 = DateTime.parse(line['sent'])
userid = conversation['participants'].find { |p| p['targetId'] == line['senderTargetId'] }
newline = "#{line['sent']} #{userid['name']} : #{line['content']}"
if date1 < date2
conversation['details_content'] << newline
end
end
end
create_event payload: conversation
end
end
memory['last_status'] = payload
memory['last_status'] = payload_memory
else
if interpolated['debug'] == 'true'
log "nothing to compare"
Expand Down

0 comments on commit 0fe2add

Please sign in to comment.