Giter Site home page Giter Site logo

Smart Interfaces about core HOT 16 CLOSED

php-telegram-bot avatar php-telegram-bot commented on August 19, 2024
Smart Interfaces

from core.

Comments (16)

akalongman avatar akalongman commented on August 19, 2024

All messages already tracked. We can store state in db, but I think will be better if first we complete what we have :) And after we will add more features

from core.

MBoretto avatar MBoretto commented on August 19, 2024

I think about this because i'm making experiment with custom keyboard, and is mandatory to use this implementation.
If you press a button on the keyboard a message is sent to the bot without command.
So the bot have to manage message without command and at the end execute the command.
However soon i will pull the class ReplyMarkup to build easy keyboard.
Then we can think about it! ;)

from core.

akalongman avatar akalongman commented on August 19, 2024

You read CONTRIBUTING.md file? There is contributing notes. Also we must write more unit tests for our classes

from core.

MBoretto avatar MBoretto commented on August 19, 2024

Yes i red it! But i never use those intruments before so i have to study a bit!

from core.

MBoretto avatar MBoretto commented on August 19, 2024

Hi! I've got in my mind a way to implement this feature! I would like to have a feedback before start seriously to code.

To do this i need a new .sql table:

CREATE TABLE `track` (
  `id` bigint UNSIGNED AUTOINCREMENT COMMENT 'tract id',
  `track_name` CHAR(255) COMMENT 'Name of the command to execute',
  `user_id` bigint  COMMENT 'User that wrote the message',
  `data` VARCHAR(10000) COMMENT 'Data stored from command',
  `date` int(11) UNSIGNED COMMENT 'Date the track in Unix time',
   PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci

I would like to add 3 methods to the Command class:

  • startTrack(){}
    Check if a track has already been created in the database. If the track is not found, a new track is created.
    startTrack fetch the data stored in the database with unserialize() function:
    $data = startTrack();
  • updateTrack($data){}
    Store the array/variable in the database with serialize() function
  • deleteTrack(){}
    delete the track from the database

When a new message arrive without command, the bot check if a track for the user is stored on the database, then if a track is found the message is handled by the command stored in the track.

from core.

akalongman avatar akalongman commented on August 19, 2024

I think will be better in tracks table store not full data, store message_id. Messages already stored in messages table

from core.

MBoretto avatar MBoretto commented on August 19, 2024

The data field is also intended for store information useful in the future interaction with the user maybe some Flags or status. Something like $_SESSION

I prefer non to include a field with message_id because a track can include multiple interaction with the user for example:
user: /calc
bot: press calculous on the keyboard! (track is started a row is added to the db)
user: 2 (the bot execute calc command and store in the track the element 2)
user: * (the bot execute calc command and store in the track the element *)
user: 5 (the bot execute calc command and store in the track the element 5)
user: = (the bot execute calc command the full command is executed)
bot: 2 * 5 = 10 (the bot show the result and delete the track)

To avoid store rendundat information from messages i have to create another table to link track and messages something like:

id
track_id
message_id

from core.

danielberlin avatar danielberlin commented on August 19, 2024

Sounds good! I would need that as well for a convenient interface, will be your tester once it is available.

from core.

ericxxp avatar ericxxp commented on August 19, 2024

Good job man ! I like it

from core.

hakdig avatar hakdig commented on August 19, 2024

Good idea. I have a suggestion to add a "status" column to store data like : in progress, cancelled, finish. It let the possibility to add a button "cancel" to the custom keyboard and forget the scenario.

from core.

MBoretto avatar MBoretto commented on August 19, 2024

I like your idea @hagdig !
I wrote a code to do this.
I didn't share it yet because it add complexity to command interface.
I think that the library is not ready for this:
with the new inline feature a lot of work should be done in order to build a new table schema able to store the inline query.

If you and other people are interested we can complete the library with those feature and impove my tracking system!

from core.

FerX avatar FerX commented on August 19, 2024

I'm interested !

from core.

MBoretto avatar MBoretto commented on August 19, 2024

@FerX can you describe in details the feature you're looking for?

from core.

FerX avatar FerX commented on August 19, 2024

the possibility of defining a dynamic menu tree

from core.

MBoretto avatar MBoretto commented on August 19, 2024

There is PR open for this feature. @hakdig I implented you status columns that could be: active stopped cancelled

from core.

MBoretto avatar MBoretto commented on August 19, 2024

Smart interfaces has been introduced since 0.29. I'm closing this, then we can open another issue to improve this feature 🎉

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.