-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.ts
79 lines (76 loc) · 1.73 KB
/
bot.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require("dotenv").config();
import { Bot, Context, session, SessionFlavor } from "grammy";
import { initializeCommands } from "./bot/commands";
import { initiateCallbackQueries } from "./bot/callbackqueries";
import { initializeInputs } from "./bot/input";
import { initcache } from "./utils/cache";
interface SessionData {
amount: string;
amount_withdraw: string;
token: string;
balances: any;
ref?: string;
limit_price: string;
wallet: string;
input_tag: string;
reply: boolean;
sequence_number: number;
currentmsg: number;
currentchatid: number;
userid: string;
percentage?: string;
config: {
gasLimit: string;
slippage: string;
gasPricedelta: string;
};
wallet_leo: any;
costum_amount: boolean;
address: string;
sessionset: boolean;
awaitingAmount: boolean;
history: number;
rpc_url: string;
}
export type MyContext = Context & SessionFlavor<SessionData>;
let reply = false;
let input_tag: any = "";
export const bot = new Bot<MyContext>(process.env.BOT_KEY as string);
function initial(): SessionData {
return {
amount: "0",
amount_withdraw: "0",
token: "",
limit_price: "",
balances: [],
wallet: "",
input_tag: "",
reply: false,
wallet_leo: null,
sequence_number: 0,
userid: "",
currentmsg: 0,
percentage: "0.5",
currentchatid: 0,
config: {
gasLimit: "20000",
slippage: "5",
gasPricedelta: "3",
},
address: "",
sessionset: false,
costum_amount: false,
awaitingAmount: false,
history: 0,
rpc_url: "https://manta-pacific.drpc.org"
};
}
bot.use(session({ initial }));
try {
initializeCommands();
initiateCallbackQueries();
initializeInputs();
} catch (e) {
console.log(e);
}
bot.start()