2016-04-11 06:04:47 +02:00
|
|
|
local nick = {}
|
|
|
|
|
2016-06-07 06:31:34 +02:00
|
|
|
local utilities = require('otouto.utilities')
|
2016-04-11 06:04:47 +02:00
|
|
|
|
|
|
|
nick.command = 'nick <nickname>'
|
2015-08-18 11:55:25 +02:00
|
|
|
|
2016-05-27 05:28:44 +02:00
|
|
|
function nick:init(config)
|
|
|
|
nick.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('nick', true).table
|
2016-07-25 11:03:35 +02:00
|
|
|
nick.doc = config.cmd_pat .. [[nick <nickname>
|
|
|
|
Set your nickname. Use "]] .. config.cmd_pat .. 'nick --" to delete it.'
|
2016-04-11 06:04:47 +02:00
|
|
|
end
|
2015-08-18 11:55:25 +02:00
|
|
|
|
2016-05-27 02:26:30 +02:00
|
|
|
function nick:action(msg, config)
|
2015-08-18 11:55:25 +02:00
|
|
|
|
otouto 3.11
"things occurred"
Added some utilities (id_from_username, id_from_message), removed some utilities (latcyr, others?).
Removed cycle-wasting "shortcuts" -- no more automatic id_str or name; text_lower remains.
Moved userdata (nicknames, lastfm, etc) to a different tree in the database (automatic migration will occur). /me now returns userdata.
Speaking of migration, database now stores the latest version run to make future automigration easy.
Database now saves hourly rather than minutely.
Changed readme and some plugins to reflect above changes.
Removed broken rockspec (Brayden, feel free to re-add once it's working).
Added option to automatically block people (via drua) when blacklisted.
Fixed about.lua trigger problems.
administration 1.11 - Removed /kickme and /broadcast. Users should leave manually, and announcements should be made via channel rather than spam. /setqotd now handles forwarded messages correctly. /kick, /ban, /hammer,
/mod, /admin now support multiple arguments. Added get_targets function. No migration is necessary.
2016-07-05 09:29:11 +02:00
|
|
|
local id_str, name
|
2015-08-18 11:55:25 +02:00
|
|
|
|
2016-05-27 02:26:30 +02:00
|
|
|
if msg.from.id == config.admin and msg.reply_to_message then
|
otouto 3.11
"things occurred"
Added some utilities (id_from_username, id_from_message), removed some utilities (latcyr, others?).
Removed cycle-wasting "shortcuts" -- no more automatic id_str or name; text_lower remains.
Moved userdata (nicknames, lastfm, etc) to a different tree in the database (automatic migration will occur). /me now returns userdata.
Speaking of migration, database now stores the latest version run to make future automigration easy.
Database now saves hourly rather than minutely.
Changed readme and some plugins to reflect above changes.
Removed broken rockspec (Brayden, feel free to re-add once it's working).
Added option to automatically block people (via drua) when blacklisted.
Fixed about.lua trigger problems.
administration 1.11 - Removed /kickme and /broadcast. Users should leave manually, and announcements should be made via channel rather than spam. /setqotd now handles forwarded messages correctly. /kick, /ban, /hammer,
/mod, /admin now support multiple arguments. Added get_targets function. No migration is necessary.
2016-07-05 09:29:11 +02:00
|
|
|
id_str = tostring(msg.reply_to_message.from.id)
|
|
|
|
name = utilities.build_name(msg.reply_to_message.from.first_name, msg.reply_to_message.from.last_name)
|
|
|
|
else
|
|
|
|
id_str = tostring(msg.from.id)
|
|
|
|
name = utilities.build_name(msg.from.first_name, msg.from.last_name)
|
2015-08-29 08:15:01 +02:00
|
|
|
end
|
|
|
|
|
otouto 3.11
"things occurred"
Added some utilities (id_from_username, id_from_message), removed some utilities (latcyr, others?).
Removed cycle-wasting "shortcuts" -- no more automatic id_str or name; text_lower remains.
Moved userdata (nicknames, lastfm, etc) to a different tree in the database (automatic migration will occur). /me now returns userdata.
Speaking of migration, database now stores the latest version run to make future automigration easy.
Database now saves hourly rather than minutely.
Changed readme and some plugins to reflect above changes.
Removed broken rockspec (Brayden, feel free to re-add once it's working).
Added option to automatically block people (via drua) when blacklisted.
Fixed about.lua trigger problems.
administration 1.11 - Removed /kickme and /broadcast. Users should leave manually, and announcements should be made via channel rather than spam. /setqotd now handles forwarded messages correctly. /kick, /ban, /hammer,
/mod, /admin now support multiple arguments. Added get_targets function. No migration is necessary.
2016-07-05 09:29:11 +02:00
|
|
|
self.database.userdata[id_str] = self.database.userdata[id_str] or {}
|
|
|
|
|
2016-03-08 10:17:55 +01:00
|
|
|
local output
|
2016-04-08 23:12:02 +02:00
|
|
|
local input = utilities.input(msg.text)
|
2016-03-08 10:17:55 +01:00
|
|
|
if not input then
|
otouto 3.11
"things occurred"
Added some utilities (id_from_username, id_from_message), removed some utilities (latcyr, others?).
Removed cycle-wasting "shortcuts" -- no more automatic id_str or name; text_lower remains.
Moved userdata (nicknames, lastfm, etc) to a different tree in the database (automatic migration will occur). /me now returns userdata.
Speaking of migration, database now stores the latest version run to make future automigration easy.
Database now saves hourly rather than minutely.
Changed readme and some plugins to reflect above changes.
Removed broken rockspec (Brayden, feel free to re-add once it's working).
Added option to automatically block people (via drua) when blacklisted.
Fixed about.lua trigger problems.
administration 1.11 - Removed /kickme and /broadcast. Users should leave manually, and announcements should be made via channel rather than spam. /setqotd now handles forwarded messages correctly. /kick, /ban, /hammer,
/mod, /admin now support multiple arguments. Added get_targets function. No migration is necessary.
2016-07-05 09:29:11 +02:00
|
|
|
if self.database.userdata[id_str].nickname then
|
|
|
|
output = name .. '\'s nickname is "' .. self.database.userdata[id_str].nickname .. '".'
|
2016-03-08 10:17:55 +01:00
|
|
|
else
|
otouto 3.11
"things occurred"
Added some utilities (id_from_username, id_from_message), removed some utilities (latcyr, others?).
Removed cycle-wasting "shortcuts" -- no more automatic id_str or name; text_lower remains.
Moved userdata (nicknames, lastfm, etc) to a different tree in the database (automatic migration will occur). /me now returns userdata.
Speaking of migration, database now stores the latest version run to make future automigration easy.
Database now saves hourly rather than minutely.
Changed readme and some plugins to reflect above changes.
Removed broken rockspec (Brayden, feel free to re-add once it's working).
Added option to automatically block people (via drua) when blacklisted.
Fixed about.lua trigger problems.
administration 1.11 - Removed /kickme and /broadcast. Users should leave manually, and announcements should be made via channel rather than spam. /setqotd now handles forwarded messages correctly. /kick, /ban, /hammer,
/mod, /admin now support multiple arguments. Added get_targets function. No migration is necessary.
2016-07-05 09:29:11 +02:00
|
|
|
output = name .. ' currently has no nickname.'
|
2016-03-08 10:17:55 +01:00
|
|
|
end
|
2016-05-27 17:49:58 +02:00
|
|
|
elseif utilities.utf8_len(input) > 32 then
|
2016-03-08 10:17:55 +01:00
|
|
|
output = 'The character limit for nicknames is 32.'
|
2016-05-25 15:01:54 +02:00
|
|
|
elseif input == '--' or input == utilities.char.em_dash then
|
otouto 3.11
"things occurred"
Added some utilities (id_from_username, id_from_message), removed some utilities (latcyr, others?).
Removed cycle-wasting "shortcuts" -- no more automatic id_str or name; text_lower remains.
Moved userdata (nicknames, lastfm, etc) to a different tree in the database (automatic migration will occur). /me now returns userdata.
Speaking of migration, database now stores the latest version run to make future automigration easy.
Database now saves hourly rather than minutely.
Changed readme and some plugins to reflect above changes.
Removed broken rockspec (Brayden, feel free to re-add once it's working).
Added option to automatically block people (via drua) when blacklisted.
Fixed about.lua trigger problems.
administration 1.11 - Removed /kickme and /broadcast. Users should leave manually, and announcements should be made via channel rather than spam. /setqotd now handles forwarded messages correctly. /kick, /ban, /hammer,
/mod, /admin now support multiple arguments. Added get_targets function. No migration is necessary.
2016-07-05 09:29:11 +02:00
|
|
|
self.database.userdata[id_str].nickname = nil
|
|
|
|
output = name .. '\'s nickname has been deleted.'
|
2015-11-25 03:22:04 +01:00
|
|
|
else
|
2016-05-10 21:49:05 +02:00
|
|
|
input = input:gsub('\n', ' ')
|
otouto 3.11
"things occurred"
Added some utilities (id_from_username, id_from_message), removed some utilities (latcyr, others?).
Removed cycle-wasting "shortcuts" -- no more automatic id_str or name; text_lower remains.
Moved userdata (nicknames, lastfm, etc) to a different tree in the database (automatic migration will occur). /me now returns userdata.
Speaking of migration, database now stores the latest version run to make future automigration easy.
Database now saves hourly rather than minutely.
Changed readme and some plugins to reflect above changes.
Removed broken rockspec (Brayden, feel free to re-add once it's working).
Added option to automatically block people (via drua) when blacklisted.
Fixed about.lua trigger problems.
administration 1.11 - Removed /kickme and /broadcast. Users should leave manually, and announcements should be made via channel rather than spam. /setqotd now handles forwarded messages correctly. /kick, /ban, /hammer,
/mod, /admin now support multiple arguments. Added get_targets function. No migration is necessary.
2016-07-05 09:29:11 +02:00
|
|
|
self.database.userdata[id_str].nickname = input
|
|
|
|
output = name .. '\'s nickname has been set to "' .. input .. '".'
|
2015-11-25 03:22:04 +01:00
|
|
|
end
|
|
|
|
|
2016-05-29 19:08:39 +02:00
|
|
|
utilities.send_reply(self, msg, output)
|
2015-08-18 11:55:25 +02:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2016-04-11 06:04:47 +02:00
|
|
|
return nick
|