gurpreet-legend / Alan-Feed

A user-friendly AI-assisted news application
https://alan-feed.netlify.app/
MIT License
4 stars 10 forks source link

[Bug] - Fix the Alan AI listener #6

Open gurpreet-legend opened 2 years ago

gurpreet-legend commented 2 years ago

Bug:

Example: In alan-scripts.example.txt, Instead of :

    api.request(``, (error, response, body) => {
        const { articles } = JSON.parse(body);
        if(!articles) {
            p.play('Sorry, please try searching for a different category');
            return;
        }

        savedArticles = articles;

        p.play({ command : 'newHeadlines', articles});
        if(p.C.value) {
            p.play(`Here are the (latest|recent) articles on ${p.C.value}`);
        }
        else if(p.C.value == ''){
            p.play(`Here are the (latest|recent) news`);
        }

        p.play('Would you like me to read the headlines ?');
        p.then(confirmation);
    });

Use this:

    api.axios.get(NEWS_API_URL)
        .then((response) => {
            savedArticles = response.articles;
            p.play({ command : 'newHeadlines', savedArticles});
            if(p.C.value) {
                p.play(`Here are the (latest|recent) articles on ${p.C.value}`);
            }
            else if(p.C.value == ''){
                p.play(`Here are the (latest|recent) news`);
            }

            p.play('Would you like me to read the headlines ?');
            p.then(confirmation);
         })
         .catch((error) => {
                p.play('Sorry, please try searching for a different category');
         });
probro27 commented 2 years ago

Hi @gurpreet-legend I would like to work on this bug. Please assign it to me. Think I can work on this. Just to confirm, you want me edit the alan-script.example file and that should have axios calls. Is that correct? Because I cannot see anywhere else where you are making calls in the code.

gurpreet-legend commented 2 years ago

Hi @gurpreet-legend I would like to work on this bug. Please assign it to me. Think I can work on this. Just to confirm, you want me edit the alan-script.example file and that should have axios calls. Is that correct? Because I cannot see anywhere else where you are making calls in the code.

Yupp, exactly that I want

probro27 commented 2 years ago

Awesome, @gurpreet-legend check out my pull request #21

gurpreet-legend commented 2 years ago

Actually, I ran your script, there were some errors I resolved them and already made a push, so I think this issue had already been resolved, just make a pull request to verify.

probro27 commented 2 years ago

If you fixed the bug then that's fine. I'll just close the pull request.