mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-22 23:25:41 +01:00
added youtube audio extractor, dice, and direct response for images
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
from itertools import islice
|
||||
from typing import Dict
|
||||
|
||||
@@ -10,6 +11,8 @@ class DDGWebSearchPlugin(Plugin):
|
||||
"""
|
||||
A plugin to search the web for a given query, using DuckDuckGo
|
||||
"""
|
||||
def __init__(self):
|
||||
self.safesearch = os.getenv('DUCKDUCKGO_SAFESEARCH', 'moderate')
|
||||
|
||||
def get_source_name(self) -> str:
|
||||
return "DuckDuckGo"
|
||||
@@ -24,9 +27,22 @@ class DDGWebSearchPlugin(Plugin):
|
||||
"query": {
|
||||
"type": "string",
|
||||
"description": "the user query"
|
||||
},
|
||||
"region": {
|
||||
"type": "string",
|
||||
"enum": ['xa-ar', 'xa-en', 'ar-es', 'au-en', 'at-de', 'be-fr', 'be-nl', 'br-pt', 'bg-bg',
|
||||
'ca-en', 'ca-fr', 'ct-ca', 'cl-es', 'cn-zh', 'co-es', 'hr-hr', 'cz-cs', 'dk-da',
|
||||
'ee-et', 'fi-fi', 'fr-fr', 'de-de', 'gr-el', 'hk-tzh', 'hu-hu', 'in-en', 'id-id',
|
||||
'id-en', 'ie-en', 'il-he', 'it-it', 'jp-jp', 'kr-kr', 'lv-lv', 'lt-lt', 'xl-es',
|
||||
'my-ms', 'my-en', 'mx-es', 'nl-nl', 'nz-en', 'no-no', 'pe-es', 'ph-en', 'ph-tl',
|
||||
'pl-pl', 'pt-pt', 'ro-ro', 'ru-ru', 'sg-en', 'sk-sk', 'sl-sl', 'za-en', 'es-es',
|
||||
'se-sv', 'ch-de', 'ch-fr', 'ch-it', 'tw-tzh', 'th-th', 'tr-tr', 'ua-uk', 'uk-en',
|
||||
'us-en', 'ue-es', 've-es', 'vn-vi', 'wt-wt'],
|
||||
"description": "The region to use for the search. Infer this from the language used for the"
|
||||
"query. Default to `wt-wt` if not specified",
|
||||
}
|
||||
},
|
||||
"required": ["query"],
|
||||
"required": ["query", "region"],
|
||||
},
|
||||
}]
|
||||
|
||||
@@ -34,8 +50,8 @@ class DDGWebSearchPlugin(Plugin):
|
||||
with DDGS() as ddgs:
|
||||
ddgs_gen = ddgs.text(
|
||||
kwargs['query'],
|
||||
region='wt-wt',
|
||||
safesearch='off'
|
||||
region=kwargs.get('region', 'wt-wt'),
|
||||
safesearch=self.safesearch
|
||||
)
|
||||
results = list(islice(ddgs_gen, 3))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user