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

"Tokengating the Chatroom" bug fix #202

Open
bliotti opened this issue May 29, 2024 · 0 comments · May be fixed by #203
Open

"Tokengating the Chatroom" bug fix #202

bliotti opened this issue May 29, 2024 · 0 comments · May be fixed by #203

Comments

@bliotti
Copy link
Contributor

bliotti commented May 29, 2024

Example code for the Broadcast Handler should set Balance to 0 if it doesn't already exist.

Handlers.add(
  "Broadcast",
  Handlers.utils.hasMatchingTag("Action", "Broadcast"),
  function(m)
    -- Add line below to set Balance to 0 if it doesn't exist.
    if not Balances then Balances = { [ao.id] = 0 } end
    if Balances[m.From] == nil or tonumber(Balances[m.From]) < 1 then
      print("UNAUTH REQ: " .. m.From)
      return
    end
    local type = m.Type or "Normal"
    print("Broadcasting message from " .. m.From .. ". Content: " .. m.Data)
    for i = 1, #Members, 1 do
      ao.send({
        Target = Members[i],
        Action = "Broadcasted",
        Broadcaster = m.From,
        Data = m.Data
      })
    end
  end
)
@bliotti bliotti changed the title "Tokengating the Chatroom" bug "Tokengating the Chatroom" bug fix May 30, 2024
@bliotti bliotti linked a pull request May 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant