various improvements
This commit is contained in:
parent
21f8e10147
commit
dfece989a0
20
README.md
20
README.md
@ -1,3 +1,19 @@
|
||||
# otouto
|
||||
A plugin-wielding Telegram bot using the new API.
|
||||
The latest version runs on @mokubot. v1 runs on @otouto.
|
||||
|
||||
The plugin-wielding, multi-purpose Telgram chat bot.
|
||||
|
||||
Public bot runs on [@mokubot](http://telegram.me/mokubot).
|
||||
|
||||
Requires lua-socket, lua-sec, and cjson or dkjson.
|
||||
|
||||
###Configuration
|
||||
|
||||
Most config.json entries are self-explanatory.
|
||||
|
||||
TIME_OFFSET is the time difference, in seconds, between your system clock. It is often necessary for accurate output of the time plugin.
|
||||
|
||||
"admins" table includes the ID numbers, as integers, of any privileged users. These will have access to the admin plugin and any addition privileged commands.
|
||||
|
||||
"people" table is for the personality plugin:
|
||||
`"123456789": "foobar"`
|
||||
ID number must be a string.
|
10
config.json
10
config.json
@ -1,9 +1,11 @@
|
||||
{
|
||||
"BOT_API_KEY": "",
|
||||
"ADMIN_ID": 0,
|
||||
"BIBLIA_API_KEY": "",
|
||||
"GIPHY_API_KEY": "",
|
||||
"TIME_OFFSET": 0,
|
||||
"admins": [
|
||||
0
|
||||
],
|
||||
"plugins": [
|
||||
"8ball.lua",
|
||||
"admin.lua",
|
||||
@ -27,6 +29,7 @@
|
||||
"imdb.lua",
|
||||
"personality.lua",
|
||||
"pokedex.lua",
|
||||
"pun.lua",
|
||||
"reddit.lua",
|
||||
"remind.lua",
|
||||
"shrug.lua",
|
||||
@ -36,6 +39,9 @@
|
||||
"weather.lua",
|
||||
"whoami.lua",
|
||||
"xkcd.lua"
|
||||
]
|
||||
],
|
||||
"people": {
|
||||
"0": "nickname",
|
||||
}
|
||||
}
|
||||
|
||||
|
20
plugin.lua
20
plugin.lua
@ -1,20 +0,0 @@
|
||||
local PLUGIN = {}
|
||||
|
||||
PLUGIN.doc = [[
|
||||
!example
|
||||
Info about the command.
|
||||
]]
|
||||
|
||||
PLUGIN.triggers = {
|
||||
'^!example',
|
||||
'^!e$'
|
||||
}
|
||||
|
||||
function PLUGIN.action(msg)
|
||||
|
||||
local message = 'Example output.'
|
||||
send_msg(msg, message)
|
||||
|
||||
end
|
||||
|
||||
return PLUGIN
|
@ -10,7 +10,14 @@ function PLUGIN.action(msg)
|
||||
|
||||
local message = 'Command not found.'
|
||||
|
||||
if msg.from.id ~= config.ADMIN_ID then
|
||||
local sudo = 0
|
||||
for i,v in ipairs(config.admins) do
|
||||
if msg.from.id == v then
|
||||
sudo = v
|
||||
end
|
||||
end
|
||||
|
||||
if sudo == 0 then
|
||||
message = 'Permission denied.'
|
||||
|
||||
elseif string.lower(first_word(input)) == 'run' then
|
||||
|
@ -25,14 +25,24 @@ function PLUGIN.action(msg)
|
||||
jdat.res = "I don't know what to say to that."
|
||||
end
|
||||
|
||||
local message = jdat.res
|
||||
|
||||
-- Let's clean up the response a little. Capitalization & punctuation.
|
||||
local message = jdat.res:gsub('simsimi', 'clive')
|
||||
local message = message:gsub("^%l", string.upper)
|
||||
filter = {
|
||||
['%aim%aimi'] = bot.first_name,
|
||||
['^%s*(.-)%s*$'] = '%1',
|
||||
['^%l'] = string.upper
|
||||
}
|
||||
|
||||
for k,v in pairs(filter) do
|
||||
message = string.gsub(message, k, v)
|
||||
end
|
||||
|
||||
if not string.match(message, '%p$') then
|
||||
message = message .. '.'
|
||||
end
|
||||
|
||||
send_message(msg.chat.id, jdat.res)
|
||||
send_message(msg.chat.id, message)
|
||||
|
||||
end
|
||||
|
||||
|
@ -13,6 +13,8 @@ PLUGIN.triggers = {
|
||||
|
||||
function PLUGIN.action(msg)
|
||||
|
||||
if string.find(msg.text, '@') and not string.match('help@'..bot.username) then return end
|
||||
|
||||
local input = get_input(msg.text)
|
||||
|
||||
if input then
|
||||
@ -29,6 +31,7 @@ function PLUGIN.action(msg)
|
||||
*Arguments: <required> [optional]
|
||||
Use "!help <command>" for specific information.
|
||||
otouto v]] .. VERSION .. [[ by @topkecleon.
|
||||
Fork me on github! github.com/topkecleon/otouto
|
||||
]]
|
||||
|
||||
if msg.from.id ~= msg.chat.id then
|
||||
|
@ -1,7 +1,12 @@
|
||||
-- config.people is a table of IDs/nicknames the bot can address more familiarly
|
||||
-- like so:
|
||||
-- 13227902: "Drew"
|
||||
|
||||
|
||||
local PLUGIN = {}
|
||||
|
||||
PLUGIN.triggers = {
|
||||
'otouto%p?$',
|
||||
bot.first_name .. '%p?$',
|
||||
'^tadaima%p?$',
|
||||
'^i\'m home%p?$',
|
||||
'^i\'m back%p?$'
|
||||
@ -11,25 +16,27 @@ function PLUGIN.action(msg) -- I WISH LUA HAD PROPER REGEX SUPPORT
|
||||
|
||||
local input = string.lower(msg.text)
|
||||
|
||||
if config.people[tostring(msg.from.id)] then msg.from.first_name = config.people[tostring(msg.from.id)] end
|
||||
|
||||
for i = 2, #PLUGIN.triggers do
|
||||
if string.match(input, PLUGIN.triggers[i]) then
|
||||
return send_message(msg.chat.id, 'Welcome back, ' .. msg.from.first_name .. '!')
|
||||
end
|
||||
end
|
||||
|
||||
if input:match('thanks,? otouto') or input:match('thank you,? otouto') then
|
||||
if input:match('thanks,? '..bot.first_name) or input:match('thank you,? '..bot.first_name) then
|
||||
return send_message(msg.chat.id, 'No problem, ' .. msg.from.first_name .. '!')
|
||||
end
|
||||
|
||||
if input:match('hello,? otouto') or input:match('hey,? otouto') or input:match('hi,? otouto') then
|
||||
if input:match('hello,? '..bot.first_name) or input:match('hey,? '..bot.first_name) or input:match('hi,? '..bot.first_name) then
|
||||
return send_message(msg.chat.id, 'Hi, ' .. msg.from.first_name .. '!')
|
||||
end
|
||||
|
||||
if input:match('i hate you,? otouto') or input:match('screw you,? otouto') or input:match('fuck you,? otouto') then
|
||||
if input:match('i hate you,? '..bot.first_name) or input:match('screw you,? '..bot.first_name) or input:match('fuck you,? '..bot.first_name) then
|
||||
return send_msg(msg, '; _ ;')
|
||||
end
|
||||
|
||||
if string.match(input, 'i love you,? otouto') then
|
||||
if string.match(input, 'i love you,? '..bot.first_name) then
|
||||
return send_msg(msg, '<3')
|
||||
end
|
||||
|
||||
|
@ -105,7 +105,7 @@ function PLUGIN.action(msg)
|
||||
slapper = msg.from.first_name
|
||||
else
|
||||
victim = msg.from.first_name
|
||||
slapper = bot.username
|
||||
slapper = bot.first_name
|
||||
end
|
||||
|
||||
local message = PLUGIN.getSlap(slapper, victim)
|
||||
|
@ -1,3 +1,5 @@
|
||||
-- TIME_OFFSET is the number of seconds necessary to correct your system clock to UTC.
|
||||
|
||||
local PLUGIN = {}
|
||||
|
||||
PLUGIN.doc = [[
|
||||
|
Reference in New Issue
Block a user