OSCA-Kampala-Chapter / autobot

Autobot is a bot library targetted to build software bots for various platforms with ease of integration in mind
MIT License
14 stars 15 forks source link

add functionality to api module functions and implement the remain api modules #153

Closed ToebiasHT closed 1 year ago

ToebiasHT commented 1 year ago

This is the final phase in order to have an MVP for autobot. The methods in the different classes in api modules need to have their functionality added. also @ushergodwin already worked on one module but there are the rest of the api modules in the stcikers,games etc subpackages. The methods for these objects are located in the same sections on the telegram api page.

In order to add functionality, The method should first be determined as a post or get method. Post methods push data to the telegram bot while get methods pull data from it. for get methods, they internally call the _get() method with the url and headers as key word arguments. for example `self._get(url = url,headers = kwargs)

the method should taken in only key word arguments as parameters, for example async def send_message (self,**kwargs), then construct a url that it will pass to the internal get or post method. To construct the url, should just call the add_method method on the url class that it has access to from the context. the add_method should be given a name corresponding to the actual telegram method, and it shall return a new url with the telegram method name. Then the method should go ahead and call the underlying _get or _post methods. The return dictionary from the _get and _post methods is then parsed by the method and the method returns the parsed value. For example

async def send_message (self,**kwargs):
    url = self.url.add_method("sendMessage")
    res = await self._post(url = url,body = kwargs)
    return self.parser.parse(res)

async def get_updates (self,**kwargs):
    url = self.url.add_method("getUpdates")
    res = await self._get(url = url,headers = kwargs)
    return [self.parser.parse(update) for update in res]

for any questions, please raise them in the Q&A section of the discussion @kallyas @ushergodwin

ushergodwin commented 1 year ago

Duly noted.

kallyas commented 1 year ago

@ht-thomas @ushergodwin Is this complete?

ToebiasHT commented 1 year ago

@kallyas I think one API module is still incomplete. The one for the general objects.

kallyas commented 1 year ago

Oh even general objects, so is the implementation the same?

ToebiasHT commented 1 year ago

@kallyas yes. Basically the same as the other API objects. Unless there are methods that require special attention

ToebiasHT commented 1 year ago

@kallyas are you planning to work on this?

kallyas commented 1 year ago

yes, I'm planning on continuing

ToebiasHT commented 1 year ago

@kallyas great. My target is now to make a beta release on sunday. I don't know if it will be possible

kallyas commented 1 year ago

Sure, I'll try

kallyas commented 1 year ago

@ht-thomas are they supposed to be in this file? https://github.com/OSCA-Kampala-Chapter/autobot/blob/b69b9ad20857aa941cd28db8543dcc1488a2013e/autobot/telegram/api.py#L2

ToebiasHT commented 1 year ago

@kallyas yes, the module already has function signatures that @ushergodwin wrote. Now they need to implement the functionality just like you did with the other API methods