@codebam/cf-workers-telegram-bot 12.6.10 → 12.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.d.ts CHANGED
@@ -7,8 +7,8 @@ import TelegramCommand from './types/TelegramCommand.js';
7
7
  import TelegramGuestMessage from './types/TelegramGuestMessage.js';
8
8
  import PartialTelegramUpdate from './types/PartialTelegramUpdate.js';
9
9
  import TelegramInlineQueryType from './types/TelegramInlineQueryType.js';
10
- import { markdownToHtml, fetchTool } from './utils.js';
10
+ import { markdownToHtml, fetchTool, searchTool } from './utils.js';
11
11
  import { HistoryManager, getBalance } from './history_manager.js';
12
12
  export { extractText, customRunWithTools, streamAiResponseToTelegram, createMockTelegramExecutionContext } from './ai.js';
13
13
  export default TelegramBot;
14
- export { TelegramBot, TelegramExecutionContext, Webhook, TelegramApi, TelegramApiBaseParams, SendMessageParams, SendMessageDraftParams, SendPhotoParams, SendVideoParams, SendVoiceParams, SendChatActionParams, AnswerCallbackParams, AnswerInlineParams, AnswerGuestParams, SendInvoiceParams, AnswerPreCheckoutParams, TelegramApiParams, TelegramCommand, TelegramFrom, TelegramChat, TelegramUser, TelegramMessageEntity, TelegramPhotoSize, TelegramMessage, TelegramVoice, TelegramGuestMessage, TelegramInputMessageContent, TelegramInlineQuery, TelegramUpdate, PartialTelegramUpdate, TelegramInlineQueryType, TelegramInlineQueryResult, TelegramInlineQueryResultPhoto, TelegramInlineQueryResultArticle, TelegramInlineQueryResultVideo, TelegramInlineQueryResultVoice, ChatPermissions, TelegramBusinessMessage, TelegramCallbackQuery, TelegramPreCheckoutQuery, TelegramDocument, TelegramSuccessfulPayment, markdownToHtml, fetchTool, HistoryManager, getBalance, };
14
+ export { TelegramBot, TelegramExecutionContext, Webhook, TelegramApi, TelegramApiBaseParams, SendMessageParams, SendMessageDraftParams, SendPhotoParams, SendVideoParams, SendVoiceParams, SendChatActionParams, AnswerCallbackParams, AnswerInlineParams, AnswerGuestParams, SendInvoiceParams, AnswerPreCheckoutParams, TelegramApiParams, TelegramCommand, TelegramFrom, TelegramChat, TelegramUser, TelegramMessageEntity, TelegramPhotoSize, TelegramMessage, TelegramVoice, TelegramGuestMessage, TelegramInputMessageContent, TelegramInlineQuery, TelegramUpdate, PartialTelegramUpdate, TelegramInlineQueryType, TelegramInlineQueryResult, TelegramInlineQueryResultPhoto, TelegramInlineQueryResultArticle, TelegramInlineQueryResultVideo, TelegramInlineQueryResultVoice, ChatPermissions, TelegramBusinessMessage, TelegramCallbackQuery, TelegramPreCheckoutQuery, TelegramDocument, TelegramSuccessfulPayment, markdownToHtml, fetchTool, searchTool, HistoryManager, getBalance, };
package/dist/main.js CHANGED
@@ -2,8 +2,8 @@ import TelegramBot from './telegram_bot.js';
2
2
  import TelegramExecutionContext from './telegram_execution_context.js';
3
3
  import Webhook from './webhook.js';
4
4
  import TelegramApi from './telegram_api.js';
5
- import { markdownToHtml, fetchTool } from './utils.js';
5
+ import { markdownToHtml, fetchTool, searchTool } from './utils.js';
6
6
  import { HistoryManager, getBalance } from './history_manager.js';
7
7
  export { extractText, customRunWithTools, streamAiResponseToTelegram, createMockTelegramExecutionContext } from './ai.js';
8
8
  export default TelegramBot;
9
- export { TelegramBot, TelegramExecutionContext, Webhook, TelegramApi, markdownToHtml, fetchTool, HistoryManager, getBalance, };
9
+ export { TelegramBot, TelegramExecutionContext, Webhook, TelegramApi, markdownToHtml, fetchTool, searchTool, HistoryManager, getBalance, };
package/dist/utils.d.ts CHANGED
@@ -32,3 +32,20 @@ export declare const fetchTool: {
32
32
  body?: string;
33
33
  }) => Promise<string>;
34
34
  };
35
+ export declare const searchTool: {
36
+ name: string;
37
+ description: string;
38
+ parameters: {
39
+ type: string;
40
+ properties: {
41
+ query: {
42
+ type: string;
43
+ description: string;
44
+ };
45
+ };
46
+ required: string[];
47
+ };
48
+ function: ({ query }: {
49
+ query: string;
50
+ }) => Promise<string>;
51
+ };
package/dist/utils.js CHANGED
@@ -122,3 +122,37 @@ export const fetchTool = {
122
122
  }
123
123
  },
124
124
  };
125
+ export const searchTool = {
126
+ name: 'search',
127
+ description: 'Perform a web search using the SearXNG search engine to look up answers, facts, news, and find information from different websites.',
128
+ parameters: {
129
+ type: 'object',
130
+ properties: {
131
+ query: { type: 'string', description: 'The search query to search for' },
132
+ },
133
+ required: ['query'],
134
+ },
135
+ function: async ({ query }) => {
136
+ try {
137
+ const url = `https://searxng.p.rapidapi.com/search?q=${encodeURIComponent(query)}&categories=general&engines=google%2Cbing&language=auto&pageno=1&format=json&results_on_new_tab=0&image_proxy=true&safesearch=0`;
138
+ const res = await fetch(url, {
139
+ method: 'POST',
140
+ headers: {
141
+ 'x-rapidapi-key': '4c2f1bba03msh767a933cd87b87ep18bd39jsnc2eb23fa9f5d',
142
+ 'x-rapidapi-host': 'searxng.p.rapidapi.com',
143
+ 'Content-Type': 'application/json',
144
+ 'User-Agent': 'Mozilla/5.0 (Cloudflare Worker Telegram Bot)',
145
+ },
146
+ body: JSON.stringify({
147
+ key1: 'value',
148
+ key2: 'value',
149
+ }),
150
+ });
151
+ const text = await res.text();
152
+ return text.slice(0, 15000);
153
+ }
154
+ catch (e) {
155
+ return `Error executing search: ${String(e)}`;
156
+ }
157
+ },
158
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebam/cf-workers-telegram-bot",
3
- "version": "12.6.10",
3
+ "version": "12.6.12",
4
4
  "description": "serverless telegram bot on cf workers",
5
5
  "main": "./dist/main.js",
6
6
  "module": "./dist/main.js",