Skip to content

Conversation

@null8626
Copy link
Member

@null8626 null8626 commented Sep 16, 2025

The following pull request is a toned down version of #3. This pull request focuses solely on the
changes done to the SDK in the v0 of the API. Such as:

  • Adapting the SDK to newer changes in v0.
  • Refactoring the autoposter.
  • Refactoring the SDK by using Lua's setmetatable({}, self) to emulate OOP objects over manual copied code that emulates OOP.
  • Removing useless manual EventEmitter implementation for the autoposter.

@null8626 null8626 changed the title feat: adapt to v0 and add autoposter feat: adapt to v0 Sep 16, 2025
Copy link
Collaborator

@velddev velddev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert the public API function names and it seems fine to me

return res;
if data then
return data
else
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: else not really needed here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if type(query.fields) == 'table' then
query.fields = concat(query.fields, ',');
end
function Api:get_bot(id)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid renaming the public API please

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, with the exception of Api:init(token); to local client = Api:new(token);.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full diff on the API methods:

PRIVATE METHODS:
- Api:commit(method, url, req, body)
+ Api:__commit(method, url, request, body)
+ Api:__request(method, path, body, query)

PUBLIC METHODS:
- Api:init(token)
+ Api:new(token)

- Api:getVotes()
+ Api:getVotes(page)

+ Api:newAutoposter()

local data = self:__request('GET', string.format('/bots/check?userId=%s', id))

return self:request('GET', '/bots/votes');
return not not data.voted
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the API, voted is an integer, not a boolean. But I'll revise this to data.voted ~= 0.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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 this pull request may close these issues.

2 participants