-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
168 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,4 +99,4 @@ | |
"@commitlint/config-conventional" | ||
] | ||
} | ||
} | ||
} |
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
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,44 @@ | ||
import { chatAction } from "@grammyjs/auto-chat-action"; | ||
import { Composer } from "grammy"; | ||
import { GrammyContext } from "../../../helpers/grammy-context"; | ||
import { logHandle } from "../../../helpers/logging"; | ||
|
||
const composer = new Composer<GrammyContext>(); | ||
|
||
const feature = composer.chatType("private"); | ||
|
||
/** | ||
* Pairs the user's Telegram ID with the user's GitHub ID. | ||
*/ | ||
feature.command("wallet", logHandle("command-wallet"), chatAction("typing"), async (ctx) => { | ||
const userId = ctx.from?.id; | ||
const walletAddress = ctx.message?.text?.split(" ")[1]; | ||
|
||
const user = await ctx.adapters.github.retrieveUserByTelegramId(userId); | ||
|
||
if (!user) { | ||
await ctx.reply("You are not registered. Please register first."); | ||
return; | ||
} | ||
|
||
try { | ||
await ctx.adapters.github.handleUserBaseStorage( | ||
{ | ||
...user, | ||
walletAddress, | ||
}, | ||
"update" | ||
); | ||
} catch (er) { | ||
if (er instanceof Error) { | ||
await ctx.reply(ctx.logger.error(`${er.message}`, { er, userId, walletAddress }).logMessage.raw); | ||
return; | ||
} | ||
await ctx.reply("An error occurred while trying to register your wallet."); | ||
return; | ||
} | ||
|
||
await ctx.reply(`Your wallet address has been successfully registered.`); | ||
}); | ||
|
||
export { composer as walletFeature }; |
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
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
Oops, something went wrong.