-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.ts
35 lines (28 loc) · 990 Bytes
/
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
import "https://deno.land/[email protected]/dotenv/load.ts";
import { Bot } from "https://deno.land/x/[email protected]/mod.ts";
const BOT_TOKEN = Deno.env.get("BOT_TOKEN")
if (typeof BOT_TOKEN === "undefined")
throw new Error("BOT_TOKEN is not defined")
const bot = new Bot(BOT_TOKEN);
bot.command("start", async (ctx) => {
await ctx.reply(`M3 info bot
type /info to see you info
type /test to chek if the bot is working`);
});
bot.command("test", async (ctx) => {
await ctx.reply("Everything is Alright!", {
reply_to_message_id: ctx.msg.message_id,
});
});
bot.command("info", async (ctx) => {
await ctx.reply(`
First name: ${ctx.from?.first_name || ""}
User is: @${ctx.from?.username || ""}
id: ${ctx.chat.id}
Language code: ${ctx.from?.language_code || ""}
Bot?: ${ctx.from?.is_bot}`);
console.log(`UserName: ${ctx.from?.username} ,id: ${ctx.chat.id}`);
});
console.log("bot is starting...");
console.log("bot started");
bot.start();