Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

news-feed-bot-$rio-bintang #301

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions 0rbit-Get-Request.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
local json = require("json")

_0RBIT = "WSXUI2JjYUldJ7CKq9wE1MGwXs-ldzlUlHOQszwQe0s"

BASE_URL = "https://dummyjson.com/products"

ReceivedData = ReceivedData or {}

Handlers.add(
"Get-Request",
Handlers.utils.hasMatchingTag("Action", "Sponsored-Get-Request"),
function(msg)
Send({
Target = _0RBIT,
Action = "Get-Real-Data",
Url = BASE_URL
})
print(Colors.green .. "You have sent a GET Request to the 0rbit process.")
end
)

Handlers.add(
"Receive-Data",
Handlers.utils.hasMatchingTag("Action", "Receive-Response"),
function(msg)
local res = json.decode(msg.Data)
ReceivedData = res
print(Colors.green .. "You have received the data from the 0rbit process.")
end
)
Binary file added image sponsored get request.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions pricebot.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- PID = M7hW7_662WVGwcfrK-N9GRPzZ-sE-WE92QCwbHB1BU8

_ORBIT = "WSXUI2JjYUldJ7CKq9wE1MGwXs-ldzlUlHOQszwQe0s"

function handleError(msg, errorMessage)
ao.send({
Target = msg.From,
Tags = {
Action = "Error",
["Message-Id"] = msg.Id,
Error = errorMessage
}
})
end

Handlers.add("riobintang",
Handlers.utils.hasMatchingTag("Action", "rio-bintang"),
function(msg)
local token = msg.Tags.Token
local url = "https://api.coingecko.com/api/v3/simple/price" .. "?ids=" .. token .. "&vs_currencies=usd"
ao.send({
Target = _ORBIT,
Action = "Get-Real-Data",
Url = url
})
Handlers.utils.reply("PriceFetch")
(msg)
end
)