2016-02-23 12:15:48 +01:00
--[[
administration.lua
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
Version 1.11
2016-02-23 12:15:48 +01:00
Part of the otouto project .
© 2016 topkecleon < drew @ otou.to >
GNU General Public License , version 2
This plugin provides self - hosted , single - realm group administration .
It requires tg ( http : // github.com / vysheng / tg ) with supergroup support .
2016-05-25 15:01:54 +02:00
For more documentation , read the the manual ( otou.to / rtfm ) .
2016-02-23 12:15:48 +01:00
Remember to load this before blacklist.lua .
2016-02-25 10:42:13 +01:00
2016-03-04 23:08:21 +01:00
Important notices about updates will be here !
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
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-06-19 10:36:33 +02:00
2016-07-25 11:03:35 +02:00
1.11 .1 - Bugfixes . / hammer can now be used in PM .
] ]
2016-02-23 12:15:48 +01:00
2016-04-15 21:07:23 +02:00
local JSON = require ( ' dkjson ' )
2016-07-25 11:03:35 +02:00
local drua = require ( ' otouto.drua-tg ' )
2016-06-07 06:31:34 +02:00
local bindings = require ( ' otouto.bindings ' )
local utilities = require ( ' otouto.utilities ' )
2016-04-08 23:12:02 +02:00
local administration = { }
2016-05-27 02:26:30 +02:00
function administration : init ( config )
2016-04-08 23:12:02 +02:00
-- Build the administration db if nonexistent.
if not self.database . administration then
self.database . administration = {
admins = { } ,
groups = { } ,
2016-05-19 08:34:24 +02:00
activity = { } ,
autokick_timer = os.date ( ' %d ' )
2016-04-08 23:12:02 +02:00
}
end
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
self.admin_temp = {
help = { } ,
flood = { }
}
2016-03-31 13:53:12 +02:00
2016-05-27 02:26:30 +02:00
drua.PORT = config.cli_port or 4567
2016-04-08 23:12:02 +02:00
2016-06-07 08:22:01 +02:00
administration.flags = administration.init_flags ( config.cmd_pat )
2016-05-27 02:26:30 +02:00
administration.init_command ( self , config )
2016-02-20 11:07:20 +01:00
2016-07-25 11:03:35 +02:00
administration.doc = ' Returns a list of administrated groups. \n Use ' .. config.cmd_pat .. ' ahelp for more administrative commands. '
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
administration.command = ' groups [query] '
2016-05-27 05:28:44 +02:00
2016-06-14 23:57:36 +02:00
-- In the worst case, don't send errors in reply to random messages.
administration.error = false
2016-04-08 23:12:02 +02:00
end
2016-05-27 05:28:44 +02:00
function administration . init_flags ( cmd_pat ) return {
2016-02-20 11:07:20 +01:00
[ 1 ] = {
name = ' unlisted ' ,
desc = ' Removes this group from the group listing. ' ,
2016-02-25 10:42:13 +01:00
short = ' This group is unlisted. ' ,
2016-05-27 05:28:44 +02:00
enabled = ' This group is no longer listed in ' .. cmd_pat .. ' groups. ' ,
disabled = ' This group is now listed in ' .. cmd_pat .. ' groups. '
2016-02-20 11:07:20 +01:00
} ,
[ 2 ] = {
name = ' antisquig ' ,
desc = ' Automatically removes users who post Arabic script or RTL characters. ' ,
2016-02-25 10:42:13 +01:00
short = ' This group does not allow Arabic script or RTL characters. ' ,
2016-02-20 11:07:20 +01:00
enabled = ' Users will now be removed automatically for posting Arabic script and/or RTL characters. ' ,
2016-05-26 13:22:20 +02:00
disabled = ' Users will no longer be removed automatically for posting Arabic script and/or RTL characters. ' ,
2016-02-25 10:42:13 +01:00
kicked = ' You were automatically kicked from GROUPNAME for posting Arabic script and/or RTL characters. '
2016-02-20 11:07:20 +01:00
} ,
[ 3 ] = {
2016-03-31 13:53:12 +02:00
name = ' antisquig++ ' ,
2016-02-20 11:07:20 +01:00
desc = ' Automatically removes users whose names contain Arabic script or RTL characters. ' ,
2016-02-25 10:42:13 +01:00
short = ' This group does not allow users whose names contain Arabic script or RTL characters. ' ,
2016-02-20 11:07:20 +01:00
enabled = ' Users whose names contain Arabic script and/or RTL characters will now be removed automatically. ' ,
disabled = ' Users whose names contain Arabic script and/or RTL characters will no longer be removed automatically. ' ,
2016-02-25 10:42:13 +01:00
kicked = ' You were automatically kicked from GROUPNAME for having a name which contains Arabic script and/or RTL characters. '
2016-02-20 11:07:20 +01:00
} ,
[ 4 ] = {
name = ' antibot ' ,
2016-03-22 11:16:26 +01:00
desc = ' Prevents the addition of bots by non-moderators. ' ,
2016-02-25 10:42:13 +01:00
short = ' This group does not allow users to add bots. ' ,
2016-02-20 11:07:20 +01:00
enabled = ' Non-moderators will no longer be able to add bots. ' ,
disabled = ' Non-moderators will now be able to add bots. '
2016-03-31 13:53:12 +02:00
} ,
[ 5 ] = {
name = ' antiflood ' ,
desc = ' Prevents flooding by rate-limiting messages per user. ' ,
short = ' This group automatically removes users who flood. ' ,
2016-05-27 05:28:44 +02:00
enabled = ' Users will now be removed automatically for excessive messages. Use ' .. cmd_pat .. ' antiflood to configure limits. ' ,
2016-03-31 13:53:12 +02:00
disabled = ' Users will no longer be removed automatically for excessive messages. ' ,
kicked = ' You were automatically kicked from GROUPNAME for flooding. '
2016-05-19 08:34:24 +02:00
} ,
[ 6 ] = {
name = ' antihammer ' ,
2016-05-29 19:08:39 +02:00
desc = ' Allows globally banned users to enter this group. Note that users hammered in this group will also be banned locally. ' ,
2016-05-19 08:34:24 +02:00
short = ' This group does not acknowledge global bans. ' ,
enabled = ' This group will no longer remove users for being globally banned. ' ,
disabled = ' This group will now remove users for being globally banned. '
2016-02-20 11:07:20 +01:00
}
2016-05-27 05:28:44 +02:00
} end
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
administration.antiflood = {
2016-06-17 07:13:05 +02:00
text = 5 ,
voice = 5 ,
audio = 5 ,
contact = 5 ,
photo = 10 ,
video = 10 ,
location = 10 ,
document = 10 ,
sticker = 20
2016-03-31 13:53:12 +02:00
}
2016-04-08 23:12:02 +02:00
administration.ranks = {
2016-02-20 11:07:20 +01:00
[ 0 ] = ' Banned ' ,
[ 1 ] = ' Users ' ,
[ 2 ] = ' Moderators ' ,
[ 3 ] = ' Governors ' ,
[ 4 ] = ' Administrators ' ,
[ 5 ] = ' Owner '
}
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
function administration : get_rank ( user_id_str , chat_id_str , config )
2016-02-20 11:07:20 +01: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
user_id_str = tostring ( user_id_str )
local user_id = tonumber ( user_id_str )
chat_id_str = tostring ( chat_id_str )
2016-02-20 11:07:20 +01: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
-- Return 5 if the user_id_str is the bot or its owner.
if user_id == config.admin or user_id == self.info . id then
2016-02-20 11:07:20 +01:00
return 5
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
-- Return 4 if the user_id_str is an administrator.
if self.database . administration.admins [ user_id_str ] then
2016-02-20 11:07:20 +01:00
return 4
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
if chat_id_str and self.database . administration.groups [ chat_id_str ] then
-- Return 3 if the user_id_str is the governor of the chat_id_str.
if self.database . administration.groups [ chat_id_str ] . governor == user_id then
2016-02-20 11:07:20 +01:00
return 3
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
-- Return 2 if the user_id_str is a moderator of the chat_id_str.
elseif self.database . administration.groups [ chat_id_str ] . mods [ user_id_str ] then
2016-02-20 11:07:20 +01:00
return 2
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
-- Return 0 if the user_id_str is banned from the chat_id_str.
elseif self.database . administration.groups [ chat_id_str ] . bans [ user_id_str ] then
2016-02-20 11:07:20 +01:00
return 0
2016-05-25 15:01:54 +02:00
-- Return 1 if antihammer is enabled.
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
elseif self.database . administration.groups [ chat_id_str ] . flags [ 6 ] then
2016-05-25 15:01:54 +02:00
return 1
2016-02-20 11:07:20 +01:00
end
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
-- Return 0 if the user_id_str is blacklisted (and antihammer is not enabled).
if self.database . blacklist [ user_id_str ] then
2016-05-25 15:01:54 +02:00
return 0
2016-02-20 11:07:20 +01: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
-- Return 1 if the user_id_str is a regular user.
2016-02-20 11:07:20 +01:00
return 1
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
-- Returns an array of "user" tables.
function administration : get_targets ( msg , config )
if msg.reply_to_message then
local target = { }
for k , v in pairs ( msg.reply_to_message . from ) do
target [ k ] = v
end
target.name = utilities.build_name ( target.first_name , target.last_name )
target.id_str = tostring ( target.id )
target.rank = administration.get_rank ( self , target.id , msg.chat . id , config )
return { target }
else
local input = utilities.input ( msg.text )
if input then
local t = { }
for _ , user in ipairs ( utilities.index ( input ) ) do
if self.database . users [ user ] then
local target = { }
for k , v in pairs ( self.database . users [ user ] ) do
target [ k ] = v
end
target.name = utilities.build_name ( target.first_name , target.last_name )
target.id_str = tostring ( target.id )
target.rank = administration.get_rank ( self , target.id , msg.chat . id , config )
table.insert ( t , target )
elseif tonumber ( user ) then
local target = {
id = tonumber ( user ) ,
id_str = user ,
name = ' Unknown ( ' .. user .. ' ) ' ,
rank = administration.get_rank ( self , user , msg.chat . id , config )
}
table.insert ( t , target )
elseif user : match ( ' ^@ ' ) then
local target = utilities.resolve_username ( self , user )
if target then
target.rank = administration.get_rank ( self , target.id , msg.chat . id , config )
target.id_str = tostring ( target.id )
target.name = utilities.build_name ( target.first_name , target.last_name )
table.insert ( t , target )
else
table.insert ( t , { err = ' Sorry, I do not recognize that username ( ' .. user .. ' ). ' } )
end
else
table.insert ( t , { err = ' Invalid username or ID ( ' .. user .. ' ). ' } )
end
end
return t
else
return false
end
2016-02-20 11:07:20 +01:00
end
end
2016-04-08 23:12:02 +02:00
function administration : mod_format ( id )
2016-03-28 08:15:46 +02:00
id = tostring ( id )
2016-04-08 23:12:02 +02:00
local user = self.database . users [ id ] or { first_name = ' Unknown ' }
local name = utilities.build_name ( user.first_name , user.last_name )
name = utilities.markdown_escape ( name )
2016-03-28 08:15:46 +02:00
local output = ' • ' .. name .. ' `[ ' .. id .. ' ]` \n '
2016-05-19 08:42:11 +02:00
return output
2016-03-28 08:15:46 +02:00
end
2016-05-27 05:28:44 +02:00
function administration : get_desc ( chat_id , config )
2016-02-23 12:15:48 +01:00
2016-04-08 23:12:02 +02:00
local group = self.database . administration.groups [ tostring ( chat_id ) ]
2016-03-28 08:15:46 +02:00
local t = { }
2016-02-23 12:15:48 +01:00
if group.link then
2016-03-28 08:15:46 +02:00
table.insert ( t , ' *Welcome to* [ ' .. group.name .. ' ]( ' .. group.link .. ' )*!* ' )
2016-02-23 12:15:48 +01:00
else
2016-05-25 15:01:54 +02:00
table.insert ( t , ' *Welcome to ' .. group.name .. ' !* ' )
2016-02-23 12:15:48 +01:00
end
if group.motd then
2016-03-28 08:15:46 +02:00
table.insert ( t , ' *Message of the Day:* \n ' .. group.motd )
2016-02-23 12:15:48 +01:00
end
2016-03-22 11:16:26 +01:00
if # group.rules > 0 then
2016-03-28 08:15:46 +02:00
local rulelist = ' *Rules:* \n '
2016-05-25 15:01:54 +02:00
for i = 1 , # group.rules do
rulelist = rulelist .. ' * ' .. i .. ' .* ' .. group.rules [ i ] .. ' \n '
2016-02-25 10:42:13 +01:00
end
2016-04-15 21:07:23 +02:00
table.insert ( t , utilities.trim ( rulelist ) )
2016-02-25 10:42:13 +01:00
end
2016-03-28 08:15:46 +02:00
local flaglist = ' '
2016-04-08 23:12:02 +02:00
for i = 1 , # administration.flags do
2016-03-28 08:15:46 +02:00
if group.flags [ i ] then
2016-04-08 23:12:02 +02:00
flaglist = flaglist .. ' • ' .. administration.flags [ i ] . short .. ' \n '
2016-02-25 10:42:13 +01:00
end
2016-02-23 12:15:48 +01:00
end
2016-03-28 08:15:46 +02:00
if flaglist ~= ' ' then
2016-04-15 21:07:23 +02:00
table.insert ( t , ' *Flags:* \n ' .. utilities.trim ( flaglist ) )
2016-03-28 08:15:46 +02:00
end
2016-04-05 09:42:16 +02:00
if group.governor then
2016-04-08 23:12:02 +02:00
local gov = self.database . users [ tostring ( group.governor ) ]
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 s
if gov then
s = utilities.md_escape ( utilities.build_name ( gov.first_name , gov.last_name ) ) .. ' `[ ' .. gov.id .. ' ]` '
else
s = ' Unknown `[ ' .. group.governor .. ' ]` '
end
2016-04-05 09:42:16 +02:00
table.insert ( t , ' *Governor:* ' .. s )
end
2016-03-28 08:15:46 +02:00
local modstring = ' '
2016-04-08 23:12:02 +02:00
for k , _ in pairs ( group.mods ) do
modstring = modstring .. administration.mod_format ( self , k )
2016-03-28 08:15:46 +02:00
end
if modstring ~= ' ' then
2016-04-15 21:07:23 +02:00
table.insert ( t , ' *Moderators:* \n ' .. utilities.trim ( modstring ) )
2016-03-28 08:15:46 +02:00
end
2016-06-07 08:22:01 +02:00
table.insert ( t , ' Run ' .. config.cmd_pat .. ' ahelp@ ' .. self.info . username .. ' for a list of commands. ' )
2016-04-05 09:42:16 +02:00
return table.concat ( t , ' \n \n ' )
end
2016-05-27 05:28:44 +02:00
function administration : update_desc ( chat , config )
2016-04-08 23:12:02 +02:00
local group = self.database . administration.groups [ tostring ( chat ) ]
2016-04-05 09:42:16 +02:00
local desc = ' Welcome to ' .. group.name .. ' ! \n '
if group.motd then desc = desc .. group.motd .. ' \n ' end
2016-04-01 19:29:00 +02:00
if group.governor then
2016-04-08 23:12:02 +02:00
local gov = self.database . users [ tostring ( group.governor ) ]
desc = desc .. ' \n Governor: ' .. utilities.build_name ( gov.first_name , gov.last_name ) .. ' [ ' .. gov.id .. ' ] \n '
2016-03-28 08:15:46 +02:00
end
2016-05-27 05:28:44 +02:00
local s = ' \n ' .. config.cmd_pat .. ' desc@ ' .. self.info . username .. ' for more information. '
2016-04-05 09:42:16 +02:00
desc = desc : sub ( 1 , 250 - s : len ( ) ) .. s
drua.channel_set_about ( chat , desc )
2016-02-23 12:15:48 +01:00
end
2016-05-27 02:26:30 +02:00
function administration : kick_user ( chat , target , reason , config )
2016-05-21 02:47:13 +02:00
drua.kick_user ( chat , target )
2016-05-26 13:22:20 +02:00
local victim = target
if self.database . users [ tostring ( target ) ] then
victim = utilities.build_name (
2016-06-14 23:57:36 +02:00
self.database . users [ tostring ( target ) ] . first_name ,
self.database . users [ tostring ( target ) ] . last_name
) .. ' [ ' .. victim .. ' ] '
2016-05-26 13:22:20 +02:00
end
local group = self.database . administration.groups [ tostring ( chat ) ] . name
2016-05-27 02:26:30 +02:00
utilities.handle_exception ( self , victim .. ' kicked from ' .. group , reason , config )
2016-05-19 08:34:24 +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
function administration . init_command ( self_ , config_ )
2016-04-08 23:12:02 +02:00
administration.commands = {
2016-02-20 11:07:20 +01:00
2016-05-19 08:34:24 +02:00
{ -- generic, mostly autokicks
2016-04-08 23:12:02 +02:00
triggers = { ' ' } ,
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
privilege = 0 ,
interior = true ,
2016-02-20 11:07:20 +01:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-02-20 11:07:20 +01:00
2016-05-27 02:26:30 +02:00
local rank = administration.get_rank ( self , msg.from . id , msg.chat . id , config )
2016-05-26 13:22:20 +02:00
local user = { }
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 from_id_str = tostring ( msg.from . id )
local chat_id_str = tostring ( msg.chat . id )
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
if rank < 2 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
local from_name = utilities.build_name ( msg.from . first_name , msg.from . last_name )
2016-02-20 11:07:20 +01:00
2016-05-19 08:34:24 +02:00
-- banned
if rank == 0 then
user.do_kick = true
2016-05-26 13:22:20 +02:00
user.dont_unban = true
2016-05-19 08:34:24 +02:00
user.reason = ' banned '
user.output = ' Sorry, you are banned from ' .. msg.chat . title .. ' . '
2016-05-22 22:08:45 +02:00
elseif group.flags [ 2 ] and ( -- antisquig
2016-05-20 09:34:52 +02:00
msg.text : match ( utilities.char . arabic )
2016-05-22 22:08:45 +02:00
or msg.text : match ( utilities.char . rtl_override )
or msg.text : match ( utilities.char . rtl_mark )
2016-05-19 08:34:24 +02:00
) then
user.do_kick = true
user.reason = ' antisquig '
user.output = administration.flags [ 2 ] . kicked : gsub ( ' GROUPNAME ' , msg.chat . title )
2016-05-22 22:08:45 +02:00
elseif group.flags [ 3 ] and ( -- antisquig++
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
from_name : match ( utilities.char . arabic )
or from_name : match ( utilities.char . rtl_override )
or from_name : match ( utilities.char . rtl_mark )
2016-05-19 08:34:24 +02:00
) then
user.do_kick = true
user.reason = ' antisquig++ '
user.output = administration.flags [ 3 ] . kicked : gsub ( ' GROUPNAME ' , msg.chat . title )
2016-02-20 11:07:20 +01:00
end
2016-04-08 23:12:02 +02:00
-- antiflood
2016-05-19 08:34:24 +02:00
if group.flags [ 5 ] then
2016-04-08 23:12:02 +02:00
if not group.antiflood then
group.antiflood = JSON.decode ( JSON.encode ( administration.antiflood ) )
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
if not self.admin_temp . flood [ chat_id_str ] then
self.admin_temp . flood [ chat_id_str ] = { }
2016-04-08 23:12:02 +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
if not self.admin_temp . flood [ chat_id_str ] [ from_id_str ] then
self.admin_temp . flood [ chat_id_str ] [ from_id_str ] = 0
2016-04-08 23:12:02 +02:00
end
if msg.sticker then -- Thanks Brazil for discarding switches.
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.admin_temp . flood [ chat_id_str ] [ from_id_str ] = self.admin_temp . flood [ chat_id_str ] [ from_id_str ] + group.antiflood . sticker
2016-04-08 23:12:02 +02:00
elseif msg.photo 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.admin_temp . flood [ chat_id_str ] [ from_id_str ] = self.admin_temp . flood [ chat_id_str ] [ from_id_str ] + group.antiflood . photo
2016-04-08 23:12:02 +02:00
elseif msg.document 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.admin_temp . flood [ chat_id_str ] [ from_id_str ] = self.admin_temp . flood [ chat_id_str ] [ from_id_str ] + group.antiflood . document
2016-04-08 23:12:02 +02:00
elseif msg.audio 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.admin_temp . flood [ chat_id_str ] [ from_id_str ] = self.admin_temp . flood [ chat_id_str ] [ from_id_str ] + group.antiflood . audio
2016-04-08 23:12:02 +02:00
elseif msg.contact 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.admin_temp . flood [ chat_id_str ] [ from_id_str ] = self.admin_temp . flood [ chat_id_str ] [ from_id_str ] + group.antiflood . contact
2016-04-08 23:12:02 +02:00
elseif msg.video 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.admin_temp . flood [ chat_id_str ] [ from_id_str ] = self.admin_temp . flood [ chat_id_str ] [ from_id_str ] + group.antiflood . video
2016-04-08 23:12:02 +02:00
elseif msg.location 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.admin_temp . flood [ chat_id_str ] [ from_id_str ] = self.admin_temp . flood [ chat_id_str ] [ from_id_str ] + group.antiflood . location
2016-04-08 23:12:02 +02:00
elseif msg.voice 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.admin_temp . flood [ chat_id_str ] [ from_id_str ] = self.admin_temp . flood [ chat_id_str ] [ from_id_str ] + group.antiflood . voice
2016-04-08 23:12:02 +02: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
self.admin_temp . flood [ chat_id_str ] [ from_id_str ] = self.admin_temp . flood [ chat_id_str ] [ from_id_str ] + group.antiflood . text
2016-04-08 23:12:02 +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
if self.admin_temp . flood [ chat_id_str ] [ from_id_str ] > 99 then
2016-05-19 08:34:24 +02:00
user.do_kick = true
user.reason = ' antiflood '
user.output = administration.flags [ 5 ] . kicked : gsub ( ' GROUPNAME ' , msg.chat . title )
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.admin_temp . flood [ chat_id_str ] [ from_id_str ] = nil
2016-04-08 23:12:02 +02:00
end
2016-03-31 13:53:12 +02:00
end
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
end
2016-02-20 11:07:20 +01:00
2016-05-19 08:34:24 +02:00
local new_user = user
2016-05-31 01:10:58 +02:00
local new_rank = rank
2016-02-20 11:07:20 +01: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
if msg.new_chat_member then
2016-02-20 11:07:20 +01:00
2016-05-31 01:10:58 +02:00
-- I hate typing this out.
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 noob = msg.new_chat_member
local noob_name = utilities.build_name ( noob.first_name , noob.last_name )
2016-05-31 01:10:58 +02:00
2016-05-19 08:34:24 +02:00
-- We'll make a new table for the new guy, unless he's also
-- the original guy.
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 msg.new_chat_member . id ~= msg.from . id then
2016-05-26 13:22:20 +02:00
new_user = { }
2016-05-27 02:26:30 +02:00
new_rank = administration.get_rank ( self , noob.id , msg.chat . id , config )
2016-02-20 11:07:20 +01:00
end
2016-05-31 01:10:58 +02:00
if new_rank == 0 then
new_user.do_kick = true
new_user.dont_unban = true
new_user.reason = ' banned '
new_user.output = ' Sorry, you are banned from ' .. msg.chat . title .. ' . '
elseif new_rank == 1 then
if group.flags [ 3 ] and ( -- antisquig++
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
noob_name : match ( utilities.char . arabic )
or noob_name : match ( utilities.char . rtl_override )
or noob_name : match ( utilities.char . rtl_mark )
2016-05-19 08:34:24 +02:00
) then
new_user.do_kick = true
new_user.reason = ' antisquig++ '
new_user.output = administration.flags [ 3 ] . kicked : gsub ( ' GROUPNAME ' , msg.chat . title )
2016-05-31 01:10:58 +02:00
elseif ( -- antibot
group.flags [ 4 ]
and noob.username
2016-05-31 03:06:33 +02:00
and noob.username : match ( ' bot$ ' )
2016-05-31 01:10:58 +02:00
and rank < 2
) then
2016-05-19 08:34:24 +02:00
new_user.do_kick = true
new_user.reason = ' antibot '
end
2016-05-31 01:10:58 +02:00
else
-- Make the new user a group admin if he's a mod or higher.
if msg.chat . type == ' supergroup ' 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
drua.channel_set_admin ( msg.chat . id , msg.new_chat_member . id , 2 )
2016-05-31 01:10:58 +02:00
end
2016-02-20 11:07:20 +01:00
end
2016-04-08 23:12:02 +02:00
elseif msg.new_chat_title then
if rank < 3 then
drua.rename_chat ( msg.chat . id , group.name )
else
group.name = msg.new_chat_title
if group.grouptype == ' supergroup ' then
2016-05-27 05:28:44 +02:00
administration.update_desc ( self , msg.chat . id , config )
2016-04-08 23:12:02 +02:00
end
2016-04-05 09:42:16 +02:00
end
2016-04-08 23:12:02 +02:00
elseif msg.new_chat_photo then
if group.grouptype == ' group ' then
if rank < 3 then
drua.set_photo ( msg.chat . id , group.photo )
else
group.photo = drua.get_photo ( msg.chat . id )
end
2016-02-20 11:07:20 +01:00
else
2016-03-27 14:30:41 +02:00
group.photo = drua.get_photo ( msg.chat . id )
2016-02-20 11:07:20 +01:00
end
2016-04-08 23:12:02 +02:00
elseif msg.delete_chat_photo then
if group.grouptype == ' group ' then
if rank < 3 then
drua.set_photo ( msg.chat . id , group.photo )
else
group.photo = nil
end
2016-02-20 11:07:20 +01:00
else
group.photo = nil
end
2016-05-19 08:34:24 +02:00
end
2016-05-22 22:08:45 +02:00
if new_user ~= user and new_user.do_kick 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
administration.kick_user ( self , msg.chat . id , msg.new_chat_member . id , new_user.reason , config )
2016-05-22 22:08:45 +02:00
if new_user.output 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
utilities.send_message ( self , msg.new_chat_member . id , new_user.output )
2016-05-22 22:08:45 +02:00
end
2016-05-26 13:22:20 +02:00
if not new_user.dont_unban and msg.chat . type == ' supergroup ' then
2016-05-29 19:08:39 +02:00
bindings.unbanChatMember ( self , { chat_id = msg.chat . id , user_id = msg.from . id } )
2016-05-19 08:34:24 +02:00
end
end
2016-05-26 13:22:20 +02:00
if group.flags [ 5 ] and user.do_kick and not user.dont_unban 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 group.autokicks [ from_id_str ] then
group.autokicks [ from_id_str ] = group.autokicks [ from_id_str ] + 1
2016-05-19 08:34:24 +02: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
group.autokicks [ from_id_str ] = 1
2016-05-19 08:34:24 +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
if group.autokicks [ from_id_str ] >= group.autoban then
group.autokicks [ from_id_str ] = 0
group.bans [ from_id_str ] = true
2016-05-26 13:22:20 +02:00
user.dont_unban = true
2016-05-20 09:34:52 +02:00
user.reason = ' antiflood autoban: ' .. user.reason
2016-05-22 22:08:45 +02:00
user.output = user.output .. ' \n You have been banned for being autokicked too many times. '
2016-05-19 08:34:24 +02:00
end
end
2016-05-26 13:22:20 +02:00
if user.do_kick then
2016-05-27 02:26:30 +02:00
administration.kick_user ( self , msg.chat . id , msg.from . id , user.reason , config )
2016-05-19 08:34:24 +02:00
if user.output then
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.from . id , user.output )
2016-05-19 08:34:24 +02:00
end
2016-05-26 13:22:20 +02:00
if not user.dont_unban and msg.chat . type == ' supergroup ' then
2016-05-29 19:08:39 +02:00
bindings.unbanChatMember ( self , { chat_id = msg.chat . id , user_id = msg.from . id } )
2016-05-19 08:34:24 +02:00
end
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
if msg.new_chat_member and not new_user.do_kick then
2016-05-27 05:28:44 +02:00
local output = administration.get_desc ( self , msg.chat . id , config )
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
utilities.send_message ( self , msg.new_chat_member . id , output , true , nil , true )
2016-03-27 14:30:41 +02:00
end
2016-04-08 23:12:02 +02:00
-- Last active time for group listing.
2016-04-26 07:40:31 +02:00
if msg.text : len ( ) > 0 then
for i , v in pairs ( self.database . administration.activity ) do
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 v == chat_id_str then
2016-04-26 07:40:31 +02:00
table.remove ( self.database . administration.activity , i )
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
table.insert ( self.database . administration.activity , 1 , chat_id_str )
2016-04-26 07:40:31 +02:00
end
2016-04-08 23:12:02 +02:00
end
end
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
return true
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
end
2016-02-20 11:07:20 +01:00
} ,
2016-05-19 08:34:24 +02:00
{ -- /groups
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' groups ' , true ) . table ,
2016-04-08 23:12:02 +02:00
2016-06-19 10:36:33 +02:00
command = ' groups \\ [query] ' ,
2016-04-08 23:12:02 +02:00
privilege = 1 ,
interior = false ,
2016-06-19 10:36:33 +02:00
doc = ' Returns a list of groups matching the query, or a list of all administrated groups. ' ,
2016-04-08 23:12:02 +02:00
2016-06-19 10:36:33 +02:00
action = function ( self , msg , _ , config )
local input = utilities.input ( msg.text )
local search_res = ' '
local grouplist = ' '
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
for _ , chat_id_str in ipairs ( self.database . administration.activity ) do
local group = self.database . administration.groups [ chat_id_str ]
2016-06-19 10:36:33 +02:00
if ( not group.flags [ 1 ] ) and group.link then -- no unlisted or unlinked groups
grouplist = grouplist .. ' • [ ' .. utilities.md_escape ( group.name ) .. ' ]( ' .. group.link .. ' ) \n '
if input and string.match ( group.name : lower ( ) , input : lower ( ) ) then
search_res = search_res .. ' • [ ' .. utilities.md_escape ( group.name ) .. ' ]( ' .. group.link .. ' ) \n '
2016-04-08 23:12:02 +02:00
end
2016-02-20 11:07:20 +01:00
end
end
2016-06-19 10:36:33 +02:00
local output
if search_res ~= ' ' then
output = ' *Groups matching* _ ' .. input .. ' _ *:* \n ' .. search_res
elseif grouplist ~= ' ' then
output = ' *Groups:* \n ' .. grouplist
2016-04-08 23:12:02 +02:00
else
2016-06-19 10:36:33 +02:00
output = ' There are currently no listed groups. '
2016-04-08 23:12:02 +02:00
end
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-02-20 11:07:20 +01:00
end
} ,
2016-05-19 08:34:24 +02:00
{ -- /ahelp
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' ahelp ' , true ) . table ,
2016-04-08 23:12:02 +02:00
2016-05-25 15:01:54 +02:00
command = ' ahelp \\ [command] ' ,
2016-04-08 23:12:02 +02:00
privilege = 1 ,
interior = false ,
2016-05-25 15:01:54 +02:00
doc = ' Returns a list of realm-related commands for your rank (in a private message), or command-specific help. ' ,
2016-02-20 11:07:20 +01:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
local rank = administration.get_rank ( self , msg.from . id , msg.chat . id , config )
2016-05-25 15:01:54 +02:00
local input = utilities.get_word ( msg.text_lower , 2 )
if input then
2016-05-27 05:28:44 +02:00
input = input : gsub ( ' ^ ' .. config.cmd_pat .. ' ' , ' ' )
2016-05-25 15:01:54 +02:00
local doc
for _ , action in ipairs ( administration.commands ) do
if action.keyword == input then
2016-05-27 05:28:44 +02:00
doc = ' ' .. config.cmd_pat .. ' ' .. action.command : gsub ( ' \\ ' , ' ' ) .. ' \n ' .. action.doc
2016-05-25 15:01:54 +02:00
break
end
2016-04-08 23:12:02 +02:00
end
2016-05-25 15:01:54 +02:00
if doc then
local output = ' *Help for* _ ' .. input .. ' _ : \n ``` \n ' .. doc .. ' \n ``` '
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-05-25 15:01:54 +02:00
else
2016-05-27 05:28:44 +02:00
local output = ' Sorry, there is no help for that command. \n ' .. config.cmd_pat .. ' ahelp@ ' .. self.info . username
2016-05-29 19:08:39 +02:00
utilities.send_reply ( self , msg , output )
2016-04-08 23:12:02 +02:00
end
else
2016-05-25 15:01:54 +02:00
local output = ' *Commands for ' .. administration.ranks [ rank ] .. ' :* \n '
for i = 1 , rank do
for _ , val in ipairs ( self.admin_temp . help [ i ] ) do
2016-05-27 05:28:44 +02:00
output = output .. ' • ' .. config.cmd_pat .. val .. ' \n '
2016-05-25 15:01:54 +02:00
end
end
output = output .. ' Arguments: <required> \\ [optional] '
2016-05-29 19:08:39 +02:00
if utilities.send_message ( self , msg.from . id , output , true , nil , true ) then
2016-05-25 15:01:54 +02:00
if msg.from . id ~= msg.chat . id then
2016-05-29 19:08:39 +02:00
utilities.send_reply ( self , msg , ' I have sent you the requested information in a private message. ' )
2016-05-25 15:01:54 +02:00
end
else
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-05-25 15:01:54 +02:00
end
2016-04-01 19:29:00 +02:00
end
2016-02-25 10:42:13 +01:00
end
2016-02-20 11:07:20 +01:00
} ,
2016-05-25 15:01:54 +02:00
{ -- /ops
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' ops ' ) : t ( ' oplist ' ) . table ,
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
command = ' ops ' ,
privilege = 1 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Returns a list of moderators and the governor for the group. ' ,
2016-02-20 11:07:20 +01:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-04-08 23:12:02 +02:00
local modstring = ' '
for k , _ in pairs ( group.mods ) do
modstring = modstring .. administration.mod_format ( self , k )
end
if modstring ~= ' ' then
2016-05-25 15:01:54 +02:00
modstring = ' *Moderators for ' .. msg.chat . title .. ' :* \n ' .. modstring
2016-04-08 23:12:02 +02:00
end
local govstring = ' '
if group.governor then
local gov = self.database . users [ tostring ( group.governor ) ]
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 gov then
govstring = ' *Governor:* ' .. utilities.md_escape ( utilities.build_name ( gov.first_name , gov.last_name ) ) .. ' `[ ' .. gov.id .. ' ]` '
else
govstring = ' *Governor:* Unknown `[ ' .. group.governor .. ' ]` '
end
2016-04-08 23:12:02 +02:00
end
2016-04-15 21:07:23 +02:00
local output = utilities.trim ( modstring ) .. ' \n \n ' .. utilities.trim ( govstring )
2016-04-08 23:12:02 +02:00
if output == ' \n \n ' then
output = ' There are currently no moderators for this group. '
end
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-04-08 23:12:02 +02:00
end
2016-02-20 11:07:20 +01:00
2016-02-23 12:15:48 +01:00
} ,
2016-05-19 08:34:24 +02:00
{ -- /desc
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' desc ' ) : t ( ' description ' ) . table ,
2016-04-08 23:12:02 +02:00
command = ' description ' ,
privilege = 1 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Returns a description of the group (in a private message), including its motd, rules, flags, governor, and moderators. ' ,
2016-02-23 12:15:48 +01:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-05-27 05:28:44 +02:00
local output = administration.get_desc ( self , msg.chat . id , config )
2016-05-29 19:08:39 +02:00
if utilities.send_message ( self , msg.from . id , output , true , nil , true ) then
2016-04-08 23:12:02 +02:00
if msg.from . id ~= msg.chat . id then
2016-05-29 19:08:39 +02:00
utilities.send_reply ( self , msg , ' I have sent you the requested information in a private message. ' )
2016-04-08 23:12:02 +02:00
end
else
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-04-01 19:29:00 +02:00
end
2016-02-25 10:42:13 +01:00
end
2016-02-20 11:07:20 +01:00
} ,
2016-05-19 08:34:24 +02:00
{ -- /rules
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' rules? ' , true ) . table ,
2016-04-08 23:12:02 +02:00
2016-05-25 15:01:54 +02:00
command = ' rules \\ [i] ' ,
2016-04-08 23:12:02 +02:00
privilege = 1 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Returns the group \' s list of rules, or a specific rule. ' ,
2016-04-08 23:12:02 +02:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-04-08 23:12:02 +02:00
local output
local input = utilities.get_word ( msg.text_lower , 2 )
input = tonumber ( input )
if # group.rules > 0 then
if input and group.rules [ input ] then
output = ' * ' .. input .. ' .* ' .. group.rules [ input ]
else
2016-05-25 15:01:54 +02:00
output = ' *Rules for ' .. msg.chat . title .. ' :* \n '
2016-04-08 23:12:02 +02:00
for i , v in ipairs ( group.rules ) do
output = output .. ' * ' .. i .. ' .* ' .. v .. ' \n '
end
2016-04-05 12:43:11 +02:00
end
2016-04-08 23:12:02 +02:00
else
output = ' No rules have been set for ' .. msg.chat . title .. ' . '
2016-02-25 10:42:13 +01:00
end
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-02-20 11:07:20 +01:00
end
} ,
2016-05-19 08:34:24 +02:00
{ -- /motd
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' motd ' ) . table ,
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
command = ' motd ' ,
privilege = 1 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Returns the group \' s message of the day. ' ,
2016-02-20 11:07:20 +01:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-04-08 23:12:02 +02:00
local output = ' No MOTD has been set for ' .. msg.chat . title .. ' . '
if group.motd then
2016-05-25 15:01:54 +02:00
output = ' *MOTD for ' .. msg.chat . title .. ' :* \n ' .. group.motd
2016-04-08 23:12:02 +02:00
end
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-04-08 23:12:02 +02:00
end
2016-02-20 11:07:20 +01:00
} ,
2016-05-19 08:34:24 +02:00
{ -- /link
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' link ' ) . table ,
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
command = ' link ' ,
privilege = 1 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Returns the group \' s link. ' ,
2016-02-20 11:07:20 +01:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-04-08 23:12:02 +02:00
local output = ' No link has been set for ' .. msg.chat . title .. ' . '
if group.link then
output = ' [ ' .. msg.chat . title .. ' ]( ' .. group.link .. ' ) '
end
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-02-20 11:07:20 +01:00
end
} ,
2016-05-19 08:34:24 +02:00
{ -- /kick
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' kick ' , true ) . table ,
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
command = ' kick <user> ' ,
privilege = 2 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Removes a user from the group. The target may be specified via reply, username, or ID. ' ,
2016-04-08 23:12:02 +02:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
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 targets = administration.get_targets ( self , msg , config )
if targets then
local output = ' '
for _ , target in ipairs ( targets ) do
if target.err then
output = output .. target.err .. ' \n '
elseif target.rank >= administration.get_rank ( self , msg.from . id , msg.chat . id , config ) then
output = output .. target.name .. ' is too privileged to be kicked. \n '
else
administration.kick_user ( self , msg.chat . id , target.id , ' kicked by ' .. utilities.build_name ( msg.from . first_name , msg.from . last_name ) , config )
output = output .. target.name .. ' has been kicked. \n '
if msg.chat . type == ' supergroup ' then
bindings.unbanChatMember ( self , { chat_id = msg.chat . id , user_id = target.id } )
end
end
2016-05-25 15:01:54 +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
utilities.send_reply ( self , msg , output )
else
utilities.send_reply ( self , msg , ' Please specify a user or users via reply, username, or ID. ' )
2016-04-26 07:40:31 +02:00
end
2016-02-20 11:07:20 +01:00
end
2016-02-25 10:42:13 +01:00
} ,
2016-05-19 08:34:24 +02:00
{ -- /ban
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' ban ' , true ) . table ,
2016-02-25 10:42:13 +01:00
2016-04-08 23:12:02 +02:00
command = ' ban <user> ' ,
privilege = 2 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Bans a user from the group. The target may be specified via reply, username, or ID. ' ,
2016-04-08 23:12:02 +02:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
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 targets = administration.get_targets ( self , msg , config )
if targets then
local output = ' '
for _ , target in ipairs ( targets ) do
if target.err then
output = output .. target.err .. ' \n '
elseif group.bans [ target.id_str ] then
output = output .. target.name .. ' is already banned. \n '
elseif target.rank >= administration.get_rank ( self , msg.from . id , msg.chat . id , config ) then
output = output .. target.name .. ' is too privileged to be banned. \n '
else
administration.kick_user ( self , msg.chat . id , target.id , ' banned by ' .. utilities.build_name ( msg.from . first_name , msg.from . last_name ) , config )
output = output .. target.name .. ' has been banned. \n '
group.mods [ target.id_str ] = nil
group.bans [ target.id_str ] = true
end
end
utilities.send_reply ( self , msg , output )
2016-02-25 10:42:13 +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
utilities.send_reply ( self , msg , ' Please specify a user or users via reply, username, or ID. ' )
2016-02-25 10:42:13 +01:00
end
end
2016-04-08 23:12:02 +02:00
} ,
2016-05-25 15:01:54 +02:00
{ -- /unban
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' unban ' , true ) . table ,
2016-04-08 23:12:02 +02:00
2016-05-25 15:01:54 +02:00
command = ' unban <user> ' ,
privilege = 2 ,
2016-04-08 23:12:02 +02:00
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Unbans a user from the group. The target may be specified via reply, username, or ID. ' ,
2016-02-25 10:42:13 +01:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
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 targets = administration.get_targets ( self , msg , config )
if targets then
local output = ' '
for _ , target in ipairs ( targets ) do
if target.err then
output = output .. target.err .. ' \n '
else
if not group.bans [ target.id_str ] then
output = output .. target.name .. ' is not banned. \n '
else
output = output .. target.name .. ' has been unbanned. \n '
group.bans [ target.id_str ] = nil
end
if msg.chat . type == ' supergroup ' then
bindings.unbanChatMember ( self , { chat_id = msg.chat . id , user_id = target.id } )
end
end
2016-04-08 23:12:02 +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
utilities.send_reply ( self , msg , output )
else
utilities.send_reply ( self , msg , ' Please specify a user or users via reply, username, or ID. ' )
2016-04-08 23:12:02 +02:00
end
end
2016-02-20 11:07:20 +01:00
} ,
2016-06-17 07:13:05 +02:00
{ -- /setmotd
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' setmotd ' , true ) : t ( ' setqotd ' , true ) . table ,
2016-06-17 07:13:05 +02:00
command = ' setmotd <motd> ' ,
privilege = 2 ,
interior = true ,
doc = ' Sets the group \' s message of the day. Markdown is supported. Pass "--" to delete the message. ' ,
action = function ( self , msg , group , config )
local input = utilities.input ( msg.text )
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 quoted = utilities.build_name ( msg.from . first_name , msg.from . last_name )
2016-06-19 10:36:33 +02:00
if msg.reply_to_message and # msg.reply_to_message . text > 0 then
2016-06-17 07:13:05 +02:00
input = msg.reply_to_message . text
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 msg.reply_to_message . forward_from then
quoted = utilities.build_name ( msg.reply_to_message . forward_from.first_name , msg.reply_to_message . forward_from.last_name )
else
quoted = utilities.build_name ( msg.reply_to_message . from.first_name , msg.reply_to_message . from.last_name )
end
2016-06-17 07:13:05 +02:00
end
if input then
if input == ' -- ' or input == utilities.char . em_dash then
group.motd = nil
utilities.send_reply ( self , msg , ' The MOTD has been cleared. ' )
else
2016-06-19 10:36:33 +02:00
if msg.text : match ( ' ^/setqotd ' ) then
input = ' _ ' .. utilities.md_escape ( input ) .. ' _ \n - ' .. utilities.md_escape ( quoted )
end
2016-06-17 07:13:05 +02:00
group.motd = input
local output = ' *MOTD for ' .. msg.chat . title .. ' :* \n ' .. input
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
end
if group.grouptype == ' supergroup ' then
administration.update_desc ( self , msg.chat . id , config )
end
else
utilities.send_reply ( self , msg , ' Please specify the new message of the day. ' )
end
end
} ,
2016-05-19 08:34:24 +02:00
{ -- /setrules
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' setrules ' , true ) . table ,
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
command = ' setrules <rules> ' ,
privilege = 3 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Sets the group \' s rules. Rules will be automatically numbered. Separate rules with a new line. Markdown is supported. Pass "--" to delete the rules. ' ,
2016-04-08 23:12:02 +02:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-05-27 05:28:44 +02:00
local input = msg.text : match ( ' ^ ' .. config.cmd_pat .. ' setrules[@ ' .. self.info . username .. ' ]*(.+) ' )
2016-05-25 15:01:54 +02:00
if input == ' -- ' or input == ' ' .. utilities.char . em_dash then
2016-04-08 23:12:02 +02:00
group.rules = { }
2016-05-29 19:08:39 +02:00
utilities.send_reply ( self , msg , ' The rules have been cleared. ' )
2016-05-25 15:01:54 +02:00
elseif input then
group.rules = { }
input = utilities.trim ( input ) .. ' \n '
local output = ' *Rules for ' .. msg.chat . title .. ' :* \n '
local i = 1
for l in input : gmatch ( ' (.-) \n ' ) do
output = output .. ' * ' .. i .. ' .* ' .. l .. ' \n '
i = i + 1
table.insert ( group.rules , utilities.trim ( l ) )
end
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-05-25 15:01:54 +02:00
else
2016-05-29 19:08:39 +02:00
utilities.send_reply ( self , msg , ' Please specify the new rules. ' )
2016-04-08 23:12:02 +02:00
end
2016-05-25 15:01:54 +02:00
end
} ,
{ -- /changerule
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' changerule ' , true ) . table ,
2016-05-25 15:01:54 +02:00
command = ' changerule <i> <rule> ' ,
privilege = 3 ,
interior = true ,
2016-06-07 05:13:26 +02:00
doc = ' Changes a single rule. Pass "--" to delete the rule. If i is a number for which there is no rule, adds a rule by the next incremented number. ' ,
2016-05-25 15:01:54 +02:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-05-25 15:01:54 +02:00
local input = utilities.input ( msg.text )
2016-05-27 05:28:44 +02:00
local output = ' usage: ` ' .. config.cmd_pat .. ' changerule <i> <newrule>` '
2016-05-25 15:01:54 +02:00
if input then
local rule_num = tonumber ( input : match ( ' ^%d+ ' ) )
local new_rule = utilities.input ( input )
if not rule_num then
output = ' Please specify which rule you want to change. '
elseif not new_rule then
output = ' Please specify the new rule. '
elseif new_rule == ' -- ' or new_rule == utilities.char . em_dash then
if group.rules [ rule_num ] then
table.remove ( group.rules , rule_num )
output = ' That rule has been deleted. '
else
output = ' There is no rule with that number. '
end
else
if not group.rules [ rule_num ] then
rule_num = # group.rules + 1
end
group.rules [ rule_num ] = new_rule
output = ' * ' .. rule_num .. ' *. ' .. new_rule
end
2016-04-08 23:12:02 +02:00
end
2016-05-29 19:08:39 +02:00
utilities.send_reply ( self , msg , output , true )
2016-02-20 11:07:20 +01:00
end
} ,
2016-05-19 08:34:24 +02:00
{ -- /setlink
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' setlink ' , true ) . table ,
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
command = ' setlink <link> ' ,
privilege = 3 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Sets the group \' s join link. Pass "--" to regenerate the link. ' ,
2016-04-08 23:12:02 +02:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-04-08 23:12:02 +02:00
local input = utilities.input ( msg.text )
2016-05-26 13:22:20 +02:00
if input == ' -- ' or input == utilities.char . em_dash then
2016-04-08 23:12:02 +02:00
group.link = drua.export_link ( msg.chat . id )
2016-05-29 19:08:39 +02:00
utilities.send_reply ( self , msg , ' The link has been regenerated. ' )
2016-05-25 15:01:54 +02:00
elseif input then
group.link = input
local output = ' [ ' .. msg.chat . title .. ' ]( ' .. input .. ' ) '
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-05-25 15:01:54 +02:00
else
2016-05-29 19:08:39 +02:00
utilities.send_reply ( self , msg , ' Please specify the new link. ' )
2016-04-08 23:12:02 +02:00
end
end
2016-04-01 19:29:00 +02:00
} ,
2016-05-19 08:34:24 +02:00
{ -- /alist
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' alist ' ) . table ,
2016-04-01 19:29:00 +02:00
2016-04-08 23:12:02 +02:00
command = ' alist ' ,
privilege = 3 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Returns a list of administrators. Owner is denoted with a star character. ' ,
2016-04-01 19:29:00 +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
action = function ( self , msg , group , config )
2016-04-08 23:12:02 +02:00
local output = ' *Administrators:* \n '
2016-05-27 02:26:30 +02:00
output = output .. administration.mod_format ( self , config.admin ) : gsub ( ' \n ' , ' ★ \n ' )
2016-04-08 23:12:02 +02:00
for id , _ in pairs ( self.database . administration.admins ) do
output = output .. administration.mod_format ( self , id )
end
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-04-08 23:12:02 +02:00
end
2016-02-20 11:07:20 +01:00
} ,
2016-05-19 08:34:24 +02:00
{ -- /flags
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' flags? ' , true ) . table ,
2016-02-20 11:07:20 +01:00
2016-06-17 07:13:05 +02:00
command = ' flag \\ [i] ... ' ,
2016-04-08 23:12:02 +02:00
privilege = 3 ,
interior = true ,
2016-06-17 07:13:05 +02:00
doc = ' Returns a list of flags or toggles the specified flags. ' ,
2016-04-08 23:12:02 +02:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-06-17 07:13:05 +02:00
local output = ' '
2016-04-08 23:12:02 +02:00
local input = utilities.input ( msg.text )
if input then
2016-06-17 07:13:05 +02:00
local index = utilities.index ( input )
for _ , i in ipairs ( index ) do
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 n = tonumber ( i )
2016-06-17 07:13:05 +02:00
if n and administration.flags [ n ] then
if group.flags [ n ] == true then
group.flags [ n ] = false
output = output .. administration.flags [ n ] . disabled .. ' \n '
else
group.flags [ n ] = true
output = output .. administration.flags [ n ] . enabled .. ' \n '
end
end
end
if output == ' ' then
2016-06-14 23:57:36 +02:00
input = false
end
2016-04-08 23:12:02 +02:00
end
if not input then
2016-06-17 07:13:05 +02:00
output = ' *Flags for ' .. msg.chat . title .. ' :* \n '
for i , flag in ipairs ( administration.flags ) do
2016-04-08 23:12:02 +02:00
local status = group.flags [ i ] or false
2016-06-17 07:13:05 +02:00
output = output .. ' * ' .. i .. ' . ' .. flag.name .. ' * `[ ' .. tostring ( status ) .. ' ]` \n • ' .. flag.desc .. ' \n '
2016-04-08 23:12:02 +02:00
end
2016-02-20 11:07:20 +01:00
end
2016-06-17 07:13:05 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-02-20 11:07:20 +01:00
end
2016-03-31 13:53:12 +02:00
} ,
2016-05-19 08:34:24 +02:00
{ -- /antiflood
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' antiflood ' , true ) . table ,
2016-03-31 13:53:12 +02:00
2016-05-25 15:01:54 +02:00
command = ' antiflood \\ [<type> <i>] ' ,
2016-04-08 23:12:02 +02:00
privilege = 3 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Returns a list of antiflood values or sets one. ' ,
2016-04-08 23:12:02 +02:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-04-08 23:12:02 +02:00
if not group.flags [ 5 ] then
2016-05-27 05:28:44 +02:00
utilities.send_message ( self , msg.chat . id , ' antiflood is not enabled. Use ` ' .. config.cmd_pat .. ' flag 5` to enable it. ' , true , nil , true )
2016-04-08 23:12:02 +02:00
else
2016-05-25 15:01:54 +02:00
if not group.antiflood then
group.antiflood = JSON.decode ( JSON.encode ( administration.antiflood ) )
2016-04-08 23:12:02 +02:00
end
2016-05-25 15:01:54 +02:00
local input = utilities.input ( msg.text_lower )
local output
if input then
local key , val = input : match ( ' (%a+) (%d+) ' )
if not key or not val or not tonumber ( val ) then
output = ' Not a valid message type or number. '
elseif key == ' autoban ' then
group.autoban = tonumber ( val )
output = ' Users will now be autobanned after * ' .. val .. ' * autokicks. '
else
group.antiflood [ key ] = tonumber ( val )
output = ' * ' .. key : gsub ( ' ^%l ' , string.upper ) .. ' * messages are now worth * ' .. val .. ' * points. '
end
else
2016-05-27 05:28:44 +02:00
output = ' usage: ` ' .. config.cmd_pat .. ' antiflood <type> <i>` \n example: ` ' .. config.cmd_pat .. ' antiflood text 5` \n Use this command to configure the point values for each message type. When a user reaches 100 points, he is kicked. The points are reset each minute. The current values are: \n '
2016-05-25 15:01:54 +02:00
for k , v in pairs ( group.antiflood ) do
output = output .. ' * ' .. k .. ' :* ` ' .. v .. ' ` \n '
end
output = output .. ' Users will be banned automatically after * ' .. group.autoban .. ' * autokicks. Configure this with the *autoban* keyword. '
end
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , msg.message_id , true )
2016-03-31 13:53:12 +02:00
end
end
2016-02-20 11:07:20 +01:00
} ,
2016-05-19 08:34:24 +02:00
{ -- /mod
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' mod ' , true ) . table ,
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
command = ' mod <user> ' ,
privilege = 3 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Promotes a user to a moderator. The target may be specified via reply, username, or ID. ' ,
2016-04-08 23:12:02 +02:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
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 targets = administration.get_targets ( self , msg , config )
if targets then
local output = ' '
for _ , target in ipairs ( targets ) do
if target.err then
output = output .. target.err .. ' \n '
else
if target.rank > 1 then
output = output .. target.name .. ' is already a moderator or greater. \n '
else
output = output .. target.name .. ' is now a moderator. \n '
group.mods [ target.id_str ] = true
group.bans [ target.id_str ] = nil
end
if group.grouptype == ' supergroup ' then
drua.channel_set_admin ( msg.chat . id , target.id , 2 )
end
end
2016-04-08 23:12:02 +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
utilities.send_reply ( self , msg , output )
else
utilities.send_reply ( self , msg , ' Please specify a user or users via reply, username, or ID. ' )
2016-05-25 15:01:54 +02:00
end
end
} ,
{ -- /demod
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' demod ' , true ) . table ,
2016-05-25 15:01:54 +02:00
command = ' demod <user> ' ,
privilege = 3 ,
interior = true ,
doc = ' Demotes a moderator to a user. The target may be specified via reply, username, or ID. ' ,
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
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 targets = administration.get_targets ( self , msg , config )
if targets then
local output = ' '
for _ , target in ipairs ( targets ) do
if target.err then
output = output .. target.err .. ' \n '
else
if not group.mods [ target.id_str ] then
output = output .. target.name .. ' is not a moderator. \n '
else
output = output .. target.name .. ' is no longer a moderator. \n '
group.mods [ target.id_str ] = nil
end
if group.grouptype == ' supergroup ' then
drua.channel_set_admin ( msg.chat . id , target.id , 0 )
end
end
2016-04-08 23:12:02 +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
utilities.send_reply ( self , msg , output )
else
utilities.send_reply ( self , msg , ' Please specify a user or users via reply, username, or ID. ' )
2016-03-22 11:16:26 +01:00
end
2016-02-20 11:07:20 +01:00
end
} ,
2016-05-19 08:34:24 +02:00
{ -- /gov
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' gov ' , true ) . table ,
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
command = ' gov <user> ' ,
privilege = 4 ,
interior = true ,
2016-05-25 15:01:54 +02:00
doc = ' Promotes a user to the governor. The current governor will be replaced. The target may be specified via reply, username, or ID. ' ,
2016-04-08 23:12:02 +02:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
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 targets = administration.get_targets ( self , msg , config )
if targets then
local target = targets [ 1 ]
if target.err then
utilities.send_reply ( self , msg , target.err )
2016-05-25 15:01:54 +02: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
if group.governor == target.id then
utilities.send_reply ( self , msg , target.name .. ' is already the governor. ' )
else
group.bans [ target.id_str ] = nil
group.mods [ target.id_str ] = nil
group.governor = target.id
utilities.send_reply ( self , msg , target.name .. ' is the new governor. ' )
end
if group.grouptype == ' supergroup ' then
drua.channel_set_admin ( msg.chat . id , target.id , 2 )
administration.update_desc ( self , msg.chat . id , config )
end
2016-04-08 23:12:02 +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
else
utilities.send_reply ( self , msg , ' Please specify a user via reply, username, or ID. ' )
2016-03-22 11:16:26 +01:00
end
2016-05-25 15:01:54 +02:00
end
} ,
{ -- /degov
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' degov ' , true ) . table ,
2016-05-25 15:01:54 +02:00
command = ' degov <user> ' ,
privilege = 4 ,
interior = true ,
doc = ' Demotes the governor to a user. The administrator will become the new governor. The target may be specified via reply, username, or ID. ' ,
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
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 targets = administration.get_targets ( self , msg , config )
if targets then
local target = targets [ 1 ]
if target.err then
utilities.send_reply ( self , msg , target.err )
2016-05-25 15:01:54 +02: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
if group.governor ~= target.id then
utilities.send_reply ( self , msg , target.name .. ' is not the governor. ' )
else
group.governor = msg.from . id
utilities.send_reply ( self , msg , target.name .. ' is no longer the governor. ' )
end
if group.grouptype == ' supergroup ' then
drua.channel_set_admin ( msg.chat . id , target.id , 0 )
administration.update_desc ( self , msg.chat . id , config )
end
2016-05-25 15:01:54 +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
else
utilities.send_reply ( self , msg , ' Please specify a user via reply, username, or ID. ' )
2016-04-01 19:29:00 +02:00
end
2016-02-20 11:07:20 +01:00
end
} ,
2016-05-19 08:34:24 +02:00
{ -- /hammer
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' hammer ' , true ) . table ,
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
command = ' hammer <user> ' ,
privilege = 4 ,
interior = false ,
2016-05-25 15:01:54 +02:00
doc = ' Bans a user from all groups. The target may be specified via reply, username, or ID. ' ,
2016-04-08 23:12:02 +02:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
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 targets = administration.get_targets ( self , msg , config )
if targets then
local output = ' '
for _ , target in ipairs ( targets ) do
if target.err then
output = output .. target.err .. ' \n '
elseif self.database . blacklist [ target.id_str ] then
output = output .. target.name .. ' is already globally banned. \n '
elseif target.rank >= administration.get_rank ( self , msg.from . id , msg.chat . id , config ) then
output = output .. target.name .. ' is too privileged to be globally banned. \n '
else
2016-07-25 11:03:35 +02:00
if group then
administration.kick_user ( self , msg.chat . id , target.id , ' hammered by ' .. utilities.build_name ( msg.from . first_name , msg.from . last_name ) , config )
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
if # targets == 1 then
for k , v in pairs ( self.database . administration.groups ) do
if not v.flags [ 6 ] then
v.mods [ target.id_str ] = nil
drua.kick_user ( k , target.id )
end
end
end
self.database . blacklist [ target.id_str ] = true
2016-07-25 11:03:35 +02:00
if group and group.flags [ 6 ] == true 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
group.mods [ target.id_str ] = nil
group.bans [ target.id_str ] = true
output = output .. target.name .. ' has been globally and locally banned. \n '
else
output = output .. target.name .. ' has been globally banned. \n '
end
2016-05-21 02:47:13 +02:00
end
end
2016-05-29 19:08:39 +02:00
utilities.send_reply ( self , msg , output )
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
else
utilities.send_reply ( self , msg , ' Please specify a user or users via reply, username, or ID. ' )
2016-02-20 11:07:20 +01:00
end
end
} ,
2016-05-25 15:01:54 +02:00
{ -- /unhammer
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' unhammer ' , true ) . table ,
2016-05-25 15:01:54 +02:00
command = ' unhammer <user> ' ,
privilege = 4 ,
interior = false ,
doc = ' Removes a global ban. The target may be specified via reply, username, or ID. ' ,
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
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 targets = administration.get_targets ( self , msg , config )
if targets then
local output = ' '
for _ , target in ipairs ( targets ) do
if target.err then
output = output .. target.err .. ' \n '
elseif not self.database . blacklist [ target.id_str ] then
output = output .. target.name .. ' is not globally banned. \n '
else
self.database . blacklist [ target.id_str ] = nil
output = output .. target.name .. ' has been globally unbanned. \n '
end
end
utilities.send_reply ( self , msg , output )
2016-05-25 15:01:54 +02: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
utilities.send_reply ( self , msg , ' Please specify a user or users via reply, username, or ID. ' )
2016-05-25 15:01:54 +02:00
end
end
} ,
2016-05-19 08:34:24 +02:00
{ -- /admin
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' admin ' , true ) . table ,
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
command = ' admin <user> ' ,
privilege = 5 ,
interior = false ,
2016-05-25 15:01:54 +02:00
doc = ' Promotes a user to an administrator. The target may be specified via reply, username, or ID. ' ,
2016-04-08 23:12:02 +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
action = function ( self , msg , _ , config )
local targets = administration.get_targets ( self , msg , config )
if targets then
local output = ' '
for _ , target in ipairs ( targets ) do
if target.err then
output = output .. target.err .. ' \n '
elseif target.rank >= 4 then
output = output .. target.name .. ' is already an administrator or greater. \n '
else
for _ , group in pairs ( self.database . administration.groups ) do
group.mods [ target.id_str ] = nil
end
self.database . administration.admins [ target.id_str ] = true
output = output .. target.name .. ' is now an administrator. \n '
end
2016-04-08 23:12:02 +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
utilities.send_reply ( self , msg , output )
else
utilities.send_reply ( self , msg , ' Please specify a user or users via reply, username, or ID. ' )
2016-05-25 15:01:54 +02:00
end
end
} ,
{ -- /deadmin
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' deadmin ' , true ) . table ,
2016-05-25 15:01:54 +02:00
command = ' deadmin <user> ' ,
privilege = 5 ,
interior = false ,
doc = ' Demotes an administrator to a user. The target may be specified via reply, username, or ID. ' ,
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
action = function ( self , msg , _ , config )
local targets = administration.get_targets ( self , msg , config )
if targets then
local output = ' '
for _ , target in ipairs ( targets ) do
if target.err then
output = output .. target.err .. ' \n '
elseif target.rank ~= 4 then
output = output .. target.name .. ' is not an administrator. \n '
else
for chat_id , group in pairs ( self.database . administration.groups ) do
if group.grouptype == ' supergroup ' then
drua.channel_set_admin ( chat_id , target.id , 0 )
end
end
self.database . administration.admins [ target.id_str ] = nil
output = output .. target.name .. ' is no longer an administrator. \n '
2016-05-31 01:10:58 +02:00
end
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
utilities.send_reply ( self , msg , output )
else
utilities.send_reply ( self , msg , ' Please specify a user or users via reply, username, or ID. ' )
2016-05-25 15:01:54 +02:00
end
2016-02-20 11:07:20 +01:00
end
} ,
2016-05-19 08:34:24 +02:00
{ -- /gadd
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' gadd ' , true ) . table ,
2016-02-20 11:07:20 +01:00
2016-06-17 07:13:05 +02:00
command = ' gadd \\ [i] ... ' ,
2016-04-08 23:12:02 +02:00
privilege = 5 ,
interior = false ,
2016-06-17 07:13:05 +02:00
doc = ' Adds a group to the administration system. Pass numbers as arguments to enable those flags immediately. \n Example usage: \n \t /gadd 1 4 5 \n This would add a group and enable the unlisted flag, antibot, and antiflood. ' ,
2016-02-20 11:07:20 +01:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-06-14 23:57:36 +02:00
if msg.chat . id == msg.from . id then
utilities.send_message ( self , msg.chat . id , ' No. ' )
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
elseif group then
2016-05-29 19:08:39 +02:00
utilities.send_reply ( self , msg , ' I am already administrating this group. ' )
2016-05-25 15:01:54 +02:00
else
2016-06-17 07:13:05 +02:00
local output = ' I am now administrating this group. '
2016-06-07 05:13:26 +02:00
local flags = { }
for i = 1 , # administration.flags do
flags [ i ] = false
end
local input = utilities.input ( msg.text )
if input then
local index = utilities.index ( input )
for _ , i in ipairs ( index ) do
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 n = tonumber ( i )
2016-06-17 07:13:05 +02:00
if n and administration.flags [ n ] and flags [ n ] ~= true then
flags [ n ] = true
output = output .. ' \n ' .. administration.flags [ n ] . short
2016-06-07 05:13:26 +02:00
end
end
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 . administration.groups [ tostring ( msg.chat . id ) ] = {
2016-05-25 15:01:54 +02:00
mods = { } ,
governor = msg.from . id ,
bans = { } ,
2016-06-07 05:13:26 +02:00
flags = flags ,
2016-05-25 15:01:54 +02:00
rules = { } ,
grouptype = msg.chat . type ,
name = msg.chat . title ,
link = drua.export_link ( msg.chat . id ) ,
photo = drua.get_photo ( msg.chat . id ) ,
founded = os.time ( ) ,
autokicks = { } ,
autoban = 3
}
2016-05-27 05:28:44 +02:00
administration.update_desc ( self , msg.chat . id , config )
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
table.insert ( self.database . administration.activity , tostring ( msg.chat . id ) )
2016-06-17 07:13:05 +02:00
utilities.send_reply ( self , msg , output )
2016-05-25 15:01:54 +02:00
drua.channel_set_admin ( msg.chat . id , self.info . id , 2 )
2016-04-08 23:12:02 +02:00
end
end
2016-02-20 11:07:20 +01:00
} ,
2016-05-19 08:34:24 +02:00
{ -- /grem
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' grem ' , true ) : t ( ' gremove ' , true ) . table ,
2016-04-08 23:12:02 +02:00
command = ' gremove \\ [chat] ' ,
privilege = 5 ,
2016-04-26 07:40:31 +02:00
interior = false ,
2016-05-25 15:01:54 +02:00
doc = ' Removes a group from the administration system. ' ,
2016-04-08 23:12:02 +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
action = function ( self , msg )
local input = utilities.input ( msg.text ) or tostring ( msg.chat . id )
2016-04-26 07:40:31 +02:00
local output
2016-04-08 23:12:02 +02:00
if self.database . administration.groups [ input ] then
2016-04-29 06:36:35 +02:00
local chat_name = self.database . administration.groups [ input ] . name
2016-04-08 23:12:02 +02:00
self.database . administration.groups [ input ] = nil
for i , v in ipairs ( self.database . administration.activity ) do
if v == input then
table.remove ( self.database . administration.activity , i )
end
2016-03-28 08:15:46 +02:00
end
2016-04-26 07:40:31 +02:00
output = ' I am no longer administrating _ ' .. utilities.md_escape ( chat_name ) .. ' _. '
2016-04-08 23:12:02 +02: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
if input == tostring ( msg.chat . id ) then
2016-04-26 07:40:31 +02:00
output = ' I do not administrate this group. '
else
output = ' I do not administrate that group. '
end
2016-02-27 04:06:38 +01:00
end
2016-05-29 19:08:39 +02:00
utilities.send_message ( self , msg.chat . id , output , true , nil , true )
2016-02-20 11:07:20 +01:00
end
2016-04-01 19:29:00 +02:00
} ,
2016-05-19 08:34:24 +02:00
{ -- /glist
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
triggers = utilities.triggers ( self_.info . username , config_.cmd_pat ) : t ( ' glist ' , false ) . table ,
2016-04-08 23:12:02 +02:00
command = ' glist ' ,
privilege = 5 ,
interior = false ,
2016-05-25 15:01:54 +02:00
doc = ' Returns a list (in a private message) of all administrated groups with their governors and links. ' ,
2016-04-08 23:12:02 +02:00
2016-05-27 02:26:30 +02:00
action = function ( self , msg , group , config )
2016-04-08 23:12:02 +02:00
local output = ' '
if utilities.table_size ( self.database . administration.groups ) > 0 then
for k , v in pairs ( self.database . administration.groups ) do
output = output .. ' [ ' .. utilities.md_escape ( v.name ) .. ' ]( ' .. v.link .. ' ) `[ ' .. k .. ' ]` \n '
if v.governor then
local gov = self.database . users [ tostring ( v.governor ) ]
output = output .. ' ★ ' .. utilities.md_escape ( utilities.build_name ( gov.first_name , gov.last_name ) ) .. ' `[ ' .. gov.id .. ' ]` \n '
end
2016-04-01 19:29:00 +02:00
end
2016-04-08 23:12:02 +02:00
else
output = ' There are no groups. '
2016-04-01 19:29:00 +02:00
end
2016-05-29 19:08:39 +02:00
if utilities.send_message ( self , msg.from . id , output , true , nil , true ) then
2016-04-08 23:12:02 +02:00
if msg.from . id ~= msg.chat . id then
2016-05-29 19:08:39 +02:00
utilities.send_reply ( self , msg , ' I have sent you the requested information in a private message. ' )
2016-04-08 23:12:02 +02:00
end
2016-04-01 19:29:00 +02:00
end
end
2016-04-08 23:12:02 +02:00
}
2016-02-20 11:07:20 +01:00
2016-04-08 23:12:02 +02:00
}
2016-02-20 11:07:20 +01: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
administration.triggers = { ' ' }
2016-05-25 15:01:54 +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
-- Generate help messages and ahelp keywords.
2016-04-08 23:12:02 +02:00
self_.database . administration.help = { }
for i , _ in ipairs ( administration.ranks ) do
self_.admin_temp . help [ i ] = { }
end
for _ , v in ipairs ( administration.commands ) do
if v.command then
table.insert ( self_.admin_temp . help [ v.privilege ] , v.command )
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 v.doc then
v.keyword = utilities.get_word ( v.command , 1 )
end
2016-05-25 15:01:54 +02:00
end
end
2016-02-20 11:07:20 +01:00
end
2016-02-25 10:42:13 +01:00
2016-05-27 02:26:30 +02:00
function administration : action ( msg , config )
2016-04-08 23:12:02 +02:00
for _ , command in ipairs ( administration.commands ) do
for _ , trigger in pairs ( command.triggers ) do
if msg.text_lower : match ( trigger ) 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
( command.interior and not self.database . administration.groups [ tostring ( msg.chat . id ) ] )
or administration.get_rank ( self , msg.from . id , msg.chat . id , config ) < command.privilege
then
2016-02-20 11:07:20 +01:00
break
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
local res = command.action ( self , msg , self.database . administration.groups [ tostring ( msg.chat . id ) ] , config )
2016-02-20 11:07:20 +01:00
if res ~= true then
return res
end
end
end
end
return true
end
2016-04-08 23:12:02 +02:00
function administration : cron ( )
2016-04-12 05:55:46 +02:00
self.admin_temp . flood = { }
2016-05-19 08:34:24 +02:00
if os.date ( ' %d ' ) ~= self.database . administration.autokick_timer then
self.database . administration.autokick_timer = os.date ( ' %d ' )
for _ , v in pairs ( self.database . administration.groups ) do
v.autokicks = { }
end
end
2016-03-31 13:53:12 +02:00
end
2016-04-08 23:12:02 +02:00
return administration