Merge branch 'master' of github.com:yagop/telegram-bot
This commit is contained in:
39
bot/bot.lua
39
bot/bot.lua
@ -4,8 +4,6 @@
|
||||
-- lrexlib = require("rex_pcre")
|
||||
|
||||
VERSION = 'v0.6'
|
||||
|
||||
plugins = {}
|
||||
|
||||
-- taken from http://stackoverflow.com/a/11130774/3163199
|
||||
function scandir(directory)
|
||||
@ -16,16 +14,7 @@
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
-- load all plugins in the plugins/ directory
|
||||
for k, v in pairs(scandir("plugins")) do
|
||||
if not (v:sub(0, 1) == ".") then
|
||||
print("Loading plugin", v)
|
||||
t = loadfile("plugins/" .. v)()
|
||||
table.insert(plugins, t)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function on_msg_receive (msg)
|
||||
if msg_valid(msg) == false then
|
||||
return
|
||||
@ -273,11 +262,6 @@
|
||||
end
|
||||
end
|
||||
|
||||
-- Start and load values
|
||||
config = load_config()
|
||||
our_id = 0
|
||||
now = os.time()
|
||||
|
||||
function get_receiver(msg)
|
||||
if msg.to.type == 'user' then
|
||||
return 'user#id'..msg.from.id
|
||||
@ -287,7 +271,6 @@
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function on_our_id (id)
|
||||
our_id = id
|
||||
end
|
||||
@ -310,3 +293,23 @@
|
||||
function on_binlog_replay_end ()
|
||||
started = 1
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Start and load values
|
||||
config = load_config()
|
||||
our_id = 0
|
||||
now = os.time()
|
||||
|
||||
-- load plugins
|
||||
plugins = {}
|
||||
|
||||
-- load all plugins in the plugins/ directory
|
||||
for k, v in pairs(scandir("plugins")) do
|
||||
if not (v:sub(0, 1) == ".") then
|
||||
print("Loading plugin", v)
|
||||
t = loadfile("plugins/" .. v)()
|
||||
table.insert(plugins, t)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -2,5 +2,11 @@
|
||||
"log_file": "/var/www/html/log.txt",
|
||||
"sh_enabled": false,
|
||||
"sudo_users": [ 0, 1 ],
|
||||
"values": { }
|
||||
}
|
||||
"values": { },
|
||||
"twitter": {
|
||||
"consumer_key" : "",
|
||||
"consumer_secret" : "",
|
||||
"access_token" : "",
|
||||
"access_token_secret" : ""
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user