Comments (17)
There is no support for inline mode right now.
from telegram-bot-simple.
Will this be difficult to implement?
I'm still learning Haskell, but I feel like this could be easily implemented, just by defining an InlineQuery record, let Aeson parse it, and build an Update from there. But I guess I would need some help from the current collaborators...
from telegram-bot-simple.
Well, I tried doing exactly this, but I stuck with something that looks like an infinite recursion during parsing the query and I have no idea, how to fix or debug this.
from telegram-bot-simple.
@pavel-the-best May I kindly ask you to share the code you are currently working with in order to help you with infinite recursion?
from telegram-bot-simple.
Yes, here you go:
https://github.com/pavel-the-best/telegram-bot-simple/tree/inline-mode
from telegram-bot-simple.
Hi!
Sorry for the long delay.
I've been able to test @pavel-the-best implementation and it looks really good. I've been able to receive correctly inline queries, but couldn't send back results for that query. Currently, the data type InlineQueryResult (https://github.com/pavel-the-best/telegram-bot-simple/blob/a3a88369ffeb7c73802f6fb6725653bdc752de0c/src/Telegram/Bot/API/InlineMode.hs#L68) has only the type, id, and contact fields, so the other ones, required for other types of results are missing. Tomorrow I will check if just adding some fields will do the work, let's see what I can do, because I've never messed with something as advanced as Aeson...
In any case, this looks cool!
from telegram-bot-simple.
Ok, I've been taking a closer look at this, and there is work to do to get the answers/results work (If I understood it correctly, when an inline query comes, the bot should send "answers", and when the user chooses one, that comes to the bot as a "result". Thus, "answer" and "result" are not the same). those dataclasses need to be made, and then hopefully it work. Although I'm very novice, I think I can do, at least, most of it, so I will post here any progress I make!
from telegram-bot-simple.
Can you please provide EchoBot example that you used for testing this?
from telegram-bot-simple.
Sorry, I didn't used EchoBot. I made a bot the last month (https://git.sr.ht/~gdanix/marlin_gcode_info_bot), and I wanted to add inline mode to it, so I've been messing with my bot. In any case, I didn't do anything special, just created the bot with traceBotDefault
, and then saw that the inline mode queries started to get parsed and showed in the terminal.
I remember I had to uncomment 2 lines from Bot/API.hs to make it work, but it's just a matter of imports/exports.
from telegram-bot-simple.
Good news!!
I've been able to complete a minimal working support for inline mode, and modified EchoBot to make use of it. Now, it should respond to inline queries echoing the query itself.
I'm going to work now on cleaning up, documenting and structuring a bit better the dataclasses I've created.
One downside is that conversationBot doesn't work with inline mode, probably because inline queries doesn't have a chat id.
I've uploaded all the code to my fork: https://git.sr.ht/~gdanix/telegram-bot-simple
This is my very first contribution to a Haskell project any feedback (doesn't need to be kind, don't worry) is appreciated!
P.S. I forgot to blur the name of my testing bot in the first screenshot... Doesn't matter...
from telegram-bot-simple.
Hi! I've done a bit more of work for inline mode.
I've implemented the InputMessageContent dataclasses (https://core.telegram.org/bots/api#inputmessagecontent) in their own module.
Also, I've moved the InlineQueryResultType to it's own module, with the goal of moving all the InlineQueryResult-related dataclasses there (https://core.telegram.org/bots/api#inlinequeryresult)
EchoBot has been updated to make use of the new dataclasses.
I've uploaded all the progress to my fork (https://git.sr.ht/~gdanix/telegram-bot-simple). Please @swamp-agr, let me know if you can grab the changes from there and publish here, or if you prefer me to open a Pull Request.
Currently, with these latest additions, a bot can respond to inline queries, and can send back only article results (text, basically). Since all the InputMessageContent dataclasses are in place, these article displayed to the user can result in a text message (like in the above screenshots), but also in a venue, location or contact message.
What's left to do is to implement the different result dataclasses. There are a huge number of them, but also the article result must be completed (url, reply_markup, and so on). Also the ChosenInlineResult.
from telegram-bot-simple.
Hi!
I've been looking for a "contributing" file, and I didn't find it. I would really like this library to be complete. Sadly, this is my first time contributing to a Haskell library, and I'm a bit lost. I'm sorry if I didn't do things right.
What would be an appropriate plan for delivering this inline mode? To build it on top of the latest version? (I just continued working from the @pavel-the-best work). I guess, since the project is in GitHub, the PR workflow must be followed.
from telegram-bot-simple.
Hi @gDanix,
Please go ahead and open pull request. You contribution is welcome here.
I will let you know if something should be changed among the way during review process.
Best Regards,
@swamp-agr
from telegram-bot-simple.
Thank you so much!!
I will redo my changes on top of the latest version (0.3.5, IIRC) and open a PR.
I don't think it would be necessary to backport them to previous versions. but let me know if you're interested!
from telegram-bot-simple.
🎉 Inline support from #45 released on hackage: telegram-bot-simple-0.3.7
.
👍 @gDanix @pavel-the-best thank you!
from telegram-bot-simple.
If there's nothing to add feel free to close the issue.
from telegram-bot-simple.
Closing in absence of comments. Feel free to re-open at any time.
from telegram-bot-simple.
Related Issues (20)
- Bot API 6.0
- Version 6.0 won't compile HOT 1
- Inconsistency in parseMode fields HOT 3
- DecodeFailure on copyMessage HOT 1
- What is callbackQueryDataRead? HOT 1
- `command` UpdateParser is eating newlines HOT 2
- High CPU usage HOT 6
- Add support for bot mention in command HOT 1
- `Telegram.Bot.API.UpdatingMessages.editMessageReplyMarkup` is seemingly broken HOT 1
- Bot API 6.6 HOT 1
- telegram-bot-simple-0.11 + telegram-bot-api-6.5 as dependencies
- Bot API 6.7
- Inline mode is broken HOT 1
- SendMessage hangs indefinitely on some sendMessageText field values HOT 1
- Telegram-bot-simple hangs when something kills the thread responsible for actions processing HOT 1
- Bot API 6.8
- Bot API 6.9
- Bot API 7.0 🔥 HOT 1
- Support Mini Apps (WebApp)
- Update UpdateType
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegram-bot-simple.