-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Simplifying the search feature (#58)
* feat: auto delete command & reply the tweet url * docs: add comment about reply * feat: update to use gpt-4o for allow user (#57) * docs: TODO * help * refactor: stash * typo: twitter -> xlog * update comment * go to sleep * feat: handle sender_chat * do anything * refactor: remove inline bot * feat: update to use gpt-4o for allow user * refactor: use grammy instead myself type * fix: LLM permission * feat: add comment to github issue
- Loading branch information
Showing
18 changed files
with
516 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
"dependencies": { | ||
"crossbell": "^1.12.0", | ||
"crypto-js": "^4.2.0", | ||
"grammy": "^1.23.0", | ||
"oauth-1.0a": "^2.2.6", | ||
"openai": "^4.33.0", | ||
"telegramify-markdown": "git+ssh://[email protected]/niracler/telegramify-markdown.git#master" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Env as CoreEnv } from "@/core/type" | ||
import { Update } from "grammy/types" | ||
|
||
export type Env = {} & CoreEnv | ||
|
||
/** | ||
* Processes the syncXLog command by syncing a message with XLog. | ||
* | ||
* @param update - The Telegram update object. | ||
* @param env - The environment object. | ||
* @returns A promise that resolves to a string indicating the result of the sync operation. | ||
*/ | ||
export async function processChannel(update: Update, env: Env): Promise<string> { | ||
|
||
const message = update.message?.text || update.message?.caption || '' | ||
const command = message.split(' ')[0] | ||
const content = message.slice(command.length + 1) | ||
|
||
const res = await env.DB.prepare('SELECT * FROM telegram_messages WHERE text LIKE ?').bind(`%${content}%`).all() | ||
// console.log('channel', command, content) | ||
|
||
// const aa = "niracler_channel" | ||
|
||
// const res = await env.DB.prepare('SELECT * FROM telegram_messages WHERE sender_chat_username LIKE ?').bind(`%${aa}%`).all() | ||
|
||
return `channel ${command} ${content} ${JSON.stringify(res)}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,6 @@ | ||
export type Env = { | ||
TELEGRAM_BOT_SECRET: string | ||
DB: D1Database | ||
} | ||
|
||
export interface TelegramUpdate { | ||
update_id: number // Update ID from Telegram | ||
message: TelegramMessage // Message object, optional | ||
// 添加更多的更新相关字段| Add more update related fields | ||
} | ||
|
||
interface TelegramChat { | ||
id: number // Chat ID | ||
title?: string // Chat title, optional | ||
username?: string // Username, optional | ||
type: string // Type of chat, one of "private", "group", "supergroup" or "channel" | ||
// 添加更多的聊天相关字段 | Add more chat related fields | ||
} | ||
|
||
interface TelegramPhoto { | ||
file_id: string // 可用于获取文件内容 | Can be used to get file content | ||
file_unique_id: string // 文件的唯一标识符 | Unique identifier for this file | ||
width: number // 图片宽度 | Image width | ||
height: number // 图片高度 | Image height | ||
file_size?: number // 文件大小(可选) | File size (optional) | ||
} | ||
|
||
export interface TelegramMessage { | ||
message_id: number // Message ID | ||
chat: TelegramChat // Chat object | ||
text?: string // Received message text, optional | ||
reply_to_message?: TelegramMessage // 添加这个字段来获取回复的消息 | Add this field to get the replied message | ||
from: { | ||
username: string // 发送者的用户名 | Sender's username | ||
id: string // 发送者的ID | Sender's ID | ||
first_name: string // 发送者的名字 | Sender's first name | ||
}, | ||
sender_chat?: TelegramChat // Sender's chat object, optional | ||
caption?: string | ||
photo?: TelegramPhoto[] // TelegramPhoto需要根据API定义 | TelegramPhoto needs to be defined according to the API | ||
forward_from_chat?: TelegramChat // Forwarded from chat object, optional | ||
forward_from_message_id?: number // Forwarded from message ID, optional | ||
media_group_id?: string // Media group ID | ||
quote?: { | ||
text: string | ||
is_manual?: boolean | ||
} | ||
date: number // Unix timestamp | ||
// 添加更多的消息相关字段 | Add more message related fields | ||
TELEGRAM_BOT_USERNAME: string | ||
TELEGRAM_BOT_SECRET: string | ||
ALLOW_USER_IDS: string[] | ||
DB: D1Database | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.