-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
63 lines (46 loc) · 1.96 KB
/
index.js
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
import { Telegraf, Markup, Scenes, session } from 'telegraf';
import fs from 'fs-extra';
import path from 'path';
import moment from 'moment-hijri';
import WizardScene from './WizardScene/index.js';
import join_left from './module/join_left.js';
import EventText from './module/EventText.js';
import EventTextChannel from './module/EventTextChannel.js';
import command from './command/index.js';
import button from "./button/index.js";
import error_handling from './module/error_handling.js';
import scheduling_messages from './module/scheduling_messages.js';
import commandAdmin from './commandAdmin.js';
const __dirname = path.resolve();
async function teleAltaqwaa() {
// بداية npm
const pkg = await fs.readJson(path.join(__dirname, './package.json'));
console.log(`teleAltaqwaa v${pkg?.version} جاهز! ${moment().locale('en-EN').format('LT')}`)
// مجلد قاعدة البيانات
fs.existsSync(path.join(__dirname, './database')) ? true :
fs.mkdirSync(path.join(__dirname, './database'), { recursive: true });
const config = await fs.readJson(path.join(__dirname, './config.json'));
const options = { channelMode: true, voting: true };
const client = new Telegraf(config?.token_telegram, options);
const stage = new Scenes.Stage(WizardScene);
client.use(session());
client.use(stage.middleware());
// الأحداث
await commandAdmin(client, config);
await command(client, Markup, config);
await button(client, Markup);
await join_left(client);
await EventText(client);
await EventTextChannel(client);
// جدولة الرسائل
await scheduling_messages(client);
// ابدأ التطبيق
client.launch().catch(async (error) => {
await error_handling(error, client);
});
// تجاوز معالجة الأخطاء
client.catch(async (error) => {
await error_handling(error, client);
});
}
await teleAltaqwaa().catch(e => console.log(e));