[Gambas-user] Request for advice
dovey.john at gmail.com
Tue Jul 13 18:53:09 CEST 2021
Thank you for this!! It makes it clearer.
>What I see in your project is you have separated the bot itself into two
separate classes when it appears they should be one
since they maintain properties, upon instantiation, for the same object.
I was under the impression that I would need to create a new object/class
for each of the "objects" which the app defines. On the page
https://core.telegram.org/bots/api#user you will see the "available types"
listed. Each one is _called_ an object. How would I implement those? Each
"object" has a list of properties. When requested from the api, each one is
returned (or set) as a JSON string. Some objects include others.. such as
the message <https://core.telegram.org/bots/api#message> which includes the
user <https://core.telegram.org/bots/api#user> (multiple times), the chat
<https://core.telegram.org/bots/api#chat> (multiple times), the message
<https://core.telegram.org/bots/api#message>, an array of messageentity
<https://core.telegram.org/bots/api#messageentity> objects, etc etc.
Would it make sense to have bot.message which includes bot.message.fromuser
, bot.message.forwardfromuser or rather bot.message(fromuser, forwardfrom)
(fromuser and forwardfrom are both user objects)? Also, I don't know how to
Sorry to be an absolute pain, but I am truly lost. If I can't figure this
out, it's back to spagetti dotnet VB code...
On Tue, 13 Jul 2021 at 11:25, T Lee Davidson <t.lee.davidson at gmail.com>
> On 7/13/21 11:29 AM, John Dovey wrote:
> > What I’m not sure about is the right way to do it.
> The "right" way to do it is whatever way works for you [and/or your
> user(s)] without causing undue issues for you, them, or the
> API server.
> I admit that Bruce's conceptualization is a bit confusing at first glance
> and may actually be more complex than necessary for
> your project. However, I do understand his reasoning for the separate
> classes, ie. mainly future maintenance.
> What I see in your project is you have separated the bot itself into two
> separate classes when it appears they should be one
> since they maintain properties, upon instantiation, for the same object.
> Also, if you are trying to follow Bruce's concept, the
> HTTP request functionality would be moved to its own module.
> The tb_APIdef class is merely to encapsulate the various API methods and
> the API endpoint (URL) in a separate file for ease of
> maintenance should they change.
> This is how I see the process working. The Main form (or module) is the
> manager. It creates, destroys, and manages any number of
> bots. When a bot is created, it should use the botMe method to establish
> its identity.
> To do this, it would query the tb_APIdef class and receive a properly
> formatted request URL, for that specific method, which it
> would then pass to the tb_interface module for processing. The
> tb_interface module would then return the data retrieved from the
> API endpoint, and tb_BOT would then populate its properties accordingly.
> (That same process would be used for other
> queries/methods as well.)
> I don't know what a chatphoto would be. But, if it is unique to a
> particular bot and does not have a multitude of required meta
> datum attached, then perhaps you could simply store it in a tb_BOT
> property and not bother with yet another class.
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the User