This repository has been archived by the owner on Nov 1, 2024. It is now read-only.
generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Link Telegram Database #15
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c7cd1db
chore: switch to typescript
seprintour 6cdd6cb
chore: add installation token to json
seprintour a175643
chore: used steveantor declare.ts file
seprintour 8ecc777
Update src/helpers/navigation.ts
seprintour 2435df3
Update src/helpers/telegram.ts
seprintour 309d480
Update src/helpers/telegram.ts
seprintour 72fe281
chore: bring in sql migrations
seprintour c63646d
chore: setup supabase variables
seprintour 8737199
Update src/helpers/prompt.ts
seprintour dc80b20
chore: remove unnecessary codes
seprintour f98e95a
chore: add supabase
seprintour a318e01
chore: add updated readme
seprintour 14e356e
chore: channel support
seprintour 22feab5
Update supabase/README.md
seprintour b33f5ac
Update supabase/README.md
seprintour 9a0c1c1
chore: remove supabase type
seprintour 3fa6c4e
chore: rename variables
seprintour File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,8 +1,11 @@ | ||
{ | ||
"token": "", | ||
"telegram_bot_token": "", | ||
"webhook": "/endpoint", | ||
"secret": "QUEVEDO_BZRP_Random_String_52", | ||
"openai_api_key": "", | ||
"github_pat": "", | ||
"default_priority": "Priority: 0 (Normal)" | ||
} | ||
"default_priority": "Priority: 0 (Normal)", | ||
"github_installation_token": "", | ||
"supabase_key": "", | ||
"supabase_url": "" | ||
} |
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,18 +1,6 @@ | ||
import { RepoType } from "./types/Basic"; | ||
export const TIME_LABELS: string[] = ["Time: <1 Hour", "Time: <1 Day", "Time: <1 Week", "Time: <2 Weeks", "Time: <1 Month"]; | ||
|
||
export const repoMapping: RepoType[] = [ | ||
{ | ||
group: -1001738021587, | ||
github: "Seprintour-Test/test", | ||
}, | ||
{ | ||
group: -1001558587400, | ||
github: "ubiquity/testing-telegram-ubiquibot", | ||
}, | ||
]; | ||
|
||
export default { | ||
TIME_LABELS, | ||
repoMapping, | ||
TIME_LABELS | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { CallbackQueryType } from "../types/Basic"; | ||
|
||
import { setUserSession } from "./session"; | ||
import { getGroupDetails, listGroupsWithBot } from "./telegram"; | ||
import { editBotMessage } from "./triggers"; | ||
import { parseCallData } from "./utils"; | ||
|
||
export const handleFirstMenu = async (value: string, chatId: number, messageId: number, groupData: string) => { | ||
switch (value) { | ||
case "link_github": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recall asking about a |
||
await editBotMessage(chatId, messageId, `Please provide the URL of repository you want to link to this group.`); | ||
setUserSession(chatId, { v: "link_github", c: groupData }); | ||
break; | ||
default: | ||
break; | ||
} | ||
}; | ||
|
||
/** | ||
* Handle incoming callback_query (inline button press) | ||
* https://core.telegram.org/bots/api#message | ||
*/ | ||
export const onPrivateCallbackQuery = async (callbackQuery: CallbackQueryType) => { | ||
const parsedData = parseCallData(callbackQuery.data); | ||
const chatId = callbackQuery.message.chat.id; | ||
const messageId = callbackQuery.message.message_id; | ||
const fromId = callbackQuery.from.id; | ||
|
||
const item = parsedData[parsedData.length - 1]; // select the last calldata | ||
|
||
// Use the item.key and item.value to generate menu items | ||
switch (item.key) { | ||
case "group": | ||
const name = await getGroupDetails(item.value as number); | ||
await editBotMessage(chatId, messageId, `Here is your group: *${name}* \nWhat do you want to do?`, [ | ||
{ | ||
text: "Link Github Repo", | ||
callback_data: `${callbackQuery.data},menu:link_github`, | ||
}, | ||
]); | ||
break; | ||
case "menu": | ||
const groupData = parsedData[0]; | ||
await handleFirstMenu(item.value as string, chatId, messageId, groupData.value as string); | ||
break; | ||
case "group_list": | ||
await listGroupsWithBot(fromId, chatId, messageId); | ||
break; | ||
default: | ||
console.log(`Unknown key: ${item.key}`); | ||
break; | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const userSessions = new Map(); // Store user sessions and context | ||
|
||
export const setUserSession = (chatId: number, context: string | object) => { | ||
userSessions.set(chatId, context); | ||
}; | ||
|
||
export const getUserSession = (chatId: number) => { | ||
return userSessions.get(chatId); | ||
}; | ||
|
||
export const hasUserSession = (chatId: number) => { | ||
return userSessions.has(chatId); | ||
}; | ||
|
||
export const deleteUserSession = (chatId: number) => { | ||
userSessions.delete(chatId); | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you never renamed this to
PROMPT_SYSTEM