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

Added support for duckduckgo search. #151

Merged
merged 3 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ GUI clients are used to manage plugins, launch bot as well as specify credential
| :page_with_curl: comic | Returns a random comic | [@mboekhold](https://github.com/mboekhold) |
| 📝 todo | Makes a to do list | [@h-ranjan1110](https://github.com/h-ranjan1110) |
| 🎱 Magic 8 Ball | Answer questions using magic 8 ball | [@ZakariaTalhami](https://github.com/ZakariaTalhami) |
| 🦆 DuckDuckGo Search | Search queries in duckduckgo and return abstract. | [@rakeshseal0](https://github.com/rakeshseal0) |

## ⚡ Quickstart

Expand Down
Empty file.
11 changes: 11 additions & 0 deletions src/honeybot/plugins/downloaded/duckduckgo/info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
NAME = "duck.py"
ORIGINAL_AUTHORS = ["Rakesh Seal"]

ABOUT = """
Returns a abstract of the search query from a duckduckgo Search. Return empty if no abstract found.
"""

COMMANDS = """
>>> .duck <query>
returns abstrack from duckduckgo search
"""
37 changes: 37 additions & 0 deletions src/honeybot/plugins/downloaded/duckduckgo/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
"""
[duckduckgo.py]
Duckduckgo Plugin

[Author]
Rakesh Seal

[About]
Returns a abstract of the search query from a duckduckgo Search. Return empty if no abstract found.
[Website]


[Commands]
>>> .duck <query>
returns abstrack from duckduckgo search
"""

import requests


class Plugin:
def __init__(self):
pass

def __gen_url_from_query(self, query):
return "https://duckduckgo.com/?q=" + query + "&format=json&pretty=1"

def run(self, incoming, methods, info, bot_info):
try:
msgs = info["args"][1:][0].split()
if info['command'] == 'PRIVMSG' and msgs[0] == '.duck':
query = ' '.join(msg for msg in msgs[1:])
duck_abstract = requests.get(self.__gen_url_from_query(query)).json()["Abstract"]
methods['send'](info['address'], duck_abstract)
except Exception as e:
print("quack quack!", e)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests