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

Commands order and their execution #26

Closed
joniybek opened this issue Jan 5, 2017 · 2 comments
Closed

Commands order and their execution #26

joniybek opened this issue Jan 5, 2017 · 2 comments

Comments

@joniybek
Copy link

joniybek commented Jan 5, 2017

Hello @mukel
It is great pleasure to read your code and use this project. I have some idea that I found useful and also I have implementation and I can contribute if you let me.
So when we give commands with on(some:String){function} they don't preserve order and if we have "registered"command twice in code it will be executed twice. What if we will make commands ordered, execute them once so that we will play around with commands that match from specific to more general one?
Cheers,
/Jakhongir

@mukel
Copy link
Member

mukel commented Jan 5, 2017

Indeed, the commands should be executed in order (of declaration). Right now it's still using a hash map from legacy versions (should be a ListBuffer). I'll gladly accept a PR.

Giving some sort of priority is difficult since it's hard to enforce it's proper use, after all commands are just a predicate with an attached action, it's left open for developers. It could be a good idea to relax access modifiers in Commands.scala (everything is private right now) to make it possible.

@mukel
Copy link
Member

mukel commented Apr 16, 2017

Fixed, commands are now processed in the order or declaration.
https://github.com/mukel/telegrambot4s/blob/master/src/main/scala/info/mukel/telegrambot4s/api/Actions.scala#L19

@mukel mukel closed this as completed Apr 16, 2017
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

No branches or pull requests

2 participants