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

!!ddg command for querying duckduckgo #38

Open
Unihedro opened this issue Jan 23, 2015 · 1 comment
Open

!!ddg command for querying duckduckgo #38

Unihedro opened this issue Jan 23, 2015 · 1 comment

Comments

@Unihedro
Copy link
Owner

Queries the DuckDuckGo API and returns more appealing results, posting them in chat.
I've convinced the Javascript room to add this feature to Caprica, so we might as well as (try to) get it for our own bot as well. :P

Proposed command:

!!ddg
alias: [!!duckduckgo]

As a demonstration, this query of 'duck' on duckduckgo API returns pretty json:

{
   "DefinitionSource" : "",
   "Heading" : "Duck",
   "ImageWidth" : 0,
   "RelatedTopics" : [
      {
         "Result" : "<a href=\"https://duckduckgo.com/Duck\">Duck</a> The common name for a large number of species in the Anatidae family of birds, which also...",
         "Icon" : {
            "URL" : "",
            "Height" : "",
            "Width" : ""
         },
         "FirstURL" : "https://duckduckgo.com/Duck",
         "Text" : "Duck The common name for a large number of species in the Anatidae family of birds, which also..."
      },
      {
         "Result" : "<a href=\"https://duckduckgo.com/Anaheim_Ducks\">Anaheim Ducks</a>A professional ice hockey team based in Anaheim, California, United States.",
         "Icon" : {
            "URL" : "",
            "Height" : "",
            "Width" : ""
         },
         "FirstURL" : "https://duckduckgo.com/Anaheim_Ducks",
         "Text" : "Anaheim DucksA professional ice hockey team based in Anaheim, California, United States."
      },
      {
         "Result" : "<a href=\"https://duckduckgo.com/Ducati\">Ducati</a>Ducati Motor Holding S.p.A. is an Italian company that designs and manufactures motorcycles.",
         "Icon" : {
            "URL" : "https://duckduckgo.com/i/8d3cf6a1.png",
            "Height" : "",
            "Width" : ""
         },
         "FirstURL" : "https://duckduckgo.com/Ducati",
         "Text" : "DucatiDucati Motor Holding S.p.A. is an Italian company that designs and manufactures motorcycles."
      },
      {
         "Topics" : [
            {
               "Result" : "<a href=\"https://duckduckgo.com/don_Manley\">Duck (crossword compiler)</a>A long-serving setter of crosswords in the UK. He has supplied puzzles for the Radio Times, The...",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/don_Manley",
               "Text" : "Duck (crossword compiler)A long-serving setter of crosswords in the UK. He has supplied puzzles for the Radio Times, The..."
            }
         ],
         "Name" : "People"
      },
      {
         "Topics" : [
            {
               "Result" : "<a href=\"https://duckduckgo.com/Duck%2C_North_Carolina\">Duck, North Carolina</a>A town in Dare County, North Carolina, United States.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Duck%2C_North_Carolina",
               "Text" : "Duck, North CarolinaA town in Dare County, North Carolina, United States."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Duck%2C_West_Virginia\">Duck, West Virginia</a>An unincorporated community in Clay County, West Virginia, United States. Duck is northeast of Clay.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Duck%2C_West_Virginia",
               "Text" : "Duck, West VirginiaAn unincorporated community in Clay County, West Virginia, United States. Duck is northeast of Clay."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Monte_Creek\">Monte Creek</a>A rural locality on the South Thompson River east of Kamloops, British Columbia, Canada...",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Monte_Creek",
               "Text" : "Monte CreekA rural locality on the South Thompson River east of Kamloops, British Columbia, Canada..."
            }
         ],
         "Name" : "Places"
      },
      {
         "Topics" : [
            {
               "Result" : "<a href=\"https://duckduckgo.com/Duck_(bridge)\">Duck (bridge)</a>In the card game of contract bridge, to duck means to play low to a trick to which one has led...",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Duck_(bridge)",
               "Text" : "Duck (bridge)In the card game of contract bridge, to duck means to play low to a trick to which one has led..."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Duck_(cricket)\">Duck (cricket)</a> A batsman's dismissal for a score of zero.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Duck_(cricket)",
               "Text" : "Duck (cricket) A batsman's dismissal for a score of zero."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Oregon_Ducks\">Oregon Ducks</a>The Oregon Ducks refers to the sports teams of the University of Oregon, located in Eugene...",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Oregon_Ducks",
               "Text" : "Oregon DucksThe Oregon Ducks refers to the sports teams of the University of Oregon, located in Eugene..."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Long_Island_Ducks\">Long Island Ducks</a>An American professional baseball team based in Central Islip, New York.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Long_Island_Ducks",
               "Text" : "Long Island DucksAn American professional baseball team based in Central Islip, New York."
            }
         ],
         "Name" : "Sports and games"
      },
      {
         "Topics" : [
            {
               "Result" : "<a href=\"https://duckduckgo.com/Duck_(Alice's_Adventures_in_Wonderland)\">Duck (Alice's Adventures in Wonderland)</a>A fictional character appearing in Chapters 2 and 3 of the book Alice's Adventures in Wonderland...",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Duck_(Alice's_Adventures_in_Wonderland)",
               "Text" : "Duck (Alice's Adventures in Wonderland)A fictional character appearing in Chapters 2 and 3 of the book Alice's Adventures in Wonderland..."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Duck_the_Great_Western_Engine\">Duck the Great Western Engine</a>A fictional steam engine from The Railway Series by the Rev.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Duck_the_Great_Western_Engine",
               "Text" : "Duck the Great Western EngineA fictional steam engine from The Railway Series by the Rev."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Aflac_duck\">Aflac duck</a> The brand and mascot of Aflac Incorporated.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Aflac_duck",
               "Text" : "Aflac duck The brand and mascot of Aflac Incorporated."
            }
         ],
         "Name" : "Fictional characters"
      },
      {
         "Topics" : [
            {
               "Result" : "<a href=\"https://duckduckgo.com/Duck_(film)\">Duck (film)</a>A 2005 film by director/writer/producer Nic Bettauer.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Duck_(film)",
               "Text" : "Duck (film)A 2005 film by director/writer/producer Nic Bettauer."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Duck!_The_Carbine_High_Massacre\">Duck! The Carbine High Massacre</a> Duck! The Carbine High Massacre is a 1999 American comedy-drama film about a fictional school...",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Duck!_The_Carbine_High_Massacre",
               "Text" : "Duck! The Carbine High Massacre Duck! The Carbine High Massacre is a 1999 American comedy-drama film about a fictional school..."
            },
            {
               "Result" : "\"<a href=\"https://duckduckgo.com/?q=Duck!%20%2F%20Aren%27t%20You%20Chupacabra%20To%20See%20Me%3F\">Duck! / Aren't You Chupacabra To See Me?</a>\" An episode of The Grim Adventures of Billy and Mandy.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/?q=Duck!%20%2F%20Aren%27t%20You%20Chupacabra%20To%20See%20Me%3F",
               "Text" : "\"Duck! / Aren't You Chupacabra To See Me?\" An episode of The Grim Adventures of Billy and Mandy."
            }
         ],
         "Name" : "Film and television"
      },
      {
         "Topics" : [
            {
               "Result" : "<a href=\"https://duckduckgo.com/American_Canyon_Transit\">American Canyon Transit</a> Also known as \"The Duck\".",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/American_Canyon_Transit",
               "Text" : "American Canyon Transit Also known as \"The Duck\"."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Citro%C3%ABn_2CV\">Citro\u00ebn 2CV</a>A front-engine, front wheel drive, air-cooled economy car introduced at the 1948 Paris Mondial de...",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Citro%C3%ABn_2CV",
               "Text" : "Citro\u00ebn 2CVA front-engine, front wheel drive, air-cooled economy car introduced at the 1948 Paris Mondial de..."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Ducati\">Ducati</a>Ducati Motor Holding S.p.A. is an Italian company that designs and manufactures motorcycles.",
               "Icon" : {
                  "URL" : "https://duckduckgo.com/i/8d3cf6a1.png",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Ducati",
               "Text" : "DucatiDucati Motor Holding S.p.A. is an Italian company that designs and manufactures motorcycles."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Goodyear_Duck\">Goodyear Duck</a>A 1940s American three-seat light amphibian built by the Goodyear Aircraft Corporation.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Goodyear_Duck",
               "Text" : "Goodyear DuckA 1940s American three-seat light amphibian built by the Goodyear Aircraft Corporation."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Grumman_JF_Duck\">Grumman JF Duck</a> A single-engine amphibious biplane, built by Grumman for the United States Navy during the 1930s.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Grumman_JF_Duck",
               "Text" : "Grumman JF Duck A single-engine amphibious biplane, built by Grumman for the United States Navy during the 1930s."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/grumman_J2F_Duck\">J2F Duck</a>An American single-engine amphibious biplane.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/grumman_J2F_Duck",
               "Text" : "J2F DuckAn American single-engine amphibious biplane."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/DUKW\">DUKW</a>A six-wheel-drive modification of the 2-ton capacity \"deuce\" trucks used by the U.S. military in...",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/DUKW",
               "Text" : "DUKWA six-wheel-drive modification of the 2-ton capacity \"deuce\" trucks used by the U.S. military in..."
            }
         ],
         "Name" : "Transportation"
      },
      {
         "Topics" : [
            {
               "Result" : "<a href=\"https://duckduckgo.com/On2_Technologies\">On2 Technologies</a>A small publicly traded company, headquartered in Clifton Park, New York, that designed video...",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/On2_Technologies",
               "Text" : "On2 TechnologiesA small publicly traded company, headquartered in Clifton Park, New York, that designed video..."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Duck_Records\">Duck Records</a>The record label of Eric Clapton.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Duck_Records",
               "Text" : "Duck RecordsThe record label of Eric Clapton."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Duck_Studios\">Duck Studios</a>A production studio based in Los Angeles, California, USA. It focuses primarily on producing...",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Duck_Studios",
               "Text" : "Duck StudiosA production studio based in Los Angeles, California, USA. It focuses primarily on producing..."
            }
         ],
         "Name" : "Businesses"
      },
      {
         "Topics" : [
            {
               "Result" : "<a href=\"https://duckduckgo.com/Duck_(food)\">Duck (food)</a>A common livestock bird in many parts of the world. Duck is eaten in many cuisines around the world.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Duck_(food)",
               "Text" : "Duck (food)A common livestock bird in many parts of the world. Duck is eaten in many cuisines around the world."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Cotton_duck\">Cotton duck</a> A heavy, plain woven cotton fabric. There is also linen duck, which is less often used.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Cotton_duck",
               "Text" : "Cotton duck A heavy, plain woven cotton fabric. There is also linen duck, which is less often used."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/Duck_Samford_Stadium\">Duck Samford Stadium</a>A stadium in Auburn, Alabama.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Duck_Samford_Stadium",
               "Text" : "Duck Samford StadiumA stadium in Auburn, Alabama."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/cairn\">Ducks (hiking)</a> A man-made pile of stones. The word cairn comes from the c\u00e0rn.",
               "Icon" : {
                  "URL" : "https://duckduckgo.com/i/8a9ad1c0.jpg",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/cairn",
               "Text" : "Ducks (hiking) A man-made pile of stones. The word cairn comes from the c\u00e0rn."
            }
         ],
         "Name" : "Other uses"
      },
      {
         "Topics" : [
            {
               "Result" : "<a href=\"https://duckduckgo.com/Waterfowl\">Waterfowl</a>Waterfowl are certain wildfowl of the order Anseriformes, especially members of the family...",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/Waterfowl",
               "Text" : "WaterfowlWaterfowl are certain wildfowl of the order Anseriformes, especially members of the family..."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/d/Duct\">Duct Meanings</a>  See related meanings for the word 'Duct'.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/d/Duct",
               "Text" : "Duct Meanings  See related meanings for the word 'Duct'."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/d/Duckie\">Duckie Meanings</a>  See related meanings for the word 'Duckie'.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/d/Duckie",
               "Text" : "Duckie Meanings  See related meanings for the word 'Duckie'."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/d/Ducky\">Ducky Meanings</a>  See related meanings for the word 'Ducky'.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/d/Ducky",
               "Text" : "Ducky Meanings  See related meanings for the word 'Ducky'."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/d/Duck_Island\">Duck Island Meanings</a>  See related meanings for the phrase 'Duck Island'.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/d/Duck_Island",
               "Text" : "Duck Island Meanings  See related meanings for the phrase 'Duck Island'."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/d/Duck_Lake\">Duck Lake Meanings</a>  See related meanings for the phrase 'Duck Lake'.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/d/Duck_Lake",
               "Text" : "Duck Lake Meanings  See related meanings for the phrase 'Duck Lake'."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/d/Duck_River\">Duck River Meanings</a>  See related meanings for the phrase 'Duck River'.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/d/Duck_River",
               "Text" : "Duck River Meanings  See related meanings for the phrase 'Duck River'."
            },
            {
               "Result" : "<a href=\"https://duckduckgo.com/d/Duck_Creek\">Duck Creek Meanings</a>  See related meanings for the phrase 'Duck Creek'.",
               "Icon" : {
                  "URL" : "",
                  "Height" : "",
                  "Width" : ""
               },
               "FirstURL" : "https://duckduckgo.com/d/Duck_Creek",
               "Text" : "Duck Creek Meanings  See related meanings for the phrase 'Duck Creek'."
            }
         ],
         "Name" : "See also"
      }
   ],
   "Entity" : "",
   "Type" : "D",
   "Redirect" : "",
   "DefinitionURL" : "",
   "AbstractURL" : "https://en.wikipedia.org/wiki/Duck_(disambiguation)",
   "Definition" : "",
   "AbstractSource" : "Wikipedia",
   "Infobox" : "",
   "Image" : "",
   "ImageIsLogo" : 0,
   "Abstract" : "",
   "AbstractText" : "",
   "AnswerType" : "",
   "ImageHeight" : 0,
   "Results" : [],
   "Answer" : ""
}
@Vogel612
Copy link
Collaborator

Vogel612 commented Feb 6, 2015

soo what of that JSON would be posted to chat then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants