Skip to content

Commit f191c5a

Browse files
authored
Merge pull request #19 from fabriguespe/commands_v1
Commands v1
2 parents 39de830 + 9176c14 commit f191c5a

31 files changed

+545
-658
lines changed

Diff for: README.md

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ See more examples in the [Awesome XMTP ⭐️](https://github.com/xmtp/awesome-x
2828
2929
- `yarn start:conversational`: Start the conversational bot
3030
- `yarn start:gm`: Start the GM bot
31-
- `yarn start:gpt`: Start the ChatGPT bot
3231
- `yarn start:group`: Start the Group bot
3332

3433
## Contributing

Diff for: examples/gpt/.env.example

-4
This file was deleted.

Diff for: examples/gpt/LICENSE.md

-21
This file was deleted.

Diff for: examples/gpt/README.md

-62
This file was deleted.

Diff for: examples/gpt/package.json

-33
This file was deleted.

Diff for: examples/gpt/src/index.ts

-23
This file was deleted.

Diff for: examples/gpt/src/lib/gpt.ts

-68
This file was deleted.

Diff for: examples/gpt/tsconfig.json

-7
This file was deleted.

Diff for: examples/group/src/bots/basebet.ts

+15-51
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,25 @@
11
import { HandlerContext } from "@xmtp/botkit";
22
import { Wallet } from "ethers";
33
import { Client as xmtpClient } from "@xmtp/xmtp-js";
4-
import { extractCommandValues } from "../lib/helper.js";
5-
import { users } from "../lib/users.js";
6-
7-
const commandConfig = {
8-
bet: {
9-
params: {
10-
username: [],
11-
name: [],
12-
amount: [],
13-
},
14-
},
15-
};
164

175
export async function handler(context: HandlerContext) {
186
const { content, senderAddress } = context.message;
7+
const { params } = content;
8+
const { amount, name, users } = params;
199

20-
const extractedValues = extractCommandValues(content, commandConfig);
21-
let url = "";
22-
switch (extractedValues.command) {
23-
case "bet":
24-
const { amount, name, username } = extractedValues.params;
25-
if (!amount || !name || !username) {
26-
context.reply(
27-
"Missing required parameters. Please provide amount, token, and username.",
28-
);
29-
return;
30-
}
31-
32-
// Ensure that amount, name, and username are treated as single strings
33-
const singleName = Array.isArray(name) ? name[0] : name;
34-
const singleAmount = Array.isArray(amount) ? amount[0] : amount;
35-
36-
/* This is for creating a group
37-
38-
const recipientUser = users.find(
39-
//@ts-ignore
40-
(user) => user.username === username[0]?.replace("@", ""),
41-
);
42-
if (!recipientUser || !recipientUser.address) {
43-
context.reply("User not found or user address is missing.");
44-
return;
45-
}
46-
*/
47-
url = await generateBetUrl(
48-
context.message.senderAddress,
49-
singleName,
50-
singleAmount,
51-
);
52-
context.reply(`Bet created!. Go here: ${url}`, []);
53-
break;
54-
default:
55-
context.reply(
56-
"Unknown command. Use /help to see all available commands.",
57-
);
10+
if (!amount || !name || !users) {
11+
context.reply(
12+
"Missing required parameters. Please provide amount, token, and username.",
13+
);
14+
return;
5815
}
16+
17+
let url = await generateBetUrl(
18+
senderAddress,
19+
name as string,
20+
amount as string,
21+
);
22+
context.reply(`Bet created!. Go here: ${url}`, []);
5923
}
6024

6125
async function generateBetUrl(
@@ -74,7 +38,7 @@ async function generateBetUrl(
7438
`https://base-frame-lyart.vercel.app/transaction?transaction_type=send&amount=1&token=eth&receiver=0xA45020BdA714c3F43fECDC6e38F873fFF2Dec8ec`,
7539
);
7640
await conv.send(
77-
`Place your bet tx:0xf0490b45884803924Ca84C2051ef435991D7350D`,
41+
`Or use a deeplink. Place your bet tx:0xf0490b45884803924Ca84C2051ef435991D7350D`,
7842
);
7943
const link = `${baseUrl}${client.address}`;
8044
return link;

0 commit comments

Comments
 (0)