-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.js
59 lines (46 loc) · 1.29 KB
/
bot.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
const App = {}
// Start useful functions first
require(`./modules/utils.js`)(App)
if (process.argv.length < 3) {
App.log(`Provide the name of the config to use.`)
return
}
// The id/name of the bot instance
// This indicates what config file to use
App.name = process.argv[2]
App.log(`Starting: ${App.name}`)
// Imports go here
App.i = {}
App.i.fs = require(`fs`)
App.i.path = require(`path`)
App.i.process = require(`process`)
// A fork of node-irc that fixes a bunch of stuff
App.i.irc = require(`matrix-org-irc`)
// Official openai library
App.i.openai = require(`openai`)
App.context = {}
App.max_username_length = 25
App.last_autorespond = 0
App.config_keep = [`server`, `channels`, `port`, `nickname`, `admins`]
App.enabled = true
App.talk_count = 0
App.talked = false
App.talk_date = 0
App.talk_date_max = 1000 * 10
App.ask_charge = 0
App.max_ask_charge = 10
App.memory = {}
App.memory_timeout = 1000 * 60 * 60 * 24 * 1 // 1 Day
// Need to prepare config first
require(`./modules/config.js`)(App)
App.prepare_config()
// Load js modules
require(`./modules/irc.js`)(App)
require(`./modules/openai.js`)(App)
require(`./modules/proc.js`)(App)
require(`./modules/commands.js`)(App)
require(`./modules/spam.js`)(App)
App.start_antispam()
App.start_openai()
App.start_irc()
App.date_started = App.now()