├── .editorconfig
├── .gitignore
├── README.md
├── bot
├── bot.lua
├── methods.lua
├── permissions.lua
└── utils.lua
├── data
├── .gitkeep
└── spam_data.lua
├── lang
├── catala_lang.lua
├── english_lang.lua
├── persian_lang.lua
├── portuguese_lang.lua
└── spanish_lang.lua
├── launch.sh
├── libs
└── JSON.lua
└── plugins
├── commands.lua
├── extra.lua
├── gbans.lua
├── id.lua
├── langs.lua
├── moderation.lua
├── plugins.lua
├── private.lua
├── promote.lua
├── settings.lua
└── stats.lua
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = tab
6 | indent_size = 4
7 | trim_trailing_whitespace = true
8 | insert_final_newline = false
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.jpg
2 | bin/
3 | bot/log.txt
4 | logs/
5 | bot/data
6 | .luarocks/
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # **DBTeamV3** #
2 |
3 | [](https://core.telegram.org/tdlib)
4 | [](https://valtman.name/telegram-bot)
5 | [](https://www.lua.org/)
6 | [](https://redis.io/)
7 | [](https://github.com/Josepdal/DBTeamV1/blob/master/LICENSE)
8 |
9 |
10 | ### An administration Telegram bot using Telegram-cli
11 |
12 | DBTeamV3 is a a powerful administration userbot that uses [telegram-bot](https://valtman.name/telegram-bot).
13 | It is programmed in [Lua](https://www.lua.org/) and uses the rapid [Redis](https://redis.io/) database.
14 |
15 | The difference among the old [DBTeamV1](https://github.com/Josepdal/DBTeamV1) and [DBTeamV2](https://github.com/Josepdal/DBTeamV2) is that this one uses a much newer *Tg-Cli* with new stuff and also the bot has improved in usability, stability and has new functions.
16 |
17 | Using [DBTeamV3](https://github.com/Josepdal/DBTeamV3) you will get all [DBTeamV2](https://github.com/Josepdal/DBTeamV2) features plus the latests telegram changes like calls, payments and so more. Of course, is working in every chat including channels.
18 |
19 | # Summary
20 |
21 | - Easy to setup and to update, no compilation needed.
22 | - Uses a plugins system so you can easily configure or add what you need.
23 | - Multilanguage and easy to add new languages.
24 | - Has many funtions that normal bots are not able to do, e.g., read channels.
25 | - Advanced moderation system.
26 | - Has privilege ranges (sudo, admin, mod, user).
27 | - Simple and intuitive command usages.
28 | - Compatible with most of recent added telegram additions.
29 | - Really fast and stable.
30 | - Up-to-date documentation at http://telegra.ph/DBTeamV2-Tutorial-English-02-26
31 |
32 |
33 | # Installation
34 |
35 | Debian/Ubuntu and derivatives:
36 | ```bash
37 | # Tested on Ubuntu 16.04
38 | sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install git redis-server lua5.2 liblua5.2-dev lua-lgi libnotify-dev unzip tmux -y && add-apt-repository ppa:ubuntu-toolchain-r/test && sudo apt-get update && apt-get upgrade && sudo apt-get install libconfig++9v5 libstdc++6 && sudo apt autoremove
39 | ```
40 | In case of errors like `version GLIBCXX_3.4.21 not defined`, download manually libstdc++6 from [here](https://packages.ubuntu.com/xenial/libstdc++6), install the package with `dpkg -i` and repeat the previous step.
41 |
42 | If you are not able to install the bot in Ubuntu 14, an upgrade to Ubuntu 16.04 is recommended. Upgrade from terminal: `sudo do-release-upgrade`
43 |
44 | ---------------------------------
45 |
46 | After installing the dependencies, lets install the bot:
47 | ```bash
48 | git clone https://github.com/Josepdal/DBTeamV3.git
49 | cd DBTeamV3
50 | chmod +x launch.sh
51 | ./launch.sh install
52 | ./launch.sh login # Will ask you for a phone number & confirmation code.
53 | ./launch.sh
54 | ```
55 |
56 | DBTeamV3 Developers:
57 | --------------------
58 | [](https://t.me/Josepdal)
59 | [](https://t.me/Jarriz)
60 | [](https://t.me/iicc1)
61 |
62 | DBTeamV3 Channels:
63 | --------------------
64 | [](https://t.me/DBTeamEN)
65 | [](https://t.me/DBTeamES)
66 |
67 | Special thanks to:
68 | ==================
69 | Yago Pérez and his telegram-bot
70 | -------------------------------
71 | [](https://t.me/Yago_Perez)
72 | [](https://github.com/yagop/telegram-bot)
73 |
74 |
75 | Riccardo and his GroupButler
76 | ----------------------------
77 | [](https://t.me/bac0nnn)
78 | [](https://github.com/RememberTheAir/GroupButler)
79 |
80 |
81 | vysheng and his new telegram-bot
82 | --------------------------
83 | [](https://valtman.name/telegram-bot)
84 | [](https://github.com/vysheng)
85 |
86 |
87 | rizaumami and his tdcli lib
88 | ---------------------------
89 | [](https://github.com/rizaumami/tdcli.lua)
90 |
91 | Thanks to [@Reload_Life](https://t.me/Reload_Life) for [settings design](https://github.com/Reload-Life).
92 |
--------------------------------------------------------------------------------
/bot/bot.lua:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------
2 | -- ___ ___ _____ __ _____ --
3 | -- | \| _ )_ _|__ __ _ _ _\ \ / /_ ) --
4 | -- | |) | _ \ | |/ -_) _` | ' \ V / / / --
5 | -- |___/|___/ |_|\___\__,_|_|_|_\_/ /___| --
6 | -- --
7 | ----------------------------------------------------
8 |
9 | package.path = package.path ..';.luarocks/share/lua/5.2/?.lua' .. ';./bot/?.lua'
10 | package.cpath = package.cpath .. ';.luarocks/lib/lua/5.2/?.so'
11 |
12 | redis = require("redis")
13 | redis = redis.connect('127.0.0.1', 6379)
14 |
15 | require('utils')
16 | require("permissions")
17 | require('methods')
18 |
19 | local lgi = require ('lgi')
20 | local notify = lgi.require('Notify')
21 | notify.init ("Telegram updates")
22 |
23 | chats = {}
24 |
25 | function do_notify (user, msg)
26 | local n = notify.Notification.new(user, msg)
27 | n:show ()
28 | end
29 |
30 | function save_config( )
31 | serialize_to_file(_config, './data/config.lua')
32 | print ('saved config into ./data/config.lua')
33 | end
34 |
35 | function load_config( )
36 | local f = io.open('./data/config.lua', "r")
37 | -- If config.lua doesn't exist
38 | if not f then
39 | create_config()
40 | print ("Created new config file: data/config.lua")
41 | redis:sadd("start", "settings")
42 | else
43 | redis:sadd("load", "settings")
44 | f:close()
45 | end
46 | local config = loadfile ("./data/config.lua")()
47 | for v,user in pairs(config.sudo_users) do
48 | print("Allowed user: " .. user)
49 | end
50 | return config
51 | end
52 |
53 | function create_config()
54 | -- A simple config with basic plugins and ourselves as privileged user
55 | config = {
56 | enabled_plugins = {
57 | "settings",
58 | "id",
59 | "promote",
60 | "moderation",
61 | "commands",
62 | "plugins",
63 | "stats",
64 | "gbans",
65 | "extra",
66 | "langs",
67 | "private"
68 | },
69 | enabled_lang = {
70 | "english_lang"
71 | },
72 | our_id = {0},
73 | sudo_users = {0}
74 | }
75 | serialize_to_file(config, './data/config.lua')
76 | print ('saved config into ./data/config.lua')
77 | end
78 |
79 | function load_plugins()
80 | for k, v in pairs(_config.enabled_plugins) do
81 | print("Loading plugin", v)
82 | local ok, err = pcall(function()
83 | local t = loadfile("./plugins/"..v..'.lua')()
84 | plugins[v] = t
85 | end)
86 | if not ok then
87 | print('\27[31mError loading plugin '..v..'\27[39m')
88 | print('\27[31m'..err..'\27[39m')
89 | end
90 | end
91 | end
92 |
93 | function load_lang()
94 | for k, v in pairs(_config.enabled_lang) do
95 | print('\27[92mLoading language '.. v..'\27[39m')
96 | local ok, err = pcall(function()
97 | local t = loadfile("./lang/"..v..'.lua')()
98 | plugins[v] = t
99 | end)
100 | if not ok then
101 | print('\27[31mError loading language '..v..'\27[39m')
102 | print(tostring(io.popen("lua lang/"..v..".lua"):read('*all')))
103 | print('\27[31m'..err..'\27[39m')
104 | end
105 | end
106 | end
107 |
108 | _config = load_config()
109 | -- load plugins
110 | plugins = {}
111 | load_plugins()
112 | load_lang()
113 |
114 | function bot_init(msg)
115 | local receiver = msg.to.id
116 | local text = msg.text or "[other]"
117 | if msg.photo then text = "[photo]"
118 | elseif msg.sticker then text = "[sticker]"
119 | elseif msg.voice then text = "[voice]"
120 | elseif msg.gif then text = "[gif]"
121 | elseif msg.video then text = "[video]"
122 | elseif msg.document then text = "[document]"
123 | elseif msg.game then text = "[game]"
124 | end
125 | local user = msg.from.first_name or msg.from.username or ""
126 | print("\27[0;35m[" .. os.date("%X") .. "] \27[1;31m" .. msg.to.title .." \27[0;33m" .. user .." \27[39m » \27[0;34m" .. text .. "\27[39m")
127 |
128 | --Idea from https://github.com/RememberTheAir/GroupButler/blob/master/bot.lua
129 | if msg.from then
130 | redis:sadd('chat:' .. receiver .. ':members', msg.from.id)
131 | if msg.from.username then
132 | redis:hset('bot:usernames', '@'..msg.from.username:lower(), msg.from.id)
133 | redis:hset('bot:ids', msg.from.id, '@'.. msg.from.username:lower())
134 | elseif msg.from.first_name then
135 | redis:hset('bot:usernames', '@' .. msg.from.first_name:lower(), msg.from.id)
136 | redis:hset('bot:ids', msg.from.id, msg.from.first_name:lower())
137 | end
138 | end
139 | if msg.added then
140 | for i = 1, #msg.added, 1 do
141 | redis:sadd('chat:' .. receiver .. ':members', msg.added[i].id)
142 | end
143 | end
144 | if msg.reply_id then
145 | redis:sadd('chat:' .. receiver .. ':members', msg.replied.id)
146 | if msg.replied.username then
147 | redis:hset('bot:usernames', '@'.. msg.replied.username:lower(), msg.replied.id)
148 | redis:hset('bot:ids', msg.replied.id, '@'..msg.replied.username:lower())
149 | elseif msg.replied.first_name then
150 | redis:hset('bot:usernames', msg.replied.first_name:lower(), msg.replied.id)
151 | redis:hset('bot:ids', msg.replied.id, msg.replied.first_name:lower())
152 | end
153 | end
154 | if receiver ~= msg.from.id then -- If it is not a private chat
155 | redis:sadd('chats:ids', receiver)
156 | end
157 | if _config.our_id == msg.from.id then
158 | msg.from.id = 0
159 | end
160 | if msg_valid(msg) then
161 | msg = pre_process_msg(msg)
162 | if msg then
163 | if msg.from.id == receiver then -- match special plugins in private
164 | match_plugin(plugins.private, private, msg)
165 | else
166 | match_plugins(msg)
167 | end
168 | mark_as_read(receiver, {[0] = msg.id})
169 | end
170 | end
171 | end
172 |
173 | function chat_info(msg)
174 | tdbot_function ({
175 | _ = "getChat",
176 | chat_id = msg.to.id,
177 | }, chat_info_cb, msg)
178 | end
179 |
180 | function chat_info_cb(msg, data)
181 | msg.to.title = data.title
182 | bot_init(msg)
183 | end
184 |
185 | function user_reply_callback(msg, message)
186 | msg = reply_data(msg, message)
187 | chat_info(msg)
188 | end
189 |
190 | function reply_callback(msg, message)
191 | msg.replied.id = message.sender_user_id
192 | tdbot_function ({
193 | _ = "getUser",
194 | user_id = msg.replied.id
195 | }, user_reply_callback, msg)
196 | end
197 |
198 | function user_callback(msg, message)
199 | msg = user_data(msg, message)
200 | if msg.reply_id then
201 | tdbot_function ({
202 | _ = "getMessage",
203 | chat_id = msg.to.id,
204 | message_id = msg.reply_id
205 | }, reply_callback, msg)
206 | else
207 | chat_info(msg)
208 | end
209 | end
210 |
211 | -- This function is called when tg receive a msg
212 | function tdbot_update_callback (data)
213 | if (data._ == "updateNewMessage") or (data._ == "updateNewChannelMessage") then
214 | local msg = data.message
215 | if redis:sismember("start", "settings") then
216 | redis:srem("start", "settings")
217 | changeAbout("DBTeamV3 Tg-cli administration Bot\nChannels: @DBTeamEn @DBTeamEs", ok_cb)
218 | getMe(getMeCb)
219 | elseif redis:sismember("load", "settings") then
220 | redis:srem("load", "settings")
221 | -- This loads to cache most of users, chats, channels .. that are removed in every reboot
222 | getChats(2^63 - 1, 0, 20, ok_cb)
223 | -- This opens all chats and channels in order to receive updates
224 | for k, chat in pairs (redis:smembers('chats:ids')) do
225 | openChat(chat, ok_cb)
226 | end
227 | end
228 | msg = oldtg(data)
229 | tdbot_function ({
230 | _ = "getUser",
231 | user_id = data.message.sender_user_id
232 | }, user_callback, msg)
233 | end
234 | end
235 |
236 | function msg_valid(msg)
237 | -- Don't process outgoing messages
238 | if msg.from.id == 0 then
239 | print('\27[36mNot valid: msg from us\27[39m')
240 | return false
241 | end
242 |
243 | -- Before bot was started
244 | if msg.date < now then
245 | print('\27[36mNot valid: old msg\27[39m')
246 | return false
247 | end
248 |
249 | if msg.unread == 0 then
250 | print('\27[36mNot valid: readed\27[39m')
251 | return false
252 | end
253 |
254 | if not msg.to.id then
255 | print('\27[36mNot valid: To id not provided\27[39m')
256 | return false
257 | end
258 |
259 | if not msg.from.id then
260 | print('\27[36mNot valid: From id not provided\27[39m')
261 | return false
262 | end
263 |
264 | if msg.from.id == 777000 then
265 | print('\27[36mNot valid: Telegram message\27[39m')
266 | return false
267 | end
268 |
269 | return true
270 | end
271 |
272 | -- Apply plugin.pre_process function
273 | function pre_process_msg(msg)
274 | for name,plugin in pairs(plugins) do
275 | if plugin.pre_process and msg then
276 | print('Preprocess', name)
277 | msg = plugin.pre_process(msg)
278 | end
279 | end
280 | return msg
281 | end
282 |
283 | -- Go over enabled plugins patterns.
284 | function match_plugins(msg)
285 | for name, plugin in pairs(plugins) do
286 | match_plugin(plugin, name, msg)
287 | end
288 | end
289 |
290 | -- Check if plugin is on _config.disabled_plugin_on_chat table
291 | local function is_plugin_disabled_on_chat(plugin_name, receiver)
292 | local disabled_chats = _config.disabled_plugin_on_chat
293 | -- Table exists and chat has disabled plugins
294 | if disabled_chats and disabled_chats[receiver] then
295 | -- Checks if plugin is disabled on this chat
296 | for disabled_plugin,disabled in pairs(disabled_chats[receiver]) do
297 | if disabled_plugin == plugin_name and disabled then
298 | local warning = 'Plugin '..disabled_plugin..' is disabled on this chat'
299 | return true
300 | end
301 | end
302 | end
303 | return false
304 | end
305 |
306 | function match_plugin(plugin, plugin_name, msg)
307 | local receiver = get_receiver(msg)
308 | -- Go over patterns. If one matches it's enough.
309 | for k, pattern in pairs(plugin.patterns) do
310 | local matches = match_pattern(pattern, msg.text)
311 | if matches then
312 | -- Function exists
313 | if plugin.run then
314 | -- If plugin is for privileged users only
315 | local result = plugin.run(msg, matches)
316 | if result then
317 | send_msg(receiver, result, "md")
318 | end
319 | end
320 | -- One patterns matches
321 | return
322 | end
323 | end
324 | end
325 |
326 | now = os.time()
327 | math.randomseed(now)
328 |
--------------------------------------------------------------------------------
/bot/methods.lua:
--------------------------------------------------------------------------------
1 | function send_msg(chat_id, text, parse)
2 | assert( tdbot_function ({
3 | _ = "sendMessage",
4 | chat_id = chat_id,
5 | reply_to_message_id = 0,
6 | disable_notification = 0,
7 | from_background = 1,
8 | reply_markup = nil,
9 | input_message_content = {
10 | _ = "inputMessageText",
11 | text = text,
12 | disable_web_page_preview = 1,
13 | clear_draft = 0,
14 | parse_mode = getParse(parse),
15 | entities = {}
16 | }
17 | }, dl_cb, nil))
18 |
19 | end
20 |
21 | function reply_msg(chat_id, text, msg_id, parse)
22 | tdbot_function ({
23 | _ = "sendMessage",
24 | chat_id = chat_id,
25 | reply_to_message_id = msg_id,
26 | disable_notification = 0,
27 | from_background = 1,
28 | reply_markup = nil,
29 | input_message_content = {
30 | _ = "inputMessageText",
31 | text = text,
32 | disable_web_page_preview = 1,
33 | clear_draft = 0,
34 | parse_mode = getParse(parse),
35 | entities = {}
36 | }
37 | }, dl_cb, nil)
38 | end
39 |
40 | function createNewGroupChat(user_ids, title, cb, cmd)
41 | tdbot_function ({
42 | _ = "createNewGroupChat",
43 | user_ids = user_ids, -- vector
44 | title = title
45 | }, cb or dl_cb, cmd)
46 | end
47 |
48 | function migrateGroupChatToChannelChat(chat_id, cb, cmd)
49 | tdbot_function ({
50 | ID = "migrateGroupChatToChannelChat",
51 | chat_id = chat_id
52 | }, cb or dl_cb, cmd)
53 | end
54 |
55 | function changeChatMemberStatus(chat_id, user_id, status, cb, cmd)
56 | tdbot_function ({
57 | _ = "changeChatMemberStatus",
58 | chat_id = chat_id,
59 | user_id = user_id,
60 | status = {
61 | _ = "chatMemberStatus" .. status
62 | },
63 | }, cb or dl_cb, cmd)
64 | end
65 |
66 | function delete_msg(chat_id, msg_id)
67 | msg_id = {[0] = msg_id}
68 | tdbot_function ({
69 | _ = "deleteMessages",
70 | chat_id = chat_id,
71 | message_ids = msg_id
72 | }, dl_cb, nil)
73 | end
74 |
75 | function getParse(parse)
76 | if parse == 'md' then
77 | return {_ = "textParseModeMarkdown"}
78 | elseif parse == 'html' then
79 | return {_ = "textParseModeHTML"}
80 | else
81 | return nil
82 | end
83 | end
84 |
85 | function sendRequest(request_id, chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, input_message_content, callback, extra)
86 | tdbot_function ({
87 | _ = request_id,
88 | chat_id = chat_id,
89 | reply_to_message_id = reply_to_message_id,
90 | disable_notification = disable_notification,
91 | from_background = from_background,
92 | reply_markup = reply_markup,
93 | input_message_content = input_message_content,
94 | }, callback or dl_cb, extra)
95 | end
96 |
97 | function add_user(chat_id, user_id)
98 | tdbot_function ({
99 | _ = "addChatMember",
100 | chat_id = chat_id,
101 | user_id = user_id,
102 | forward_limit = 0
103 | }, dl_cb, extra)
104 | end
105 |
106 | function mark_as_read(chat_id, message_ids)
107 | tdbot_function ({
108 | _ = "ViewMessages",
109 | chat_id = chat_id,
110 | message_ids = message_ids
111 | }, dl_cb, extra)
112 | end
113 |
114 | function get_msg_info(chat_id, message_id, cb_function, extra)
115 | tdbot_function ({
116 | _ = "getMessage",
117 | chat_id = chat_id,
118 | message_id = message_id
119 | }, cb_function, extra)
120 | end
121 |
122 | function getChats(offset_order, offset_chat_id, limit, cb, cmd)
123 | if not limit or limit > 20 then
124 | limit = 20
125 | end
126 | tdbot_function ({
127 | _ = "getChats",
128 | offset_order = offset_order or 9223372036854775807,
129 | offset_chat_id = offset_chat_id or 0,
130 | limit = limit
131 | }, cb or dl_cb, cmd)
132 | end
133 |
134 | function getMe(cb, cmd)
135 | tdbot_function ({
136 | _ = "getMe",
137 | }, cb or dl_cb, cmd)
138 | end
139 |
140 | function getMeCb(extra, result)
141 | our_id = result.id
142 | print("Our id: "..our_id)
143 | file = io.open("./data/config.lua", "r")
144 | config = ''
145 | repeat
146 | line = file:read ("*l")
147 | if line then
148 | line = string.gsub(line, "0", our_id)
149 | config = config.."\n"..line
150 | end
151 | until not line
152 |
153 | file:close()
154 | file = io.open("./data/config.lua", "w")
155 | file:write(config)
156 | file:close()
157 | end
158 |
159 | function changeAbout(about, cb, cmd)
160 | tdbot_function ({
161 | _ = "changeAbout",
162 | about = about
163 | }, cb or dl_cb, cmd)
164 | end
165 |
166 | function pin_msg(channel_id, message_id, disable_notification)
167 | tdbot_function ({
168 | _ = "pinChannelMessage",
169 | channel_id = getChatId(channel_id)._,
170 | message_id = message_id,
171 | disable_notification = disable_notification
172 | }, dl_cb, nil)
173 | end
174 |
175 | function openChat(chat_id, cb, cmd)
176 | tdbot_function ({
177 | _ = "openChat",
178 | chat_id = chat_id
179 | }, cb or dl_cb, cmd)
180 | end
181 |
182 | function kick_user(chat_id, user_id)
183 | tdbot_function ({
184 | _ = "changeChatMemberStatus",
185 | chat_id = chat_id,
186 | user_id = user_id,
187 | status = {
188 | _ = "chatMemberStatusBanned"
189 | },
190 | }, dl_cb, nil)
191 | end
192 |
193 | function promoteToAdmin(chat_id, user_id)
194 | tdbot_function ({
195 | _ = "changeChatMemberStatus",
196 | chat_id = chat_id,
197 | user_id = user_id,
198 | status = {
199 | _ = "chatMemberStatusAdministrator"
200 | },
201 | }, dl_cb, nil)
202 | end
203 |
204 | function removeFromBanList(chat_id, user_id)
205 | tdbot_function ({
206 | _ = "changeChatMemberStatus",
207 | chat_id = chat_id,
208 | user_id = user_id,
209 | status = {
210 | _ = "chatMemberStatusLeft"
211 | },
212 | }, dl_cb, nil)
213 | end
214 |
215 | function addChatMember(chat_id, user_id)
216 | tdbot_function ({
217 | _ = "addChatMember",
218 | chat_id = chat_id,
219 | user_id = user_id,
220 | forward_limit = 50
221 | }, cb or dl_cb, nil)
222 | end
223 |
224 | function resolve_username(username, cb_function, cb_extra)
225 | tdbot_function ({
226 | _ = "searchPublicChat",
227 | username = username
228 | }, cb_function, cb_extra)
229 | end
230 |
231 | function resolve_cb(extra, user)
232 | if compare_permissions(extra.chat_id, extra.superior, user.id) then
233 | if extra.command == "ban" then
234 | send_msg(extra.chat_id, lang_text(extra.chat_id, 'banUser'):gsub("$id", user.id), "md")
235 | kick_user(extra.chat_id, user.id)
236 | redis:set("ban:" .. extra.chat_id .. ":" .. user.id, true)
237 | elseif extra.command == "unban" then
238 | send_msg(extra.chat_id, lang_text(extra.chat_id, 'unbanUser'):gsub("$id", user.id), "md")
239 | redis:del("ban:" .. extra.chat_id .. ":" .. user.id)
240 | removeFromBanList(extra.chat_id, user.id)
241 | elseif extra.command == "kick" then
242 | send_msg(extra.chat_id, lang_text(extra.chat_id, 'kickUser'):gsub("$id", user.id), "md")
243 | kick_user(extra.chat_id, user.id)
244 | removeFromBanList(extra.chat_id, user.id)
245 | elseif extra.command == "gban" then
246 | send_msg(extra.chat_id, lang_text(extra.chat_id, 'gbanUser'):gsub("$id", user.id), "md")
247 | kick_user(extra.chat_id, user.id)
248 | redis:sadd("gbans", user.id)
249 | elseif extra.command == "ungban" then
250 | send_msg(extra.chat_id, lang_text(extra.chat_id, 'unbanUser'):gsub("$id", user.id), "md")
251 | redis:srem("gbans", user.id)
252 | elseif extra.command == "mute" then
253 | send_msg(extra.chat_id, lang_text(extra.chat_id, 'muteUser'):gsub("$id", user.id), "md")
254 | redis:set("muted:" .. extra.chat_id .. ":" .. user.id, true)
255 | elseif extra.command == "unmute" then
256 | send_msg(extra.chat_id, lang_text(extra.chat_id, 'unmuteUser'):gsub("$id", user.id), "md")
257 | redis:del("muted:" .. extra.chat_id .. ":" .. user.id)
258 | elseif extra.command == "admin" then
259 | send_msg(extra.chat_id, lang_text(extra.chat_id, 'newAdmin') .. ": @" .. (user.type_.user_.username_ or user.type_.user_.first_name_), "html")
260 | redis:sadd('admins', user.id)
261 | redis:srem('mods:'..extra.chat_id, user.id)
262 | redis:hset('bot:ids',user.id, '@'.. user.type_.user_.username_)
263 | elseif extra.command == "mod" then
264 | send_msg(extra.chat_id, lang_text(extra.chat_id, 'newMod') .. ": @" .. (user.type_.user_.username_ or user.type_.user_.first_name_), "html")
265 | redis:sadd('mods:'..extra.chat_id, user.id)
266 | if new_is_sudo(extra.superior) then
267 | redis:srem('admins', user.id)
268 | end
269 | redis:hset('bot:ids',user.id, '@'.. user.type_.user_.username_)
270 | elseif extra.command == "user" then
271 | if new_is_sudo(extra.superior) then
272 | redis:srem('mods:'..extra.chat_id, user.id)
273 | redis:srem('admins', user.id)
274 | elseif is_admin(extra.superior) then
275 | redis:srem('mods:'..extra.chat_id, user.id)
276 | end
277 | send_msg(extra.chat_id, ">
@" .. (user.type_.user_.username_ or user.type_.user_.first_name_) .. "" .. lang_text(extra.chat_id, 'nowUser'), "html")
278 | end
279 | else
280 | permissions(extra.superior, extra.chat_id, extra.plugin_tag)
281 | end
282 | end
283 |
284 | function resolve_id(user_id, cb_function, cb_extra)
285 | tdbot_function ({
286 | _ = "getUserFull",
287 | user_id = user_id
288 | }, cb_function, cb_extra)
289 | end
290 |
291 | function getChat(chat_id, cb, cmd)
292 | tdbot_function ({
293 | _ = "getChat",
294 | chat_id = chat_id
295 | }, cb or dl_cb, cmd)
296 | end
297 |
298 | function getChannelMembers(channel_id, offset, filter, limit, cb_function, cb_extra)
299 | if not limit or limit > 200 then
300 | limit = 200
301 | end
302 |
303 | tdbot_function ({
304 | _ = "getChannelMembers",
305 | channel_id = getChatId(channel_id)._,
306 | filter = {
307 | _ = "channelMembersFilter" .. filter
308 | },
309 | offset = offset,
310 | limit = limit
311 | }, cb_function or cb_function, cb_extra)
312 | end
313 |
314 | function forward_msg(chat_id, from_chat_id, message_id)
315 | message_id = {[0] = message_id}
316 | tdbot_function ({
317 | _ = "forwardMessages",
318 | chat_id = chat_id,
319 | from_chat_id = from_chat_id,
320 | message_ids = message_id,
321 | disable_notification = 0,
322 | from_background = 1
323 | }, dl_cb, nil)
324 | end
325 |
326 | function kick_resolve_cb(extra, user)
327 | if compare_permissions(extra.chat_id, extra.superior, user.id) then
328 | tdbot_function ({
329 | _ = "changeChatMemberStatus",
330 | chat_id = tonumber(extra.chat_id),
331 | user_id = user.id,
332 | status = {
333 | _ = "chatMemberStatusKicked"
334 | },
335 | }, dl_cb, nil)
336 | else
337 | send_msg(extra.chat_id, 'error', 'md')
338 | end
339 | end
340 |
341 | function kick_resolve(chat_id, username, extra)
342 | resolve_username(username, kick_resolve_cb, {chat_id = chat_id, superior = extra})
343 | end
344 |
345 | function redisunban_by_reply_cb(channel_id, msg)
346 | redis:del("ban:" .. channel_id .. ":" .. msg.sender_user_id_)
347 | end
348 |
349 | function redisunban_by_reply(channel_id, message_id)
350 | get_msg_info(channel_id, message_id, redisunban_by_reply_cb, channel_id)
351 | end
352 |
353 | function redisban_resolve_cb(extra, user)
354 | if compare_permissions(extra.chat_id, extra.superior, user.id) then
355 | redis:set("ban:" .. extra.chat_id .. ":" .. user.id, true)
356 | end
357 | end
358 |
359 | function redisban_resolve(chat_id, username, superior)
360 | local extra = {}
361 | resolve_username(username, redisban_resolve_cb, {chat_id = chat_id, superior = superior})
362 | end
363 |
364 | function redisgban_resolve_cb(chat_id, user)
365 | redis:sadd("gbans", user.id)
366 | end
367 |
368 | function redisgban_resolve(chat_id, username)
369 | resolve_username(username, redisgban_resolve_cb, chat_id)
370 | end
371 |
372 | function redisgban_resolve_cb(chat_id, user)
373 | redis:srem("gbans", user.id)
374 | end
375 |
376 | function redisgban_resolve(chat_id, username)
377 | resolve_username(username, redisgban_resolve_cb, chat_id)
378 | end
379 |
380 | function redisunban_resolve_cb(extra, user)
381 | if compare_permissions(extra.chat_id, extra.superior, user.id) then
382 | redis:del("ban:" .. extra.chat_id .. ":" .. user.id)
383 | end
384 | end
385 |
386 | function redisunban_resolve(chat_id, username, superior)
387 | resolve_username(username, redisunban_resolve_cb, {chat_id = chat_id, superior = superior})
388 | end
389 |
390 | function redismute_resolve_cb(chat_id, user)
391 | redis:set("muted:" .. chat_id .. ":" .. user.id, true)
392 | end
393 |
394 | function redismute_resolve(chat_id, username)
395 | resolve_username(username, redismute_resolve_cb, chat_id)
396 | end
397 |
398 | function redisunmute_resolve_cb(chat_id, user)
399 | redis:del("muted:" .. chat_id .. ":" .. user.id)
400 | end
401 |
402 | function redisunmute_resolve(chat_id, username)
403 | resolve_username(username, redisunmute_resolve_cb, chat_id)
404 | end
405 |
406 | function getInputFile(file)
407 | if file:match('/') then
408 | infile = {_ = "InputFileLocal", path = file}
409 | elseif file:match('^%d+$') then
410 | infile = {_ = "InputFileId", id = file}
411 | else
412 | infile = {_ = "InputFilePersistentId", persistent_id = file}
413 | end
414 | return infile
415 | end
416 |
417 | function sendSticker(chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, sticker, cb, cmd)
418 | local input_message_content = {
419 | _ = "inputMessageSticker",
420 | sticker = getInputFile(sticker),
421 | width = 0,
422 | height = 0
423 | }
424 | sendRequest('SendMessage', chat_id, reply_to_message_id, disable_notification, from_background, reply_markup, input_message_content, cb, cmd)
425 | end
426 |
427 | function send_document(chat_id, document)
428 | tdbot_function ({
429 | _ = "sendMessage",
430 | chat_id = chat_id,
431 | reply_to_message_id = 0,
432 | disable_notification = 0,
433 | from_background = 1,
434 | reply_markup = nil,
435 | input_message_content = {
436 | _ = "inputMessageDocument",
437 | document = getInputFile(document),
438 | caption = nil
439 | },
440 | }, dl_cb, cb_extra)
441 | end
442 |
443 | function sendSticker(chat_id, sticker)
444 | local input_message_content = {
445 | _ = "inputMessageSticker",
446 | sticker = getInputFile(sticker),
447 | width = 0,
448 | height = 0
449 | }
450 | sendRequest('sendMessage', chat_id, 0, 0, 1, nil, input_message_content, cbsti)
451 | end
452 |
453 | function sendAnimation(chat_id, gif, caption)
454 | local input_message_content = {
455 | _ = "inputMessageAnimation",
456 | animation = getInputFile(gif),
457 | width = 0,
458 | height = 0,
459 | caption = caption
460 | }
461 | sendRequest('sendMessage', chat_id, 0, 0, 1, nil, input_message_content, cbsti)
462 | end
463 |
464 | function sendAudio(chat_id, audio, caption)
465 | local input_message_content = {
466 | _ = "inputMessageAudio",
467 | audio = getInputFile(audio),
468 | duration = duration or 0,
469 | title = title or 0,
470 | performer = performer,
471 | caption = caption
472 | }
473 | sendRequest('sendMessage', chat_id, 0, 0, 1, nil, input_message_content, cbsti)
474 | end
475 |
476 | function sendDocument(chat_id, document, caption)
477 | local input_message_content = {
478 | _ = "inputMessageDocument",
479 | document = getInputFile(document),
480 | caption = caption
481 | }
482 | sendRequest('sendMessage', chat_id, 0, 0, 1, nil, input_message_content, cbsti)
483 | end
484 |
485 | function sendPhoto(chat_id, photo, caption)
486 | local input_message_content = {
487 | _ = "inputMessagePhoto",
488 | photo = getInputFile(photo),
489 | added_sticker_file_ids = {},
490 | width = 0,
491 | height = 0,
492 | caption = caption
493 | }
494 | sendRequest('SendMessage', chat_id, 0, 0, 1, nil, input_message_content, cbsti)
495 | end
496 |
497 | function sendVideo(chat_id, video, caption)
498 | local input_message_content = {
499 | _ = "inputMessageVideo",
500 | video = getInputFile(video),
501 | added_sticker_file_ids = {},
502 | duration = duration or 0,
503 | width = width or 0,
504 | height = height or 0,
505 | caption = caption
506 | }
507 | sendRequest('sendMessage', chat_id, 0, 0, 1, nil, input_message_content, cbsti)
508 | end
509 |
510 | function sendVoice(chat_id, voice, caption)
511 | local input_message_content = {
512 | _ = "inputMessageVoice",
513 | voice = getInputFile(voice),
514 | duration = duration or 0,
515 | waveform = waveform or 0,
516 | caption = caption
517 | }
518 | sendRequest('sendMessage', chat_id, 0, 0, 1, nil, input_message_content, cbsti)
519 | end
520 |
521 | function cbsti(a,b)
522 | --vardump(a)
523 | --vardump(b)
524 | end
525 |
526 | function export_link(chat_id, cb_function, cb_extra)
527 | tdbot_function ({
528 | _ = "exportChatInviteLink",
529 | chat_id = chat_id
530 | }, cb_function, cb_extra)
531 | end
532 |
533 | function checkChatInviteLink(link, cb, cmd)
534 | tdbot_function ({
535 | _ = "checkChatInviteLink",
536 | invite_link = link
537 | }, cb or dl_cb, cmd)
538 | end
539 |
540 | function getChannelFull(channel_id, cb, cmd)
541 | tdbot_function ({
542 | _ = "GetChannelFull",
543 | channel_id = getChatId(channel_id)._
544 | }, cb or dl_cb, cmd)
545 | end
546 |
547 | function chat_history(chat_id, from_message_id, offset, limit, cb_function, cb_extra)
548 | if not limit or limit > 100 then
549 | limit = 100
550 | end
551 | tdbot_function ({
552 | _ = "getChatHistory",
553 | chat_id = chat_id,
554 | from_message_id = from_message_id,
555 | offset = offset or 0,
556 | limit = limit
557 | }, cb_function, cb_extra)
558 | end
559 |
560 | function delete_msg_user(chat_id, user_id)
561 | tdbot_function ({
562 | _ = "deleteMessagesFromUser",
563 | chat_id = chat_id,
564 | user_id = user_id
565 | }, cb or dl_cb, nil)
566 | end
--------------------------------------------------------------------------------
/bot/permissions.lua:
--------------------------------------------------------------------------------
1 | local sudos = {
2 | "lang_install",
3 | "promote_admin",
4 | "plugins",
5 | "banall",
6 | "leave",
7 | "setabout",
8 | "creategroup"
9 | }
10 | local admins = {
11 | "promote_mod",
12 | "promote_user",
13 | "gban",
14 | "add_moderation",
15 | "adduser"
16 | }
17 | local mods = {
18 | "set_lang",
19 | "settings",
20 | "muteBan",
21 | "moderation",
22 | "mod_commands",
23 | "tagall",
24 | "rem_history",
25 | "spam"
26 | }
27 |
28 | local function get_tag(plugin_tag)
29 | for v,tag in pairs(sudos) do
30 | if tag == plugin_tag then
31 | return 3
32 | end
33 | end
34 | for v,tag in pairs(admins) do
35 | if tag == plugin_tag then
36 | return 2
37 | end
38 | end
39 | for v,tag in pairs(mods) do
40 | if tag == plugin_tag then
41 | return 1
42 | end
43 | end
44 | return 0
45 | end
46 |
47 | local function user_num(user_id, chat_id)
48 | if new_is_sudo(user_id) then
49 | return 3
50 | elseif is_admin(user_id) then
51 | return 2
52 | elseif is_mod(chat_id, user_id) then
53 | return 1
54 | else
55 | return 0
56 | end
57 | end
58 |
59 | local function send_warning(user_id, chat_id, user_need)
60 | if user_need == 3 then
61 | send_msg(chat_id, lang_text(chat_id, 'require_sudo'), 'md')
62 | elseif user_need == 2 then
63 | send_msg(chat_id, lang_text(chat_id, 'require_admin'), 'md')
64 | elseif user_need == 1 then
65 | send_msg(chat_id, lang_text(chat_id, 'require_mod'), 'md')
66 | end
67 | end
68 |
69 | function compare_permissions(chat_id, user_id, user_id2)
70 | if user_num(user_id, chat_id) > user_num(user_id2, chat_id) then
71 | return true
72 | else
73 | return false
74 | end
75 | end
76 |
77 | function permissions(user_id, chat_id, plugin_tag, option)
78 | local user_need = get_tag(plugin_tag)
79 | local user_is = user_num(user_id, chat_id)
80 | if user_is >= user_need then
81 | return true
82 | else
83 | if option ~= "silent" then
84 | send_warning(user_id, chat_id, user_need)
85 | end
86 | return false
87 | end
88 | end
89 |
--------------------------------------------------------------------------------
/bot/utils.lua:
--------------------------------------------------------------------------------
1 | serpent = require("serpent")
2 |
3 | --json = (loadfile "./libs/JSON.lua")()
4 |
5 | function dl_cb (arg, data)
6 | vardump (data)
7 | end
8 |
9 | function vardump(value, depth, key)
10 | local linePrefix = ""
11 | local spaces = ""
12 |
13 | if key ~= nil then
14 | linePrefix = "["..key.."] = "
15 | end
16 |
17 | if depth == nil then
18 | depth = 0
19 | else
20 | depth = depth + 1
21 | for i=1, depth do spaces = spaces .. " " end
22 | end
23 |
24 | if type(value) == 'table' then
25 | mTable = getmetatable(value)
26 | if mTable == nil then
27 | print(spaces ..linePrefix.."(table) ")
28 | else
29 | print(spaces .."(metatable) ")
30 | value = mTable
31 | end
32 | for tableKey, tableValue in pairs(value) do
33 | vardump(tableValue, depth, tableKey)
34 | end
35 | elseif type(value) == 'function' or type(value) == 'thread' or type(value) == 'userdata' or value == nil then
36 | print(spaces..tostring(value))
37 | else
38 | print(spaces..linePrefix.."("..type(value)..") "..tostring(value))
39 | end
40 | end
41 |
42 | function ok_cb(extra, success, result)
43 |
44 | end
45 |
46 | function oldtg(data)
47 | if data.message then
48 | local msg = {}
49 | msg.to = {}
50 | msg.from = {}
51 | msg.replied = {}
52 | msg.to.id = data.message.chat_id
53 | msg.from.id = data.message.sender_user_id
54 | if data.message.content._ == "messageText" then
55 | msg.text = data.message.content.text
56 | if #data.message.content.entities ~= 0 then
57 | for k, v in ipairs (data.message.content.entities) do
58 | if v.url_ then
59 | msg.text = msg.text .. " url: " .. v.url_
60 | end
61 | end
62 | end
63 | end
64 | if data.message.content.caption then
65 | msg.text = data.message.content.caption
66 | end
67 | msg.date = data.message.date
68 | msg.id = data.message.id
69 | msg.unread = false
70 | if data.message.reply_to_message_id == 0 then
71 | msg.reply_id = false
72 | else
73 | msg.reply_id = data.message.reply_to_message_id
74 | end
75 | if data.message.content._ == "messagePhoto" then
76 | msg.photo = true
77 | if data.message.content.photo.sizes[3] then
78 | msg.file_id = data.message.content.photo.sizes[3].photo.persistent_id
79 | else
80 | msg.file_id = data.message.content.photo.sizes[0].photo.persistent_id
81 | end
82 | else
83 | msg.photo = false
84 | end
85 | if data.message.content._ == "messageSticker" then
86 | msg.sticker = true
87 | msg.file_id = data.message.content.sticker.sticker.persistent_id
88 | else
89 | msg.sticker = false
90 | end
91 | if data.message.content._ == "messageAudio" then
92 | msg.audio = true
93 | msg.file_id = data.message.content.audio.audio.persistent_id
94 | else
95 | msg.audio = false
96 | end
97 | if data.message.content._ == "messageVoice" then
98 | msg.voice = true
99 | msg.file_id = data.message.content.voice.voice.persistent_id
100 | else
101 | msg.voice = false
102 | end
103 | if data.message.content._ == "messageAnimation" then
104 | msg.gif = true
105 | msg.file_id = data.message.content.animation.animation.persistent_id
106 | else
107 | msg.gif = false
108 | end
109 | if data.message.content._ == "messageVideo" then
110 | msg.video = true
111 | msg.file_id = data.message.content.video.video.persistent_id
112 | else
113 | msg.video = false
114 | end
115 | if data.message.content._ == "messageDocument" then
116 | msg.document = true
117 | msg.file_id = data.message.content.document.document.persistent_id
118 | else
119 | msg.document = false
120 | end
121 | if data.message.content._ == "MessageGame" then
122 | msg.game = true
123 | else
124 | msg.game = false
125 | end
126 | if data.message.forward_info then
127 | msg.forward = true
128 | msg.forward = {}
129 | msg.forward.from_id = data.message.forward_info.sender_user_id
130 | msg.forward.msg_id = data.message.forward_info.data
131 | else
132 | msg.forward = false
133 | end
134 | if data.message.content._ then
135 | msg.action = data.message.content._
136 | end
137 | if data.message.content._ == "messageChatAddMembers" or data.message.content._ == "messageChatDeleteMember" or
138 | data.message.content._ == "messageChatChangeTitle" or data.message.content._ == "messageChatChangePhoto" or
139 | data.message.content._ == "messageChatJoinByLink" or data.message.content._ == "messageGameScore" then
140 | msg.service = true
141 | else
142 | msg.service = false
143 | end
144 | local new_members = data.message.content.members
145 | if new_members then
146 | msg.added = {}
147 | for i = 0, #new_members, 1 do
148 | k = i+1
149 | msg.added[k] = {}
150 | msg.added[k].id = new_members[i].id
151 | if new_members[i].username then
152 | msg.added[k].username = new_members[i].username
153 | else
154 | msg.added[k].username = false
155 | end
156 | msg.added[k].first_name = new_members[i].first_name
157 | if new_members[i].last_name then
158 | msg.added[k].last_name = new_members[i].last_name
159 | else
160 | msg.added[k].last_name = false
161 | end
162 | end
163 | end
164 | return msg
165 | end
166 | return data
167 | end
168 |
169 | function user_data(msg, data)
170 | if data.username then
171 | msg.from.username = data.username
172 | else
173 | msg.from.username = false
174 | end
175 | msg.from.first_name = data.first_name
176 | if data.last_name then
177 | msg.from.last_name = data.last_name
178 | else
179 | msg.from.last_name = false
180 | end
181 | if msg.action == "messageChatJoinByLink" then
182 | msg.added = {}
183 | msg.added[1] = {}
184 | msg.added[1].id = msg.from.id
185 | msg.added[1].username = msg.from.username
186 | msg.added[1].first_name = msg.from.fist_name
187 | msg.added[1].last_name = msg.from.last_name
188 | end
189 | return msg
190 | end
191 |
192 | function reply_data(msg, data)
193 | if data.username then
194 | msg.replied.username = data.username
195 | end
196 | msg.replied.first_name = data.first_name
197 | if data.last_name then
198 | msg.replied.last_name = data.last_name
199 | end
200 | return msg
201 | end
202 |
203 | function return_media(msg)
204 | if msg.photo then
205 | return "MessagePhoto"
206 | elseif msg.sticker then
207 | return "MessageSticker"
208 | elseif msg.audio then
209 | return "MessageAudio"
210 | elseif msg.voice then
211 | return "MessageVoice"
212 | elseif msg.gif then
213 | return "MessageAnimation"
214 | elseif msg.text then
215 | return "MessageText"
216 | elseif msg.service then
217 | return "MessageService"
218 | elseif msg.video then
219 | return "MessageVideo"
220 | elseif msg.document then
221 | return "MessageDocument"
222 | elseif msg.game then
223 | return "MessageGame"
224 | end
225 | end
226 |
227 | function serialize_to_file(data, file, uglify)
228 | file = io.open(file, 'w+')
229 | local serialized
230 | if not uglify then
231 | serialized = serpent.block(data, {
232 | comment = false,
233 | name = '_'
234 | })
235 | else
236 | serialized = serpent.dump(data)
237 | end
238 | file:write(serialized)
239 | file:close()
240 | end
241 |
242 | -- Returns a table with matches or nil
243 | function match_pattern(pattern, text, lower_case)
244 | if text then
245 | local matches = {}
246 | if lower_case then
247 | matches = { string.match(text:lower(), pattern) }
248 | else
249 | matches = { string.match(text, pattern) }
250 | end
251 | if next(matches) then
252 | return matches
253 | end
254 | end
255 | -- nil
256 | end
257 |
258 | function get_receiver(msg)
259 | return msg.to.id
260 |
261 | end
262 |
263 | function getChatId(chat_id)
264 | local chat = {}
265 | local chat_id = tostring(chat_id)
266 |
267 | if chat_id:match('^-100') then
268 | local channel_id = chat_id:gsub('-100', '')
269 | chat = {ID = channel_id, type = 'channel'}
270 | else
271 | local group_id = chat_id:gsub('-', '')
272 | chat = {ID = group_id, type = 'group'}
273 | end
274 |
275 | return chat
276 | end
277 |
278 | function set_text(lang, keyword, text)
279 | local hash = 'lang:'..lang..':'..keyword
280 | redis:set(hash, text)
281 | end
282 |
283 | function is_mod(chat_id, user_id)
284 | return redis:sismember('mods:'..chat_id, user_id)
285 | end
286 |
287 | function is_admin(user_id)
288 | return redis:sismember('admins', user_id)
289 | end
290 |
291 | function is_gban(user_id)
292 | return redis:sismember('gbans', user_id)
293 | end
294 |
295 | function new_is_sudo(user_id)
296 | local var = false
297 | -- Check users id in config
298 | for v,user in pairs(_config.sudo_users) do
299 | if user == user_id then
300 | var = true
301 | end
302 | end
303 | return var
304 | end
305 |
306 | function lang_text(chat_id, keyword)
307 | local hash = 'langset:'..chat_id
308 | local lang = redis:get(hash)
309 | if not lang then
310 | redis:set(hash,'en')
311 | lang = redis:get(hash)
312 | end
313 | local hashtext = 'lang:'..lang..':'..keyword
314 | if redis:get(hashtext) then
315 | return redis:get(hashtext)
316 | else
317 | return 'Please, install your selected "'..lang..'" language by #install [`archive_name(english_lang, spanish_lang...)`]. First, active your language package like a normal plugin by it\'s name. For example, #plugins enable `english_lang`. Or set another one by typing #lang [language(en, es...)].'
318 | end
319 |
320 | end
321 |
322 | function is_number(name_id)
323 | if tonumber(name_id) then
324 | return true
325 | else
326 | return false
327 | end
328 | end
329 |
330 | function no_markdown(text, replace)
331 | if text then
332 | text = tostring(text)
333 | if replace then
334 | text = text:gsub("`", replace)
335 | text = text:gsub("*", replace)
336 | text = text:gsub("_", replace)
337 | return text
338 | end
339 | text = text:gsub("`", "")
340 | text = text:gsub("*", "")
341 | text = text:gsub("_", "")
342 | return text
343 | end
344 | return false
345 | end
346 |
347 | function send_large_msg(chat_id, text)
348 | local text_len = string.len(text)
349 | local text_max = 4096
350 | local times = text_len/text_max
351 | local text = text
352 | for i = 1, times, 1 do
353 | local text = string.sub(text, 1, 4096)
354 | local rest = string.sub(text, 4096, text_len)
355 | local destination = chat_id
356 | local num_msg = math.ceil(text_len / text_max)
357 | if num_msg <= 1 then
358 | send_msg(destination, text, 'md')
359 | else
360 | text = rest
361 | end
362 | end
363 | end
364 |
365 | function scandir(directory)
366 | local i, t, popen = 0, {}, io.popen
367 | for filename in popen('ls -a "'..directory..'"'):lines() do
368 | i = i + 1
369 | t[i] = filename
370 | end
371 | return t
372 | end
373 |
374 | function plugins_names( )
375 | local files = {}
376 | for k, v in pairs(scandir("plugins")) do
377 | -- Ends with .lua
378 | if (v:match(".lua$")) then
379 | table.insert(files, v)
380 | end
381 | end
382 | return files
383 | end
384 |
385 | function langs_names( )
386 | local files = {}
387 | for k, v in pairs(scandir("lang")) do
388 | -- Ends with .lua
389 | if (v:match(".lua$")) then
390 | table.insert(files, v)
391 | end
392 | end
393 | return files
394 | end
395 |
396 | function get_multimatch_byspace(str, regex, cut)
397 | list = {}
398 | for wrd in str:gmatch("%S+") do
399 | if (regex and wrd:match(regex)) then
400 | table.insert(list, wrd:sub(wrd:find(regex)+cut))
401 | elseif (not regex) then
402 | table.insert(list, wrd)
403 | end
404 | end
405 | if (#list > 0) then
406 | return list
407 | end
408 | return false
409 | end
410 |
411 | function trim(text)
412 | local chars_tmp = {}
413 | local chars_m = {}
414 | local final_str = ""
415 | local text_arr = {}
416 | local ok = false
417 | local i
418 | for i=1, #text do
419 | table.insert(chars_tmp, text:sub(i, i))
420 | end
421 | i=1
422 | while(chars_tmp[i]) do
423 | if tostring(chars_tmp[i]):match('%S') then
424 | table.insert(chars_m, chars_tmp[i])
425 | ok = true
426 | elseif ok == true then
427 | table.insert(chars_m, chars_tmp[i])
428 | end
429 | i=i+1
430 | end
431 | i=#chars_m
432 | ok=false
433 | while(chars_m[i]) do
434 | if tostring(chars_m[i]):match('%S') then
435 | table.insert(text_arr, chars_m[i])
436 | ok = true
437 | elseif ok == true then
438 | table.insert(text_arr, chars_m[i])
439 | end
440 | i=i-1
441 | end
442 | for i=#text_arr, 1, -1 do
443 | final_str = final_str..text_arr[i]
444 | end
445 | return final_str
446 | end
447 |
448 | function underline(text, underline_spaces)
449 | local chars = {}
450 | local text_str = ""
451 | local symbol = trim(" ̲")
452 | for i=1, #text do
453 | table.insert(chars, text:sub(i, i))
454 | end
455 | for i=1, #chars do
456 | space = chars[i] == ' '
457 | if (not space) then
458 | text_str = text_str..chars[i]..symbol
459 | elseif (underline_spaces) then
460 | text_str = text_str..chars[i]..symbol
461 | else
462 | text_str = text_str..chars[i]
463 | end
464 | end
465 | return text_str
466 | end
467 |
468 | function up_underline(text, underline_spaces)
469 | local chars = {}
470 | local text_str = ""
471 | local symbol = trim(" ̅ ")
472 | for i=1, #text do
473 | table.insert(chars, text:sub(i, i))
474 | end
475 | for i=1, #chars do
476 | space = chars[i] == ' '
477 | if (not space) then
478 | text_str = text_str..chars[i]..symbol
479 | elseif (underline_spaces) then
480 | text_str = text_str..chars[i]..symbol
481 | else
482 | text_str = text_str..chars[i]
483 | end
484 | end
485 | return text_str
486 | end
487 |
488 | function strike_out(text, underline_spaces)
489 | local chars = {}
490 | local text_str = ""
491 | local symbol = trim(" ̶")
492 | for i=1, #text do
493 | table.insert(chars, text:sub(i, i))
494 | end
495 | for i=1, #chars do
496 | space = chars[i] == ' '
497 | if (not space) then
498 | text_str = text_str..chars[i]..symbol
499 | elseif (underline_spaces) then
500 | text_str = text_str..chars[i]..symbol
501 | else
502 | text_str = text_str..chars[i]
503 | end
504 | end
505 | return text_str
506 | end
507 |
--------------------------------------------------------------------------------
/data/.gitkeep:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/data/spam_data.lua:
--------------------------------------------------------------------------------
1 | return {
2 | blacklist = {
3 | ["default"] = {
4 | "telegram.me/(.*)",
5 | "telegra.ph/(.*)",
6 | "t.me/(.*)",
7 | "@channel"
8 | },
9 | ["links"] = {
10 | "https?://[%w-_%.%?%.:/%+=&]+%S"
11 | }
12 | },
13 |
14 | whitelist = {
15 | ["default"] = {
16 | "@DBTeam",
17 | "@DBTeamES",
18 | "@DBTeamEN"
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/lang/catala_lang.lua:
--------------------------------------------------------------------------------
1 | --------------------------------------------------
2 | -- ____ ____ _____ --
3 | -- | \| _ )_ _|___ ____ __ __ --
4 | -- | |_ ) _ \ | |/ ·__| _ \_| \/ | --
5 | -- |____/|____/ |_|\____/\_____|_/\/\_|v2 --
6 | -- --
7 | -- _____________________________________ --
8 | -- | | --
9 | -- | Traduït per @gtrabal | --
10 | -- |_____________________________________| --
11 | -- --
12 | --------------------------------------------------
13 |
14 | local LANG = 'cat'
15 |
16 | local function run(msg, matches)
17 | if permissions(msg.from.id, msg.to.id, "lang_install") then
18 |
19 | -------------------------
20 | -- Translation version --
21 | -------------------------
22 | set_text(LANG, 'version', '1.0')
23 | set_text(LANG, 'versionExtended', 'Versió de la traducció 1.0')
24 |
25 | -------------
26 | -- Plugins --
27 | -------------
28 |
29 | -- global plugins --
30 | set_text(LANG, 'require_sudo', 'Aquest plugin requereix de permissos sudo.')
31 | set_text(LANG, 'require_admin', 'Aquest plugin requereix permissos admin o superior.')
32 | set_text(LANG, 'require_mod', 'Aquest plugin requereix permissos mod o superior.')
33 |
34 | -- welcome.lua
35 | set_text(LANG, 'weloff', 'Benvinguda activada.')
36 | set_text(LANG, 'welon', 'Benvinguda desactivada.')
37 | set_text(LANG, 'weldefault', 'La benvinguda activada és la que està per defecte.')
38 | set_text(LANG, 'welnew', 'La nova benvinguda assignada és')
39 | set_text(LANG, 'defaultWelcome', 'Benvingut/s $users al grup!')
40 |
41 |
42 | -- stats.lua
43 | set_text(LANG, 'stats', '*Estadistiques del grup*')
44 | set_text(LANG, 'statsCommand', 'Estadístiques')
45 |
46 | -- settings.lua --
47 | set_text(LANG, 'user', 'Usuari')
48 | set_text(LANG, 'isFlooding', '*està fent flood.*')
49 | set_text(LANG, 'isSpamming', '*està fent spam.*')
50 |
51 | set_text(LANG, 'welcomeT', '> Els *missatges de benvinguda* estan ara *activats* en aquest grup.')
52 | set_text(LANG, 'noWelcomeT', '> Els *missatges de benvinguda* estan *desactivats* en aquest grup.')
53 |
54 | set_text(LANG, 'noStickersT', '`>` Els *Stickers* no estan permesos en aquest xat.')
55 | set_text(LANG, 'stickersT', '`>` Els *Stickers* estan permesos en aquest xat.')
56 |
57 | set_text(LANG, 'noTgservicesT', '`>` Els *Serveis de Telegram* estan *silenciats* en aquest grup.')
58 | set_text(LANG, 'tgservicesT', '`>` Els *Serveis de Telegram* són *visibles* en aquest grup.')
59 |
60 | set_text(LANG, 'gifsT', '`>` Els *Gifs* estan *permesos* en aquest grup.')
61 | set_text(LANG, 'noGifsT', '`>` Els *Gifs* *no* estan *permesos* en aquest grup.')
62 |
63 | set_text(LANG, 'photosT', '`>` Les *Fotos* estan *permeses* en aquest grup.')
64 | set_text(LANG, 'noPhotosT', '`>` Les *Fotos* *no* estan *permeses* en aquest grup.')
65 |
66 | set_text(LANG, 'botsT', '`>` Els *Bots* estan *permesos* en aquest grup.')
67 | set_text(LANG, 'noBotsT', '`>` Els *Bots no* estan *permesos* en aquest grup.')
68 |
69 | set_text(LANG, 'arabicT', '`>` L\'*àrab* està *permès* en aquest grup.')
70 | set_text(LANG, 'noArabicT', '`>` L\'*àrab no* està *permès* en aquest grup.')
71 |
72 | set_text(LANG, 'audiosT', '`>` Els *Àudios* estan *permesos* en aquest grup')
73 | set_text(LANG, 'noAudiosT', '`>` Els *Àudios no* estan *permesos* en aquest grup.')
74 |
75 | set_text(LANG, 'documentsT', '`>` Els *Documents* estan *permesos* en aquest grup.')
76 | set_text(LANG, 'noDocumentsT', '`>` Els *Documents no* estan *permesos* en aquest grup.')
77 |
78 | set_text(LANG, 'videosT', '`>` Els *Vídeos* estan *permesos* en aquest grup.')
79 | set_text(LANG, 'noVideosT', '`>` Els *Vídeos no* estan *permesos* en aquest grup.')
80 |
81 | set_text(LANG, 'locationT', '`>` La *Ubicació* està *permesa* en aquest grup.')
82 | set_text(LANG, 'noLocationT', '`>` La *Ubicació no* està *permesa* en aquest grup.')
83 |
84 | set_text(LANG, 'emojisT', '`>` Els *Emojis* estan *permesos* en aquest grup.')
85 | set_text(LANG, 'noEmojisT', '`>` Els *Emojis no* estan *permesos* en aquest grup.')
86 |
87 | set_text(LANG, 'englishT', '`>` El *Anglès* està *permès* en aquest grup.')
88 | set_text(LANG, 'noEnglishT', '`>` El *Anglès* no està *permès* en aquest grup.')
89 |
90 | set_text(LANG, 'inviteT', '`>` Les *Invitacions* estan *permeses* en aquest grup.')
91 | set_text(LANG, 'noInviteT', '`>` Les *Invitacions no* estan *permeses* en aquest grup.')
92 |
93 | set_text(LANG, 'voiceT', '`>` La *Veu* està *permesa* en aquest grup.')
94 | set_text(LANG, 'noVoiceT', '`>` La *Veu no* està *permesa* en aquest grup.')
95 |
96 | set_text(LANG, 'infoT', '`>` Les *Fotos/Títols* estan *permesos* en aquest grup.')
97 | set_text(LANG, 'noInfoT', '`>` Les *Fotos/Títols no* estan *permesos* en aquest grup.')
98 |
99 | set_text(LANG, 'gamesT', '`>` Els *Jocs* estan *permesos* en aquest grup.')
100 | set_text(LANG, 'noGamesT', '`>` Els *Jocs no* estan *permesos* en aquest grup.')
101 |
102 | set_text(LANG, 'spamT', '`>` L\'*Spam* està *permès* en aquest grup.')
103 | set_text(LANG, 'noSpamT', '`>` L\'*Spam no* està *permès* en aquest grup.')
104 | set_text(LANG, 'setSpam', '`>` La llista negra ha estat canviada a ')
105 |
106 | set_text(LANG, 'forwardT', '`>` *Reenviar missatges* està *permès* en aquest grup.')
107 | set_text(LANG, 'noForwardT', '`>` *Reenviar missatges no* està *permès* en aquest grup.')
108 |
109 | set_text(LANG, 'floodT', '`>` El *Flood* està *permès* en aquest grup.')
110 | set_text(LANG, 'noFloodT', '`>` El *Flood no* està *permès* en aquest grup.')
111 |
112 | set_text(LANG, 'floodTime', '`>` El *Temps màxim* de flood ha estat establert en ')
113 | set_text(LANG, 'floodMax', '`>` El *màxim número* de missatges amb flood ha estat establert en ')
114 |
115 | set_text(LANG, 'gSettings', 'Configuració del grup')
116 |
117 | set_text(LANG, 'allowed', 'permès')
118 | set_text(LANG, 'noAllowed', 'no permès')
119 | set_text(LANG, 'noSet', 'no establert')
120 |
121 | set_text(LANG, 'stickers', 'Stickers')
122 | set_text(LANG, 'tgservices', 'Serveis de Telegram')
123 | set_text(LANG, 'links', 'Enllaços')
124 | set_text(LANG, 'arabic', 'Àrab')
125 | set_text(LANG, 'bots', 'Bots')
126 | set_text(LANG, 'gifs', 'Gifs')
127 | set_text(LANG, 'photos', 'Fotos')
128 | set_text(LANG, 'audios', 'Àudios')
129 | set_text(LANG, 'kickme', 'Autoexpulsió')
130 | set_text(LANG, 'spam', 'Spam')
131 | set_text(LANG, 'gName', 'Nom del grup')
132 | set_text(LANG, 'flood', 'Flood')
133 | set_text(LANG, 'language', 'Idioma')
134 | set_text(LANG, 'mFlood', 'Límit de flood')
135 | set_text(LANG, 'tFlood', 'Temps de flood')
136 | set_text(LANG, 'setphoto', 'Establir foto')
137 |
138 | set_text(LANG, 'forward', 'Reenviar')
139 | set_text(LANG, 'videos', 'Vídeos')
140 | set_text(LANG, 'invite', 'Invitació')
141 | set_text(LANG, 'games', 'Jocs')
142 | set_text(LANG, 'documents', 'Documents')
143 | set_text(LANG, 'location', 'Ubicació')
144 | set_text(LANG, 'voice', 'Veu')
145 | set_text(LANG, 'icontitle', 'Canviar icona/títol')
146 | set_text(LANG, 'english', 'Anglès')
147 | set_text(LANG, 'emojis', 'Emojis')
148 | --Made with @TgTextBot by @iicc1
149 | set_text(LANG, 'groupSettings', 'Configuració del grup')
150 | set_text(LANG, 'allowedMedia', 'Multimèdia Permesa')
151 | set_text(LANG, 'settingsText', 'T̲e̲x̲t̲')
152 |
153 | set_text(LANG, 'langUpdated', 'El seu idioma ha estat actualitzat a: ')
154 |
155 | set_text(LANG, 'linkSet', '`>` El *Nou link* ha estat *establert*')
156 | set_text(LANG, 'linkError', '`>` Necessita els *permíssos de creador* per a exportar el link d\'invitació del grup.')
157 |
158 | set_text(LANG, 'newRules', '`>` Les *Noves normes* han estat *creades.*')
159 | set_text(LANG, 'rulesDefault', '`>` Les *anteriors normes* han estat *eliminades.*')
160 | set_text(LANG, 'noRules', '`>` *No hi ha normes* en aquest grup.')
161 | set_text(LANG, 'defaultRules', '*Normes del grup:*\n`>` No fer flood.\n`>` No fer spam.\n`>` Intenti romandre en aquest tema.\n`>` Prohibit qualsevol contingut racista, pornogràfic, gore...\n\n_L\'incompliment de les normes establertes poden comportar el ban del grup ._')
162 |
163 | set_text(LANG, 'delAll', '`>` Tots els missatges han estat *eliminats*.')
164 |
165 | -- export_gban.lua --
166 | set_text(LANG, 'accountsGban', 'comptes globalment banejades.')
167 |
168 | -- promote.lua --
169 | set_text(LANG, 'alreadyAdmin', 'Aquest usuari ja és *admin.*')
170 | set_text(LANG, 'alreadyMod', 'Aquest usuari ja és *mod.*')
171 |
172 | set_text(LANG, 'newAdmin', '>
Nou admin')
173 | set_text(LANG, 'newMod', '>
Nou mod')
174 | set_text(LANG, 'nowUser', ' ara és un usuari.')
175 |
176 | set_text(LANG, 'modList', '`>` *Llista de Mods*')
177 | set_text(LANG, 'adminList', '`>` *Llista d\'Admins')
178 | set_text(LANG, 'modEmpty', '*La llista de mods està buida* en aquest grup.')
179 | set_text(LANG, 'adminEmpty', '*La lista d\'admins està buida*.')
180 | set_text(LANG, 'error1', 'Error: ha de ser un supergrup.')
181 | set_text(LANG, 'error2', 'Error: ha de ser un supergrup i admin del grup.')
182 | set_text(LANG, 'banall', 'Probant de banejar tots els usuaris...')
183 | set_text(LANG, 'setAbout', 'Sobre el grup ha estat canviat a: ')
184 | set_text(LANG, 'leave', 'Adeu!')
185 |
186 |
187 | -- gban.lua --
188 | set_text(LANG, 'gbans', 'Usuaris bannejats globalment (')
189 | set_text(LANG, 'gbanLua', ' usuaris globalment bannejats de l\'arxiu LUA!')
190 | set_text(LANG, 'gbanJson', ' usuaris globalment bannejats de l\'arxiu JSON!')
191 | set_text(LANG, 'gbanDel', 'Base de dades dels Gbans eliminats.')
192 |
193 | -- id.lua --
194 | set_text(LANG, 'user', 'Usuari')
195 | set_text(LANG, 'chatName', 'Nom del grup')
196 | set_text(LANG, 'chat', 'Xat')
197 | set_text(LANG, 'userID', '*ID de l\'usuari*')
198 | set_text(LANG, 'chatID', '*ID del grup:*')
199 |
200 | -- moderation.lua --
201 | set_text(LANG, 'kickUser', '`>` L\'usuari `$id` ha estat *expulsat.*')
202 | set_text(LANG, 'banUser', '`>` L\'usuari `$id` ha estat *bannejat.*')
203 | set_text(LANG, 'unbanUser', '`>` L\'usuari `$id` ha estat *eliminat* de la llista de *bannejats.*')
204 | set_text(LANG, 'gbanUser', '`>` L\'usuari `$id` ha estat *globalment bannejat*.')
205 | set_text(LANG, 'ungbanUser', '`>` L\'usuari `$id` ha estat *eliminat* de la *llista de bannejats globalment.*')
206 | set_text(LANG, 'muteUser', '`>` L\'usuari `$id` ha estat *sil·lenciat.*')
207 | set_text(LANG, 'muteChat', '`>` El grup ha estat *sil·lenciat.*')
208 | set_text(LANG, 'muteChatSec', '`>` El chat ha estat *sil·lenciat* durant ')
209 | set_text(LANG, 'muteUserSec', '`>` L\'usuari `$id` ha estat *sil·lenciat* per ')
210 | set_text(LANG, 'unmuteUser', '`>` L\'usuari `$id` *pot parlar ara.*')
211 | set_text(LANG, 'unmuteChat', '`>` Els usuaris *poden parlar ara.*')
212 |
213 | set_text(LANG, 'delXMsg', '`>` A l\'usuari $user se li *ha eliminat* `$num messages`.')
214 |
215 | -- commands.lua --
216 | set_text(LANG, 'commandsT', 'Ordres')
217 | set_text(LANG, 'errorNoPlug', 'Aquest plugin no existeix o no té ordres.')
218 |
219 | -- plugins.lua --
220 |
221 | set_text(LANG, 'pluginsActivated', '*Plugins activats:*\n')
222 | set_text(LANG, 'pluginNoExist', '`>` El *Plugin* $name *no existeix*.')
223 | set_text(LANG, 'pluginIsEnabled', '`>` El *plugin* està *actualment activat*.')
224 | set_text(LANG, 'pluginNoEnabled', '`>` El *plugin* està *actualment desactivat*.')
225 | set_text(LANG, 'pluginsReload', '`>` *Plugins recarregats!*')
226 |
227 | set_text(LANG, 'pluginEnabled', '`>` El *plugin* ha estat *activat*.')
228 | set_text(LANG, 'pluginDisabled', '`>` El *plugin* ha estat *desactivat*.')
229 |
230 | -- private.lua--
231 |
232 | set_text(LANG, 'privateMSG', '`>` Perdona, aquesta ordre només funciona *en un xat privat amb el bot.*')
233 | set_text(LANG, 'privateError', '`>` Hi ha hagut un error.')
234 | set_text(LANG, 'privateSuper', '`>` Grup creat, emigrat a supergrup i promogut a admin!')
235 |
236 | ------------
237 | -- Usages --
238 | ------------
239 |
240 | -- commands.lua --
241 | set_text(LANG, 'commands:0', 2)
242 | set_text(LANG, 'commands:1', '#commands: Mostra les ordres de tots els plugins.')
243 | set_text(LANG, 'commands:2', '#commands [plugin]: Ordres d\'aquest plugin.')
244 |
245 | -- export_gban.lua --
246 | -- set_text(LANG, 'export_gban:0', 2)
247 | -- set_text(LANG, 'export_gban:1', '#gbans installer: Devuelve un archivo lua instalador para compartir gbans y añadirlos en otro bot con un único comando.')
248 | -- set_text(LANG, 'export_gban:2', '#gbans list: Devuelve un archivo con la lista de gbans.')
249 |
250 | -- gban_installer.lua --
251 | -- set_text(LANG, 'gban_installer:0', 1)
252 | -- set_text(LANG, 'gban_installer:1', '#install gbans: añade una lista de gbans en tu base de datos redis.')
253 |
254 | -- welcome.lua --
255 | set_text(LANG, 'welcome:0', 3)
256 | set_text(LANG, 'welcome:1', '#setwelcome [Text de benvinguda]. Pot realitzar una benvinguda personalitzada per aquest grup. Posa-hi un "0" per establir la benvinguda predeterminada.')
257 | set_text(LANG, 'welcome:2', '#getwelcome - Retorna la benvinguda actual en aquest grup')
258 | set_text(LANG, 'welcome:3', '#welcome on/off - Activar/desactivar la benvinguda en aquest grup')
259 |
260 | -- giverank.lua --
261 | set_text(LANG, 'promote:0', 6)
262 | set_text(LANG, 'promote:1', '#admin (reply): Afegeix la persona a la que respons en admin')
263 | set_text(LANG, 'promote:2', '#admin /: Afegeix un admin amb el seu ID/Usuari.')
264 | set_text(LANG, 'promote:3', '#mod (reply): Afegeix la persona a la que respons en mod.')
265 | set_text(LANG, 'promote:4', '#mod /: Afegeix un mod amb el seu ID/Usuari.')
266 | set_text(LANG, 'promote:5', '#user (reply): Converteix a la persona a la que respons en usuari.')
267 | set_text(LANG, 'promote:6', '#user /: Converteix un usuari mitjançant el seu ID/Usuari a usuari normal.')
268 |
269 | -- id.lua --
270 | set_text(LANG, 'id:0', 1)
271 | set_text(LANG, 'id:1', '#id (or reply): retorna la teva id i la del grup si estas a dins d\'un.')
272 |
273 | -- moderation.lua --
274 | set_text(LANG, 'moderation:0', 7)
275 | set_text(LANG, 'moderation:1', '#kick //: L\'usuari serà eliminat del grup actual.')
276 | set_text(LANG, 'moderation:2', '#ban //: L\'usuari serà bloquejat del grup actual i no podrà tornar.')
277 | set_text(LANG, 'moderation:3', '#unban //: L\'usuari quedarà desbloquejat al grup actual.')
278 | set_text(LANG, 'moderation:4', '#gban //: L\'usuari serà bloquejat de tots els xats i no podrà entrar.')
279 | set_text(LANG, 'moderation:5', '#ungban //: L\'usuari serà desbloquejat de tots els grups.')
280 | set_text(LANG, 'moderation:6', '#mute //: L\'usuari se sil·lenciarà del grup actual, borrant tots els seus missatges.')
281 | set_text(LANG, 'moderation:7', '#unmute //: L\'usuari podrà parlar al grup actual.')
282 |
283 | -- settings.lua --
284 | set_text(LANG, 'settings:0', 20)
285 | set_text(LANG, 'settings:1', '#tgservices on/off: Quan estigui inhabilitat, s\'esborrarà tots els missatges dels serveis de Telegram.')
286 | set_text(LANG, 'settings:2', '#invite on/off: Quan estigui inhabilitat, tots els nous membres convidats estaran eliminats.')
287 | set_text(LANG, 'settings:3', '#lang : Canvia el idioma del bot.')
288 | set_text(LANG, 'settings:4', '#photos on/off: Quan s\'inhabilita, es borraran totes les fotos.')
289 | set_text(LANG, 'settings:5', '#videos on/off: Quan estigui inhabilitat, tots els vídeos s\'esborraran.')
290 | set_text(LANG, 'settings:6', '#stickers on/off: Quan estigui inhabilitat, tots els stickers s\'esborraran.')
291 | set_text(LANG, 'settings:7', '#gifs on/off: Quan estigui inhabilitat, tots els gifs s\'esborraran.')
292 | set_text(LANG, 'settings:8', '#voice on/off: Quan estigui inhabilitat, tots els missatges de veu s\'esborraran.')
293 | set_text(LANG, 'settings:9', '#audios on/off: Quan estigui inhabilitat, tots els àudios s\'esborraran.')
294 | set_text(LANG, 'settings:10', '#documents on/off: Quan estigui inhabilitat, tots els documents s\'esborraran.')
295 | set_text(LANG, 'settings:11', '#location on/off: Quan estigui inhabilitat, totes les ubicacions s\'esborraran.')
296 | set_text(LANG, 'settings:12', '#games on/off: Quan estigui inhabilitat, tots els jocs s\'esborraran.')
297 | set_text(LANG, 'settings:13', '#spam on/off: Quan estigui inhabilitat, tots l\'spam s\'esborrarà.')
298 | set_text(LANG, 'settings:14', '#forward on/off: Quan estigui inhabilitat, tots els missatges reenviats s\'esborraran.')
299 | set_text(LANG, 'settings:15', '#floodtime : Estableix el temps que el bot utilitza per a comprovar el flood. Escriu 0 per a desactivar.')
300 | set_text(LANG, 'settings:16', '#maxflood : Estableix el màxim nombre de missatges en un temps de flood per a ser considerat com a tal. Escriu 0 per a desactivar.')
301 | set_text(LANG, 'settings:17', '#links on/off: Quan estigui inhabilitat, tots els enllaços s\'esborraran.')
302 | set_text(LANG, 'settings:18', '#arabic on/off: Quan estigui inhabilitat, tots els missatges escrits en àrab/persa s\'esborraran.')
303 | set_text(LANG, 'settings:19', '#english on/off: Quan estigui inhabilitat, tots els missatges escrits en anglès s\'esborraran.')
304 | set_text(LANG, 'settings:20', '#emoji on/off: Quan estigui inhabilitat, tots els missatges amb emojis s\'esborraran.')
305 | -- set_text(LANG, 'settings:5', '#bots on/off: Cuando está inhabilitado, si alguien añade un bot, se pateará.')
306 |
307 | if matches[1] == 'install' then
308 | return '`>` L\'idioma *català* ha estat instal·lat a la seva base de dates.'
309 | elseif matches[1] == 'update' then
310 | return '`>` L\'idioma *català* ha estat actualitzat a la seva base de dates.'
311 | end
312 | else
313 | return "`>` Aquest plugin *requereix de permissos sudo*."
314 | end
315 | end
316 |
317 | return {
318 | patterns = {
319 | '[!/#](install) (catala_lang)$',
320 | '[!/#](update) (catala_lang)$'
321 | },
322 | run = run
323 | }
324 |
--------------------------------------------------------------------------------
/lang/english_lang.lua:
--------------------------------------------------------------------------------
1 | --------------------------------------------------
2 | -- ____ ____ _____ --
3 | -- | \| _ )_ _|___ ____ __ __ --
4 | -- | |_ ) _ \ | |/ ·__| _ \_| \/ | --
5 | -- |____/|____/ |_|\____/\_____|_/\/\_|v2 --
6 | -- --
7 | --------------------------------------------------
8 |
9 | local LANG = 'en'
10 |
11 | local function run(msg, matches)
12 | if permissions(msg.from.id, msg.to.id, "lang_install") then
13 |
14 | -------------------------
15 | -- Translation version --
16 | -------------------------
17 | set_text(LANG, 'version', '2.0')
18 | set_text(LANG, 'versionExtended', 'Translation version 2.0')
19 |
20 | -------------
21 | -- Plugins --
22 | -------------
23 |
24 | -- global plugins --
25 | set_text(LANG, 'require_sudo', 'This plugin requires sudo privileges.')
26 | set_text(LANG, 'require_admin', 'This plugin requires admin privileges or higher.')
27 | set_text(LANG, 'require_mod', 'This plugin requires mod privileges or higher.')
28 |
29 | -- welcome.lua
30 | set_text(LANG, 'weloff', 'Welcome enabled.')
31 | set_text(LANG, 'welon', 'Welcome disabled.')
32 | set_text(LANG, 'weldefault', 'The welcome is the default.')
33 | set_text(LANG, 'welnew', 'Welcome saved! Actual welcome:\n')
34 | set_text(LANG, 'defaultWelcome', 'Welcome $users to the chat!')
35 |
36 | -- stats.lua
37 | set_text(LANG, 'stats', '*Chat stats*')
38 |
39 | -- settings.lua --
40 | set_text(LANG, 'user', 'User')
41 | set_text(LANG, 'isFlooding', '*is flooding.*')
42 | set_text(LANG, 'isSpamming', '*is spamming.*')
43 |
44 | set_text(LANG, 'welcomeT', '> *Welcome messages* are now *enabled* in this chat.')
45 | set_text(LANG, 'noWelcomeT', '> *Welcome messages* are *disabled* in this chat.')
46 |
47 | set_text(LANG, 'noStickersT', '`>` *Stickers* are *not allowed* in this chat.')
48 | set_text(LANG, 'stickersT', '`>` *Stickers* are now *allowed* in this chat.')
49 |
50 | set_text(LANG, 'noTgservicesT', '`>` *Telegram services disabled* in this chat.')
51 | set_text(LANG, 'tgservicesT', '`>` *Telegram services enabled* in this chat.')
52 |
53 | set_text(LANG, 'gifsT', '`>` *Gifs* are now *allowed* in this chat.')
54 | set_text(LANG, 'noGifsT', '`>` *Gifs* are *not allowed* in this chat.')
55 |
56 | set_text(LANG, 'photosT', '`>` *Photos* are now `allowed` in this chat.')
57 | set_text(LANG, 'noPhotosT', '`>` *Photos* are *not allowed* in this chat.')
58 |
59 | set_text(LANG, 'botsT', '`>` *Bots* are now allowed in this chat.')
60 | set_text(LANG, 'noBotsT', '`>` Bots are not allowed in this chat.')
61 |
62 | set_text(LANG, 'arabicT', '`>` *Arabic* is now *allowed* in this chat.')
63 | set_text(LANG, 'noArabicT', '`>` *Arabic* is *not allowed* in this chat.')
64 |
65 | set_text(LANG, 'audiosT', '`>` *Audios* are now *allowed* in this chat.')
66 | set_text(LANG, 'noAudiosT', '`>` *Audios* are *not allowed* in this chat.')
67 |
68 | set_text(LANG, 'documentsT', '`>` *Documents* are now *allowed* in this chat.')
69 | set_text(LANG, 'noDocumentsT', '`>` *Documents* are *not allowed* in this chat.')
70 |
71 | set_text(LANG, 'videosT', '`>` *Videos* are now *allowed* in this chat.')
72 | set_text(LANG, 'noVideosT', '`>` *Videos* are *not allowed* in this chat.')
73 |
74 | set_text(LANG, 'locationT', '`>` *Location* is now *allowed* in this chat.')
75 | set_text(LANG, 'noLocationT', '`>` *Location* is *not allowed* in this chat.')
76 |
77 | set_text(LANG, 'emojisT', '`>` *Emojis* are now *allowed* in this chat.')
78 | set_text(LANG, 'noEmojisT', '`>` *Emojis* are *not allowed* in this chat.')
79 |
80 | set_text(LANG, 'englishT', '`>` *English* is now *allowed* in this chat.')
81 | set_text(LANG, 'noEnglishT', '`>` *English* is *not allowed* in this chat.')
82 |
83 | set_text(LANG, 'inviteT', '`>` *Invite* is now *allowed* in this chat.')
84 | set_text(LANG, 'noInviteT', '`>` *Invite* is *not allowed* in this chat.')
85 |
86 | set_text(LANG, 'voiceT', '`>` *Voice messages* are now *allowed* in this chat.')
87 | set_text(LANG, 'noVoiceT', '`>` *Voice messages* are *not allowed* in this chat.')
88 |
89 | set_text(LANG, 'infoT', '`>` *Photo/title* can be changed in this chat.')
90 | set_text(LANG, 'noInfoT', '`>` *Photo/title* can\'t be changed in this chat.')
91 |
92 | set_text(LANG, 'gamesT', '`>` *Games* are now *allowed* in this chat.')
93 | set_text(LANG, 'noGamesT', '`>` *Games* are *not allowed* in this chat.')
94 |
95 | set_text(LANG, 'spamT', '`>` *Spam* is now *allowed* in this chat.')
96 | set_text(LANG, 'noSpamT', '`>` *Spam* is *not allowed* in this chat.')
97 | set_text(LANG, 'setSpam', '`>` Changed blacklist to ')
98 |
99 | set_text(LANG, 'forwardT', '`>` *Forward messages* is now *allowed* in this chat.')
100 | set_text(LANG, 'noForwardT', '`>` *Forward messages* is not *allowed* in this chat.')
101 |
102 | set_text(LANG, 'floodT', '`>` *Flood* is now *allowed* in this chat.')
103 | set_text(LANG, 'noFloodT', '`>` *Flood* is *not allowed* in this chat.')
104 |
105 | set_text(LANG, 'floodTime', '`>` *Flood time* check has been set to ')
106 | set_text(LANG, 'floodMax', '`>` *Max flood* messages have been set to ')
107 |
108 | set_text(LANG, 'gSettings', 'chat settings')
109 |
110 | set_text(LANG, 'allowed', 'allowed')
111 | set_text(LANG, 'noAllowed', 'not allowed')
112 | set_text(LANG, 'noSet', 'not set')
113 |
114 | set_text(LANG, 'stickers', 'Stickers')
115 | set_text(LANG, 'tgservices', 'Tg services')
116 | set_text(LANG, 'links', 'Links')
117 | set_text(LANG, 'arabic', 'Arabic')
118 | set_text(LANG, 'bots', 'Bots')
119 | set_text(LANG, 'gifs', 'Gifs')
120 | set_text(LANG, 'photos', 'Photos')
121 | set_text(LANG, 'audios', 'Audios')
122 | set_text(LANG, 'kickme', 'Kickme')
123 | set_text(LANG, 'spam', 'Spam')
124 | set_text(LANG, 'gName', 'Group Name')
125 | set_text(LANG, 'flood', 'Flood')
126 | set_text(LANG, 'language', 'Language')
127 | set_text(LANG, 'mFlood', 'Max flood')
128 | set_text(LANG, 'tFlood', 'Flood time')
129 | set_text(LANG, 'setphoto', 'Set photo')
130 |
131 | set_text(LANG, 'forward', 'Forward')
132 | set_text(LANG, 'videos', 'Videos')
133 | set_text(LANG, 'invite', 'Invite')
134 | set_text(LANG, 'games', 'Games')
135 | set_text(LANG, 'documents', 'Documents')
136 | set_text(LANG, 'location', 'Location')
137 | set_text(LANG, 'voice', 'Voice')
138 | set_text(LANG, 'icontitle', 'Change icon/title')
139 | set_text(LANG, 'english', 'English')
140 | set_text(LANG, 'emojis', 'Emojis')
141 | --Made with @TgTextBot by @iicc1
142 | set_text(LANG, 'groupSettings', 'G̲r̲o̲u̲p̲ s̲e̲t̲t̲i̲n̲g̲s̲')
143 | set_text(LANG, 'allowedMedia', 'A̲l̲l̲o̲w̲e̲d̲ m̲e̲d̲i̲a̲')
144 | set_text(LANG, 'settingsText', 'T̲e̲x̲t̲')
145 |
146 | set_text(LANG, 'langUpdated', 'Your language has been updated to: ')
147 |
148 | set_text(LANG, 'linkSet', '`>` *New link* has been *set*')
149 | set_text(LANG, 'linkError', '`>` Need *creator rights* to export chat invite link.')
150 |
151 | set_text(LANG, 'newRules', '`>` *New rules* have been *created.*')
152 | set_text(LANG, 'rulesDefault', '`>` Your previous *rules have been removed.*')
153 | set_text(LANG, 'noRules', '`>` *There are no visible rules* in this group.')
154 |
155 | set_text(LANG, 'defaultRules', '*Chat rules:*\n`>` No Flood.\n`>` No Spam.\n`>` Try to stay on topic.\n`>` Forbidden any racist, sexual, gore content...\n\n_Repeated failure to comply with these rules will cause ban._')
156 |
157 | set_text(LANG, 'delAll', '`>` All messages *cleared*.')
158 |
159 | -- export_gban.lua --
160 | set_text(LANG, 'accountsGban', 'accounts globally banned.')
161 |
162 | -- promote.lua --
163 | set_text(LANG, 'alreadyAdmin', 'This user is already *admin.*')
164 | set_text(LANG, 'alreadyMod', 'This user is already *mod.*')
165 |
166 | set_text(LANG, 'newAdmin', '>
New admin')
167 | set_text(LANG, 'newMod', '>
New mod')
168 | set_text(LANG, 'nowUser', ' is now an user.')
169 |
170 | set_text(LANG, 'modList', '`>` *Mods list*')
171 | set_text(LANG, 'adminList', '`>` *Admins list')
172 | set_text(LANG, 'modEmpty', '*Mod list is empty* in this chat.')
173 | set_text(LANG, 'adminEmpty', '*Admin list is empty.*')
174 | set_text(LANG, 'error1', 'Error: must be a supergroup.')
175 | set_text(LANG, 'error2', 'Error: must be a supergroup and admin of the chat.')
176 | set_text(LANG, 'banall', 'Trying to ban all users...')
177 | set_text(LANG, 'setAbout', 'About changed to: ')
178 | set_text(LANG, 'leave', 'Bye!')
179 |
180 |
181 | -- gban.lua --
182 | set_text(LANG, 'gbans', 'Globally banned users (')
183 | set_text(LANG, 'gbanLua', ' users globally banned from LUA file!')
184 | set_text(LANG, 'gbanJson', ' users globally banned from JSON file!')
185 | set_text(LANG, 'gbanJson', ' users globally banned from JSON file!')
186 | set_text(LANG, 'gbanDel', 'Gbans database removed.')
187 |
188 | -- id.lua --
189 | set_text(LANG, 'user', 'User')
190 | set_text(LANG, 'chatName', 'Chat Name')
191 | set_text(LANG, 'chat', 'Chat')
192 | set_text(LANG, 'userID', '*User ID:*')
193 | set_text(LANG, 'chatID', '*Chat ID:*')
194 |
195 |
196 | -- moderation.lua --
197 | set_text(LANG, 'kickUser', '`>` The user `$id` has been *kicked out.*')
198 | set_text(LANG, 'banUser', '`>` The user `$id` has been *banned.*')
199 | set_text(LANG, 'unbanUser', '`>` The user `$id` has been *removed* from *ban list.*')
200 | set_text(LANG, 'gbanUser', '`>` The user `$id` has been *globally banned*.')
201 | set_text(LANG, 'ungbanUser', '`>` The user `$id` has been *removed* from *global ban list.*')
202 | set_text(LANG, 'muteUser', '`>` The user `$id` has been *muted.*')
203 | set_text(LANG, 'muteChat', '`>` The chat has been *muted.*')
204 | set_text(LANG, 'muteChatSec', '`>` The chat has been *muted* for ')
205 | set_text(LANG, 'muteUserSec', '`>` The user `$id` has been *muted* for ')
206 | set_text(LANG, 'unmuteUser', '`>` The user `$id` *can talk now.*')
207 | set_text(LANG, 'unmuteChat', '`>` The users *can talk now.*')
208 |
209 | set_text(LANG, 'delXMsg', '`>` User $user *has deleted* `$num messages`.')
210 |
211 | -- commands.lua --
212 | set_text(LANG, 'commandsT', 'Commands')
213 | set_text(LANG, 'errorNoPlug', 'The plugin does not exists or has not usages.')
214 |
215 | -- plugins.lua --
216 |
217 | set_text(LANG, 'pluginsActivated', '*Plugins enabled:*\n')
218 | set_text(LANG, 'pluginNoExist', '`>` *Plugin* $name does *not exist*.')
219 | set_text(LANG, 'pluginIsEnabled', '`>` The *plugin* is *already enabled*.')
220 | set_text(LANG, 'pluginNoEnabled', '`>` The *plugin* is *already disabled*.')
221 | set_text(LANG, 'pluginsReload', '`>` *Plugins reloaded!*')
222 |
223 | set_text(LANG, 'pluginEnabled', '`>` The *plugin* has been *enabled*.')
224 | set_text(LANG, 'pluginDisabled', '`>` The *plugin* has been *disabled*.')
225 |
226 | -- private.lua--
227 |
228 | set_text(LANG, 'privateMSG', '`>` Sorry, this command only works *in a private chat with the bot.*')
229 | set_text(LANG, 'privateError', '`>` An error occuried.')
230 | set_text(LANG, 'privateSuper', '`>` Group created, migrated to supergroup and promoted to admin!')
231 |
232 |
233 | ------------
234 | -- Usages --
235 | ------------
236 |
237 |
238 | -- commands.lua --
239 | set_text(LANG, 'commands:0', 2)
240 | set_text(LANG, 'commands:1', '#commands: Show all commands for every plugin.')
241 | set_text(LANG, 'commands:2', '#commands [plugin]: Commands for that plugin.')
242 |
243 | -- export_gban.lua --
244 | -- set_text(LANG, 'export_gban:0', 2)
245 | -- set_text(LANG, 'export_gban:1', '#gbans installer: Return a lua file installer to share gbans and add those in another bot in just one command.')
246 | -- set_text(LANG, 'export_gban:2', '#gbans list: Return an archive with a list of gbans.')
247 |
248 | -- gban_installer.lua --
249 | -- set_text(LANG, 'gban_installer:0', 1)
250 | -- set_text(LANG, 'gban_installer:1', '#install gbans: add a list of gbans into your redis db.')
251 |
252 | -- welcome.lua --
253 | set_text(LANG, 'welcome:0', 3)
254 | set_text(LANG, 'welcome:1', '#setwelcome [text for welcome]. You can make a custom welcome for this chat. Put a "0" to set the default welcome.')
255 | set_text(LANG, 'welcome:2', '#getwelcome - returns the current welcome in this chat')
256 | set_text(LANG, 'welcome:3', '#welcome on/off - enable/disable welcome in this chat')
257 |
258 | -- giverank.lua --
259 | set_text(LANG, 'promote:0', 6)
260 | set_text(LANG, 'promote:1', '#admin (reply): add admin by reply.')
261 | set_text(LANG, 'promote:2', '#admin /: add admin by user ID/Username.')
262 | set_text(LANG, 'promote:3', '#mod (reply): add mod by reply.')
263 | set_text(LANG, 'promote:4', '#mod /: add mod by user ID/Username.')
264 | set_text(LANG, 'promote:5', '#user (reply): remove admin by reply.')
265 | set_text(LANG, 'promote:6', '#user /: remove admin by user ID/Username.')
266 |
267 | -- id.lua --
268 | set_text(LANG, 'id:0', 1)
269 | set_text(LANG, 'id:1', '#id (or reply): Return your ID and the chat id if you are in one.')
270 |
271 | -- moderation.lua --
272 | set_text(LANG, 'moderation:0', 7)
273 | set_text(LANG, 'moderation:1', '#kick //: the user will be kicked in the current chat.')
274 | set_text(LANG, 'moderation:2', '#ban //: the user will be banned in the current chat and it wont be able to return.')
275 | set_text(LANG, 'moderation:3', '#unban //: the user will be unbanned in the current chat.')
276 | set_text(LANG, 'moderation:4', '#gban //: the user will be banned from all chats and it wont be able to enter.')
277 | set_text(LANG, 'moderation:5', '#ungban //: the user will be unbanned from all chats.')
278 | set_text(LANG, 'moderation:6', '#mute //: the user will be silenced in the current chat, erasing all its messages.')
279 | set_text(LANG, 'moderation:7', '#unmute //: the user will be unsilenced in the current chat.')
280 |
281 | -- settings.lua --
282 | set_text(LANG, 'settings:0', 20)
283 | set_text(LANG, 'settings:1', '#tgservices on/off: when disabled, all telegram service messages will be cleared.')
284 | set_text(LANG, 'settings:2', '#invite on/off: when disabled, all new invited participants will be cleared.')
285 | set_text(LANG, 'settings:3', '#lang : changes the language of the bot.')
286 | set_text(LANG, 'settings:4', '#photos on/off: when disabled, all photos will be cleared.')
287 | set_text(LANG, 'settings:5', '#videos on/off: when disabled, all videos will be cleared.')
288 | set_text(LANG, 'settings:6', '#stickers on/off: when disabled, all stickers will be cleared.')
289 | set_text(LANG, 'settings:7', '#gifs on/off: when disabled, all gifs will be cleared.')
290 | set_text(LANG, 'settings:8', '#voice on/off: when disabled, all voicess will be cleared.')
291 | set_text(LANG, 'settings:9', '#audios on/off: when disabled, all audios will be cleared.')
292 | set_text(LANG, 'settings:10', '#documents on/off: when disabled, all documents will be cleared.')
293 | set_text(LANG, 'settings:11', '#location on/off: when disabled, all locations will be cleared.')
294 | set_text(LANG, 'settings:12', '#games on/off: when disabled, all games will be cleared.')
295 | set_text(LANG, 'settings:13', '#spam on/off: when disabled, all spam messages will be cleared.')
296 | set_text(LANG, 'settings:14', '#forward on/off: when disabled, all forwarded messages will be cleared.')
297 | set_text(LANG, 'settings:15', '#floodtime : set the time that bot uses to check flood. Set 0 to desactivate.')
298 | set_text(LANG, 'settings:16', '#maxflood : set the maximum messages in a floodtime to be considered as flood. Set 0 to desactivate.')
299 | set_text(LANG, 'settings:17', '#links on/off: when disabled, all links will be cleared.')
300 | set_text(LANG, 'settings:18', '#arabic on/off: when disabled, all messages with arabic/persian will be cleared.')
301 | set_text(LANG, 'settings:19', '#english on/off: when disabled, all messages with english letters will be cleared.')
302 | set_text(LANG, 'settings:20', '#emoji on/off: when disabled, all messages with emoji will be cleared.')
303 | -- set_text(LANG, 'settings:5', '#bots on/off: when disabled, if someone adds a bot, it will be kicked.')
304 |
305 | if matches[1] == 'install' then
306 | return '`>` *English* was successfully installed on your bot.'
307 | elseif matches[1] == 'update' then
308 | return '`>` *English* was successfully updated on your bot.'
309 | end
310 | else
311 | return "`>` This plugin *requires sudo* privileged user."
312 | end
313 | end
314 |
315 | return {
316 | patterns = {
317 | '[!/#](install) (english_lang)$',
318 | '[!/#](update) (english_lang)$'
319 | },
320 | run = run
321 | }
322 |
--------------------------------------------------------------------------------
/lang/persian_lang.lua:
--------------------------------------------------------------------------------
1 | --------------------------------------------------
2 | -- ____ ____ _____ --
3 | -- | \| _ )_ _|___ ____ __ __ --
4 | -- | |_ ) _ \ | |/ ·__| _ \_| \/ | --
5 | -- |____/|____/ |_|\____/\_____|_/\/\_|v2 --
6 | -- --
7 | --------------------------------------------------
8 | local LANG = 'fa'
9 |
10 | local function run(msg, matches)
11 | if permissions(msg.from.id, msg.to.id, "lang_install") then
12 | -------------------------
13 | -- Translation version --
14 | -------------------------
15 | set_text(LANG, 'version', '2.0')
16 | set_text(LANG, 'versionExtended', 'ترجمه شده ورژن 2')
17 | -------------
18 | -- Plugins --
19 | -------------
20 | -- global plugins --
21 | set_text(LANG, 'require_sudo', 'فقط براي سودو امکان پذير است.')
22 | set_text(LANG, 'require_admin', 'اين پلاگين براي ادمين يا بالاتر است.')
23 | set_text(LANG, 'require_mod', 'اين پلاگين براي مدير گروه در دسترس ميباشد!.')
24 | -- welcome.lua
25 | set_text(LANG, 'weloff', 'خوش آمد گويي روشن')
26 | set_text(LANG, 'welon', 'خوش آمد گويي خاموش.')
27 | set_text(LANG, 'weldefault', 'خوش امد گويي بصورت پيشفرض')
28 | set_text(LANG, 'welnew', 'پيام خوش آمد گويي تعيين شد به')
29 | set_text(LANG, 'defaultWelcome', 'خوش آمديد $users به گروه')
30 |
31 | -- stats.lua
32 | set_text(LANG, 'stats', '*وضعیت چت*')
33 | set_text(LANG, 'statsCommand', 'وضعیت')
34 |
35 | -- settings.lua --
36 | set_text(LANG, 'user', 'کاربر')
37 | set_text(LANG, 'isFlooding', '*در حال فرستادن پيام هاي مکرر و سريع است*')
38 |
39 | set_text(LANG, 'welcomeT', '> پیام خوش آمد در این گروه فعال شد')
40 | set_text(LANG, 'noWelcomeT', '> پیام خوش آمد در این گروه غیر فعال شد')
41 |
42 | set_text(LANG, 'isSpamming', '*در حال فرستادن هرزنامه است.*')
43 | set_text(LANG, 'noStickersT', '`>` `استيکر مجاز نيست در اين گروه`.')
44 | set_text(LANG, 'stickersT', '`>` استيکر فرستادن در حال حاظر مجاز است.')
45 | set_text(LANG, 'noTgservicesT', '`>` حذف پيام هاي مارکدون غير فعال است.')
46 | set_text(LANG, 'tgservicesT', '`>` حذف پيام هاي مارکدون فعال است.')
47 | set_text(LANG, 'gifsT', '`>` عکس متحرک(گيف) در گروه مجاز است.')
48 | set_text(LANG, 'noGifsT', '`>` ارسال پيام متحرک (گيف)در حال حاظر مجاز نيست.')
49 | set_text(LANG, 'photosT', '`>` فرستادن عکس در حال حاظر مجاز است .')
50 | set_text(LANG, 'noPhotosT', '`>` فرستادن عکس هم اکنون در گروه مجاز نيست')
51 | set_text(LANG, 'botsT', '`>` ورود ربات ها هم اکنون مجاز است در گروه')
52 | set_text(LANG, 'noBotsT', '`>` ورود ربات ها هم اکنون غير مجاز است در گروه.')
53 | set_text(LANG, 'arabicT', '`>` متون عربي يا فارسي هم اکنون مجاز است در گروه.')
54 | set_text(LANG, 'noArabicT', '`>` متون عربي در گروه غير مجاز است.')
55 | set_text(LANG, 'audiosT', '`>` فرستادن صدا هم اکنون مجاز است در گروه.')
56 | set_text(LANG, 'noAudiosT', '`>` فرستادن صدا هم اکنون غير مجاز')
57 | set_text(LANG, 'documentsT', '`>` فرستادن فايل در گروه مجاز است.')
58 | set_text(LANG, 'noDocumentsT', '`>` ارسال صدا در گروه غير مجاز است.')
59 | set_text(LANG, 'videosT', '`>` فرستادن فيلم در گروه مجاز است.')
60 | set_text(LANG, 'noVideosT', '`>` ارسال فيلم در گروه غير مجاز است.')
61 | set_text(LANG, 'locationT', '`>` ارسال مکان هم اکنون در گروه مجاز است.')
62 | set_text(LANG, 'noLocationT', '`>`ارسال مکان هم اکنون در گروه غير مجاز است')
63 | set_text(LANG, 'emojisT', '`>` ارسال ايموجي مجاز است.')
64 | set_text(LANG, 'noEmojisT', '`>` اراسل ايموجي غير مجاز است.')
65 | set_text(LANG, 'englishT', '`>` متون انگليسي در گروه مجاز است')
66 | set_text(LANG, 'noEnglishT', '`>` ارسال متون انگليسي هم اکنون در گروه غير مجاز است.')
67 | set_text(LANG, 'inviteT', '`>` دعوت کردن افراد هم اکنون مجاز است')
68 | set_text(LANG, 'noInviteT', '`>` دعوت کردن افراد هم اکنون غير مجاز است')
69 | set_text(LANG, 'voiceT', '`>` ارسال صداي ضبط شده هم اکنون مجاز است.')
70 | set_text(LANG, 'noVoiceT', '`>` ارسال صداي ظبط شده هم اکنون غير مجاز است .')
71 | set_text(LANG, 'infoT', '`>` عکس گروه را هم اکنون ميتوانيد تغيير دهيد.')
72 | set_text(LANG, 'noInfoT', '`>` عکس گروه را هم اکنون نميتوان تغيير داد')
73 | set_text(LANG, 'gamesT', '`>` شروع بازي انلاين هم اکنون مجاز است.')
74 | set_text(LANG, 'noGamesT', '`>` شروع کردن بازي غير مجاز است.')
75 | set_text(LANG, 'spamT', '`>` ارسال هرزنامه هم اکنون مجاز است.')
76 | set_text(LANG, 'noSpamT', '`>` ارسال هرزنامه هم اکنون غير مجاز است .')
77 | set_text(LANG, 'setSpam', '`>` حساسيت هرزنامه ')
78 | set_text(LANG, 'floodT', '`>` ارسال پيام هاي مکرر مجاز است.')
79 | set_text(LANG, 'forwardT', '`>`*فروارد کردن* پبام در این گروه *غیر مجاز* است.')
80 | set_text(LANG, 'noForwardT', '`>` *فروارد کردن* پبام در این گروه *مجاز* است.')
81 | set_text(LANG, 'noFloodT', '`>` ارسال پيام هاي مکرر غير مجاز است.')
82 | set_text(LANG, 'floodTime', '`>` زمان ارسال پيام مکرر و سريع تغيير يافت به : ')
83 | set_text(LANG, 'floodMax', '`>` حساسيت ارسال پيام مکرر تغير يافت به: ')
84 | set_text(LANG, 'gSettings', 'تنظيمات گروه')
85 | set_text(LANG, 'allowed', 'مجاز')
86 | set_text(LANG, 'noAllowed', 'غير مجاز ')
87 | set_text(LANG, 'noSet', 'تعيين نشده')
88 | set_text(LANG, 'stickers', 'استيکر')
89 | set_text(LANG, 'tgservices', 'سرويس تلگرام')
90 | set_text(LANG, 'links', 'ارسال لينک')
91 | set_text(LANG, 'arabic', 'فارسي و عربي')
92 | set_text(LANG, 'bots', 'ربات ')
93 | set_text(LANG, 'gifs', ' عکس متحرک .|گيف|')
94 | set_text(LANG, 'photos', 'عکس ')
95 | set_text(LANG, 'audios', 'صدا')
96 | set_text(LANG, 'kickme', 'اخراج خود')
97 | set_text(LANG, 'spam', 'هرزنامه')
98 | set_text(LANG, 'gName', 'نام گروه')
99 | set_text(LANG, 'flood', 'پيام مکرر')
100 | set_text(LANG, 'language', 'زبان')
101 | set_text(LANG, 'mFlood', 'حساسيت پيام مکرر')
102 | set_text(LANG, 'tFlood', 'زمان پيام مکرر')
103 | set_text(LANG, 'setphoto', 'تغيير عکس گروه')
104 |
105 | set_text(LANG, 'forward', 'نقل قول')
106 | set_text(LANG, 'videos', 'ويديو')
107 | set_text(LANG, 'invite', 'دعوت')
108 | set_text(LANG, 'games', 'بازي اينلاين')
109 | set_text(LANG, 'documents', 'فايل')
110 | set_text(LANG, 'location', 'مکان')
111 | set_text(LANG, 'voice', 'صداي ظبط شده')
112 | set_text(LANG, 'icontitle', 'تغییر ایکون گروه')
113 | set_text(LANG, 'english', 'متون انگليسي')
114 | set_text(LANG, 'emojis', 'ايموجي')
115 |
116 | --Made with @TgTextBot by @iicc1
117 | set_text(LANG, 'groupSettings', 'تنظيمات گروه')
118 | set_text(LANG, 'allowedMedia', 'رسانه هاي مجاز')
119 | set_text(LANG, 'settingsText', 'متن ')
120 | set_text(LANG, 'langUpdated', 'زبان شما تغيير يافت به : ')
121 |
122 | set_text(LANG, 'linkSet', '`>` *لینک جدید* تنظیم شد')
123 | set_text(LANG, 'linkError', '`>` فقط ایجادکننده گروه میتواند لینک را ایجاد کند!')
124 |
125 |
126 |
127 | set_text(LANG, 'newRules', '`>` *قوانین جدید* ایجاد شد.')
128 | set_text(LANG, 'rulesDefault', '`>` *قوانین قبلی حذف شد*')
129 | set_text(LANG, 'noRules', '`>` قوانینی در این گروه مشخص نشده است.')
130 | set_text(LANG, 'defaultRules', '*قوانین گروه:*\n`>` اسپم ممنوع\n`>` سعی کنید در راستای اهداف گروه پیش بروید\n`>` هرگونه مطالب نژادپرستی، جنسی و... ممنوع\n\n_در صورت رعایت نکردن قوانین از گروه اخراج و مسدود می شوید_')
131 |
132 | set_text(LANG, 'delAll', '`>` تمام پیام ها *پاکسازی* شد.')
133 |
134 | -- export_gban.lua --
135 | set_text(LANG, 'accountsGban', 'کاربران بن گلوبال')
136 | -- promote.lua --
137 | set_text(LANG, 'alreadyAdmin', 'اين کاربر در حال حاظر ادمين ميباشد')
138 | set_text(LANG, 'alreadyMod', 'اين کاربر در حال حاظر مدير ميباشد')
139 | set_text(LANG, 'newAdmin', '>
ادمین جدید')
140 | set_text(LANG, 'newMod', '>
مدیر جدید')
141 | set_text(LANG, 'nowUser', ' در حال حاضر کاربر معمولی است.')
142 | set_text(LANG, 'modList', '`>` *ليست مديران*')
143 | set_text(LANG, 'adminList', '`>` *ليست ادمين ها')
144 | set_text(LANG, 'modEmpty', 'هيچ مديري در اين گروه وجود ندارد .')
145 | set_text(LANG, 'adminEmpty', '*هیچ ادمینی وجود ندارد*')
146 | set_text(LANG, 'error1', 'خطا: باید یک سوپر گروه باید')
147 | set_text(LANG, 'error2', 'خطا:باید یک سوپر گروه و مدیر چت باشد')
148 | set_text(LANG, 'banall', 'تلاش برای مسدود سازی تمام کاربران ...')
149 | set_text(LANG, 'setAbout', 'اطلاعات تغییر کرد به:')
150 | set_text(LANG, 'leave', 'خدانگهدار!')
151 |
152 |
153 | -- gban.lua --
154 | set_text(LANG, 'gbans', 'کاربران مسدود شده به صورت سراسری (')
155 | set_text(LANG, 'gbanLua', ' کاربران مسدود شده به صورت سراسری در فایل LUA')
156 | set_text(LANG, 'gbanJson', ' کاربران مسدود شده به صورت سراسری در فایل Json')
157 | set_text(LANG, 'gbanDel', 'پایگاه داده کاربران مسدود شده سراسری پاکسازی شد!')
158 |
159 | -- id.lua --
160 | set_text(LANG, 'user', 'کابر')
161 | set_text(LANG, 'chatName', 'نام گروه')
162 | set_text(LANG, 'chat', 'گروه')
163 | set_text(LANG, 'userID', '*شناسه کاربر:*')
164 | set_text(LANG, 'chatID', '*شناسه گروه:*')
165 |
166 | -- moderation.lua --
167 | set_text(LANG, 'kickUser', '`>` کاربر اخراج شد')
168 | set_text(LANG, 'banUser', '`>` کابر بن شد و ورودش مسدود شد.')
169 | set_text(LANG, 'unbanUser', '`>` اين کاربر در حال حاظر از ليست مسدود ها خارج شد.')
170 | set_text(LANG, 'gbanUser', '`>` اين کاربر بن جهاني شد و ورودش براي تمام گروه ها که ربات ادمين ان است مسدود شد.')
171 | set_text(LANG, 'ungbanUser', '`>` اين کابر از بن جهاني خارج شد.')
172 | set_text(LANG, 'muteUser', '`>` اين کاربر ديگر قادر به چت کردن نيست')
173 | set_text(LANG, 'muteChat', '`>` اين گروه در حال حاظر در حالت سکوت قرار دارد')
174 | set_text(LANG, 'unmuteUser', '`>` کاربر از ليست سکوت خارج شد و ميتواند صحبت کند.')
175 | set_text(LANG, 'unmuteChat', '`>` گروه از حالت سکوت خارج شد و همه کاربران ميتوانند چت کنند')
176 | set_text(LANG, 'muteChatSec', '`>` گروه در حالت *سکوت* قرار گرفت برای ')
177 | set_text(LANG, 'muteUserSec', '`>` کاربر در حالت *سکوت* قرار گرفت برای ')
178 | set_text(LANG, 'delXMsg', '`>` User $user *has deleted* `$num messages`.')
179 |
180 |
181 | -- commands.lua --
182 | set_text(LANG, 'commandsT', 'دستور ها')
183 | set_text(LANG, 'errorNoPlug', 'اين پلاگين وجود ندارد.')
184 |
185 | -- plugins.lua --
186 |
187 | set_text(LANG, 'pluginsActivated', '*پلاگین فعال شد:*\n')
188 | set_text(LANG, 'pluginNoExist', '`>` *پلاگین* $name *موجود نیست*.')
189 | set_text(LANG, 'pluginIsEnabled', '`>` این *پلاگین* هم اکنون *فعال* است.')
190 | set_text(LANG, 'pluginNoEnabled', '`>` این *پلاگین* هم اکنون *غیر فعال* است.')
191 | set_text(LANG, 'pluginsReload', '`>` *پلاگین ها مجددا بارگذاری شد!*')
192 |
193 | set_text(LANG, 'pluginEnabled', '`>` *پلاگین فعال* شد.')
194 | set_text(LANG, 'pluginDisabled', '`>` *پلاگین غیر فعال* شد.')
195 |
196 | -- private.lua--
197 |
198 | set_text(LANG, 'privateMSG', '`>` متاسفانه این پیغام تنها در خصوصی ربات کار میکند!')
199 | set_text(LANG, 'privateError', '`>` خطایی رخ داد!')
200 | set_text(LANG, 'privateSuper', '`>` گروه ایجاد شد و به سوپر گروه ارتقا یافت')
201 |
202 |
203 |
204 | ------------
205 | -- Usages --
206 | ------------
207 | -- commands.lua --
208 | set_text(LANG, 'commands:0', 2)
209 | set_text(LANG, 'commands:1', '#commands:اين دستور براي ديدن دستورات تمام پلاگين ها ميباشد.')
210 | set_text(LANG, 'commands:2', '#commands [plugin]: براي گرفتن دستورات يک پلاگين.')
211 | -- export_gban.lua --
212 | -- set_text(LANG, 'export_gban:0', 2)
213 | -- set_text(LANG, 'export_gban:1', '#gbans installer: دريافت ليست بن گلوبال به صورت فايل لوا.')
214 | -- set_text(LANG, 'export_gban:2', '#gbans list: ليست تمام بن گلوبال ها.')
215 | -- gban_installer.lua --
216 | -- set_text(LANG, 'gban_installer:0', 1)
217 | -- set_text(LANG, 'gban_installer:1', '#install gbans: يکسان سازي بن گلوبال هاي شما و ربات db.')
218 | -- welcome.lua --
219 | set_text(LANG, 'welcome:0', 3)
220 | set_text(LANG, 'welcome:1', '#setwelcome [text for welcome]. شما ميتوانيد با اين دستور متن خوش آمد گويي را تغيير دهيد.')
221 | set_text(LANG, 'welcome:2', '#getwelcome - دريافت پيام خوش آمد گويي')
222 | set_text(LANG, 'welcome:3', '#welcome on/off - خاموش يا روشن کردن پيام خوش آمد گويي')
223 | -- giverank.lua --
224 | set_text(LANG, 'promote:0', 6)
225 | set_text(LANG, 'promote:1', '#admin (reply): اضافه کردن ادمين با استفاده از ريپلي کردن.')
226 | set_text(LANG, 'promote:2', '#admin /: اضافه کردن ادمين با استفاده از شناسه يا نام کاربري.')
227 | set_text(LANG, 'promote:3', '#mod (reply): اضافه کردن مدير با ريپلي.')
228 | set_text(LANG, 'promote:4', '#mod /: اضافه کردن مدير با استفاده از شناسه يا نام کاربري.')
229 | set_text(LANG, 'promote:5', '#user (reply): حذف ادمين با استفاده از ريپلي.')
230 | set_text(LANG, 'promote:6', '#user /:حذف ادمين با استفاده از شناسه يا نام کاربري.')
231 | -- id.lua --
232 | set_text(LANG, 'id:0', 1)
233 | set_text(LANG, 'id:1', '#id (or reply): دريافت آيدي خود و گروه.')
234 | -- moderation.lua --
235 | set_text(LANG, 'moderation:0', 7)
236 | set_text(LANG, 'moderation:1', '#kick //:حذف کاربر با استفاده از ريپلي يا نام کاربري و شناسه.')
237 | set_text(LANG, 'moderation:2', '#ban //: مسدود کردن کاربران و مجاز نبودن ورود دوباره آنها.')
238 | set_text(LANG, 'moderation:3', '#unban //: رفع مسدوديت يک فرد با استفاده از ريپلي نام کاربري و شناسه.')
239 | set_text(LANG, 'moderation:4', '#gban //: بن جهاني فرد با اسفاده از ريپلي ناسه نام کاربري.')
240 | set_text(LANG, 'moderation:5', '#ungban //: رفع مسدوديت يک فرد .')
241 | set_text(LANG, 'moderation:6', '#mute //: سکوت يک فرد با استفاده از ريپلي شناسه نام کاربري.')
242 | set_text(LANG, 'moderation:7', '#unmute //: رفع حالت سکوت يک فرد.')
243 | -- settings.lua --
244 | set_text(LANG, 'settings:0', 20)
245 | set_text(LANG, 'settings:1', '#tgservices on/off: خاموش يا روشن کردن و حذف تمام پيام هاي تلگرام سرويس گذشته.')
246 | set_text(LANG, 'settings:2', '#invite on/off: خاموش يا روشن کردن و حذف تمام پيام هاي گذشته .')
247 | set_text(LANG, 'settings:3', '#lang : تغيير زبان ربات')
248 | set_text(LANG, 'settings:4', '#photos on/off: خاموش کردن يا روشن کردن و حذف تمام عکس هاي اخير.')
249 | set_text(LANG, 'settings:5', '#videos on/off: خاموش يا روشن کردن و حذف تمام فيلم هاي گذشته.')
250 | set_text(LANG, 'settings:6', '#stickers on/off: روشن يا خاموش کردن مجاز بودن استيکر .')
251 | set_text(LANG, 'settings:7', '#gifs on/off: روشن يا خاموش کردن مجاز بودن ارسال عکس متحرک.')
252 | set_text(LANG, 'settings:8', '#voice on/off: روشن يا خاموش کردن ارسال صداي ضبط شده.')
253 | set_text(LANG, 'settings:9', '#audios on/off: حذف صدا و اهنگ.')
254 | set_text(LANG, 'settings:10', '#documents on/off: حذف فايل.')
255 | set_text(LANG, 'settings:11', '#location on/off:ارسال مکان')
256 | set_text(LANG, 'settings:12', '#games on/off: شروع کردن بازي .')
257 | set_text(LANG, 'settings:13', '#spam on/off: هرزنامه.')
258 | set_text(LANG, 'settings:14', '#forward on/off: قفل کردن فوروارد یا باز کردن')
259 | set_text(LANG, 'settings:15', '#floodtime : تعيين کردن حساسيت زمان فلود.')
260 | set_text(LANG, 'settings:16', '#maxflood : تعيين حساسيت فلود کردن.')
261 | set_text(LANG, 'settings:17', '#links on/off: ارسال لينک.')
262 | set_text(LANG, 'settings:28', '#arabic on/off: زبان عربي.')
263 | set_text(LANG, 'settings:19', '#english on/off: زبان انگليسي.')
264 | set_text(LANG, 'settings:20', '#emoji on/off: ارسال ايموجي.')
265 | -- set_text(LANG, 'settings:5', '#bots on/off: خاموش يا روشن کردن و حذف تمام ربات هاي گروه.')
266 |
267 | if matches[1] == 'install' then
268 | return '`>` زبان فارسي با موفقيت نصب شد.'
269 | elseif matches[1] == 'update' then
270 | return '`>` زبان فارسي با موفقيت بروز رساني شد.'
271 | end
272 | else
273 | return "`>` فقط براي سودو ممکن است."
274 | end
275 | end
276 |
277 | return {
278 | patterns = {
279 | '[!/#](install) (persian_lang)$',
280 | '[!/#](update) (persian_lang)$'
281 | },
282 | run = run
283 | }
284 |
--------------------------------------------------------------------------------
/lang/portuguese_lang.lua:
--------------------------------------------------------------------------------
1 | --------------------------------------------------
2 | -- ____ ____ _____ --
3 | -- | \| _ )_ _|___ ____ __ __ --
4 | -- | |_ ) _ \ | |/ ·__| _ \_| \/ | --
5 | -- |____/|____/ |_|\____/\_____|_/\/\_|v2 --
6 | -- _____________________________________ --
7 | -- | | --
8 | -- | Traduzido por @Wesley_Henr | --
9 | -- |_____________________________________| --
10 | -- --
11 | --------------------------------------------------
12 |
13 | local LANG = 'pt'
14 |
15 | local function run(msg, matches)
16 | if permissions(msg.from.id, msg.to.id, "lang_install") then
17 |
18 | -------------------------
19 | -- Translation version --
20 | -------------------------
21 | set_text(LANG, 'version', '1.0')
22 | set_text(LANG, 'versionExtended', 'Versão da tradução 1.0')
23 |
24 | -------------
25 | -- Plugins --
26 | -------------
27 |
28 | -- global plugins --
29 | set_text(LANG, 'require_sudo', 'Este plugin requer privilégios de sudo.')
30 | set_text(LANG, 'require_admin', 'Este plugin requer privilégios de administrador ou superior.')
31 | set_text(LANG, 'require_mod', 'Este plugin requer privilégios de moderador ou superior.')
32 |
33 | -- welcome.lua
34 | set_text(LANG, 'weloff', 'Bem-vindo ativado.')
35 | set_text(LANG, 'welon', 'Bem-vindo desativado.')
36 | set_text(LANG, 'weldefault', 'O bem-vindo é o padrão.')
37 | set_text(LANG, 'welnew', 'Bem-vindo salvo! é')
38 | set_text(LANG, 'defaultWelcome', 'Bem-vindo $users ao grupo!')
39 |
40 |
41 |
42 | -- stats.lua
43 | set_text(LANG, 'stats', '*Chat stats*')
44 |
45 |
46 | -- settings.lua --
47 | set_text(LANG, 'user', 'User')
48 | set_text(LANG, 'isFlooding', '*is flooding.*')
49 | set_text(LANG, 'isSpamming', '*is spamming.*')
50 |
51 | set_text(LANG, 'welcomeT', '> *Welcome messages* are now *enabled* in this chat.')
52 | set_text(LANG, 'noWelcomeT', '> *Welcome messages* are *disabled* in this chat.')
53 |
54 | set_text(LANG, 'noStickersT', '`>` *Stickers* are *not allowed* in this chat.')
55 | set_text(LANG, 'stickersT', '`>` *Stickers* are now *allowed* in this chat.')
56 |
57 | set_text(LANG, 'noTgservicesT', '`>` *Telegram services disabled* in this chat.')
58 | set_text(LANG, 'tgservicesT', '`>` *Telegram services enabled* in this chat.')
59 |
60 | set_text(LANG, 'gifsT', '`>` *Gifs* are now *allowed* in this chat.')
61 | set_text(LANG, 'noGifsT', '`>` *Gifs* are *not allowed* in this chat.')
62 |
63 | set_text(LANG, 'photosT', '`>` *Photos* are now `allowed` in this chat.')
64 | set_text(LANG, 'noPhotosT', '`>` *Photos* are *not allowed* in this chat.')
65 |
66 | set_text(LANG, 'botsT', '`>` *Bots* are now allowed in this chat.')
67 | set_text(LANG, 'noBotsT', '`>` Bots are not allowed in this chat.')
68 |
69 | set_text(LANG, 'arabicT', '`>` *Arabic* is now *allowed* in this chat.')
70 | set_text(LANG, 'noArabicT', '`>` *Arabic* is *not allowed* in this chat.')
71 |
72 | set_text(LANG, 'audiosT', '`>` *Audios* are now *allowed* in this chat.')
73 | set_text(LANG, 'noAudiosT', '`>` *Audios* are *not allowed* in this chat.')
74 |
75 | set_text(LANG, 'documentsT', '`>` *Documents* are now *allowed* in this chat.')
76 | set_text(LANG, 'noDocumentsT', '`>` *Documents* are *not allowed* in this chat.')
77 |
78 | set_text(LANG, 'videosT', '`>` *Videos* are now *allowed* in this chat.')
79 | set_text(LANG, 'noVideosT', '`>` *Videos* are *not allowed* in this chat.')
80 |
81 | set_text(LANG, 'locationT', '`>` *Location* is now *allowed* in this chat.')
82 | set_text(LANG, 'noLocationT', '`>` *Location* is *not allowed* in this chat.')
83 |
84 | set_text(LANG, 'emojisT', '`>` *Emojis* are now *allowed* in this chat.')
85 | set_text(LANG, 'noEmojisT', '`>` *Emojis* are *not allowed* in this chat.')
86 |
87 | set_text(LANG, 'englishT', '`>` *English* is now *allowed* in this chat.')
88 | set_text(LANG, 'noEnglishT', '`>` *English* is *not allowed* in this chat.')
89 |
90 | set_text(LANG, 'inviteT', '`>` *Invite* is now *allowed* in this chat.')
91 | set_text(LANG, 'noInviteT', '`>` *Invite* is *not allowed* in this chat.')
92 |
93 | set_text(LANG, 'voiceT', '`>` *Voice messages* are now *allowed* in this chat.')
94 | set_text(LANG, 'noVoiceT', '`>` *Voice messages* are *not allowed* in this chat.')
95 |
96 | set_text(LANG, 'infoT', '`>` *Photo/title* can be changed in this chat.')
97 | set_text(LANG, 'noInfoT', '`>` *Photo/title* can\'t be changed in this chat.')
98 |
99 | set_text(LANG, 'gamesT', '`>` *Games* are now *allowed* in this chat.')
100 | set_text(LANG, 'noGamesT', '`>` *Games* are *not allowed* in this chat.')
101 |
102 | set_text(LANG, 'spamT', '`>` *Spam* is now *allowed* in this chat.')
103 | set_text(LANG, 'noSpamT', '`>` *Spam* is *not allowed* in this chat.')
104 | set_text(LANG, 'setSpam', '`>` Changed blacklist to ')
105 |
106 | set_text(LANG, 'forwardT', '`>` *Forward messages* is now *allowed* in this chat.')
107 | set_text(LANG, 'noForwardT', '`>` *Forward messages* is not *allowed* in this chat.')
108 |
109 | set_text(LANG, 'floodT', '`>` *Flood* is now *allowed* in this chat.')
110 | set_text(LANG, 'noFloodT', '`>` *Flood* is *not allowed* in this chat.')
111 |
112 | set_text(LANG, 'floodTime', '`>` *Flood time* check has been set to ')
113 | set_text(LANG, 'floodMax', '`>` *Max flood* messages have been set to ')
114 |
115 | set_text(LANG, 'gSettings', 'chat settings')
116 |
117 | set_text(LANG, 'allowed', 'allowed')
118 | set_text(LANG, 'noAllowed', 'not allowed')
119 | set_text(LANG, 'noSet', 'not set')
120 |
121 | set_text(LANG, 'stickers', 'Stickers')
122 | set_text(LANG, 'tgservices', 'Tg services')
123 | set_text(LANG, 'links', 'Links')
124 | set_text(LANG, 'arabic', 'Arabic')
125 | set_text(LANG, 'bots', 'Bots')
126 | set_text(LANG, 'gifs', 'Gifs')
127 | set_text(LANG, 'photos', 'Photos')
128 | set_text(LANG, 'audios', 'Audios')
129 | set_text(LANG, 'kickme', 'Kickme')
130 | set_text(LANG, 'spam', 'Spam')
131 | set_text(LANG, 'gName', 'Group Name')
132 | set_text(LANG, 'flood', 'Flood')
133 | set_text(LANG, 'language', 'Language')
134 | set_text(LANG, 'mFlood', 'Max flood')
135 | set_text(LANG, 'tFlood', 'Flood time')
136 | set_text(LANG, 'setphoto', 'Set photo')
137 |
138 | set_text(LANG, 'forward', 'Forward')
139 | set_text(LANG, 'videos', 'Videos')
140 | set_text(LANG, 'invite', 'Invite')
141 | set_text(LANG, 'games', 'Games')
142 | set_text(LANG, 'documents', 'Documents')
143 | set_text(LANG, 'location', 'Location')
144 | set_text(LANG, 'voice', 'Voice')
145 | set_text(LANG, 'icontitle', 'Change icon/title')
146 | set_text(LANG, 'english', 'English')
147 | set_text(LANG, 'emojis', 'Emojis')
148 | --Made with @TgTextBot by @iicc1
149 | set_text(LANG, 'groupSettings', 'G̲r̲o̲u̲p̲ s̲e̲t̲t̲i̲n̲g̲s̲')
150 | set_text(LANG, 'allowedMedia', 'A̲l̲l̲o̲w̲e̲d̲ m̲e̲d̲i̲a̲')
151 | set_text(LANG, 'settingsText', 'T̲e̲x̲t̲')
152 |
153 | set_text(LANG, 'langUpdated', 'Your language has been updated to: ')
154 |
155 | set_text(LANG, 'linkSet', '`>` *New link* has been *set*')
156 | set_text(LANG, 'linkError', '`>` Need *creator rights* to export chat invite link.')
157 |
158 | set_text(LANG, 'newRules', '`>` *New rules* have been *created.*')
159 | set_text(LANG, 'rulesDefault', '`>` Your previous *rules have been removed.*')
160 | set_text(LANG, 'noRules', '`>` *There are no visible rules* in this group.')
161 | set_text(LANG, 'defaultRules', '*Chat rules:*\n`>` No Flood.\n`>` No Spam.\n`>` Try to stay on topic.\n`>` Forbidden any racist, sexual, gore content...\n\n_Repeated failure to comply with these rules will cause ban._')
162 |
163 | set_text(LANG, 'delAll', '`>` All messages *cleared*.')
164 |
165 | -- export_gban.lua --
166 | set_text(LANG, 'accountsGban', 'accounts globally banned.')
167 |
168 | -- promote.lua --
169 | set_text(LANG, 'alreadyAdmin', 'Este usuário já é um *admin.*')
170 | set_text(LANG, 'alreadyMod', 'Este usuário já é um *mod.*')
171 |
172 | set_text(LANG, 'newAdmin', '>
New admin')
173 | set_text(LANG, 'newMod', '>
New mod')
174 | set_text(LANG, 'nowUser', ' is now an user.')
175 |
176 | set_text(LANG, 'modList', '`>` *Lista de Moderadores*')
177 | set_text(LANG, 'adminList', '`>` *Lista de Administradores')
178 | set_text(LANG, 'modEmpty', '*Lista de moderadores está vazia* neste grupo.')
179 | set_text(LANG, 'adminEmpty', '*Lista de administradores vazia.*')
180 | set_text(LANG, 'error1', 'Error: must be a supergroup.')
181 | set_text(LANG, 'error2', 'Error: must be a supergroup and admin of the chat.')
182 | set_text(LANG, 'banall', 'Trying to ban all users...')
183 | set_text(LANG, 'setAbout', 'About changed to: ')
184 | set_text(LANG, 'leave', 'Bye!')
185 | -- gban.lua --
186 | set_text(LANG, 'gbans', 'Globally banned users (')
187 | set_text(LANG, 'gbanLua', ' users globally banned from LUA file!')
188 | set_text(LANG, 'gbanJson', ' users globally banned from JSON file!')
189 | set_text(LANG, 'gbanJson', ' users globally banned from JSON file!')
190 | set_text(LANG, 'gbanDel', 'Gbans database removed.')
191 |
192 | -- id.lua --
193 | set_text(LANG, 'user', 'Usuário')
194 | set_text(LANG, 'chatName', 'Nome do Grupo')
195 | set_text(LANG, 'chat', 'Grupo')
196 | set_text(LANG, 'userID', '*User ID:*')
197 | set_text(LANG, 'chatID', '*Chat ID:*')
198 |
199 | -- moderation.lua --
200 | set_text(LANG, 'kickUser', '`>` The user `$id` has been *kicked out.*')
201 | set_text(LANG, 'banUser', '`>` The user `$id` has been *banned.*')
202 | set_text(LANG, 'unbanUser', '`>` The user `$id` has been *removed* from *ban list.*')
203 | set_text(LANG, 'gbanUser', '`>` The user `$id` has been *globally banned*.')
204 | set_text(LANG, 'ungbanUser', '`>` The user `$id` has been *removed* from *global ban list.*')
205 | set_text(LANG, 'muteUser', '`>` The user `$id` has been *muted.*')
206 | set_text(LANG, 'muteChat', '`>` The chat has been *muted.*')
207 | set_text(LANG, 'muteChatSec', '`>` The chat has been *muted* for ')
208 | set_text(LANG, 'muteUserSec', '`>` The user `$id` has been *muted* for ')
209 | set_text(LANG, 'unmuteUser', '`>` The user `$id` *can talk now.*')
210 | set_text(LANG, 'unmuteChat', '`>` The users *can talk now.*')
211 |
212 | set_text(LANG, 'delXMsg', '`>` User $user *has deleted* `$num messages`.')
213 |
214 | -- commands.lua --
215 | set_text(LANG, 'commandsT', 'Comando')
216 | set_text(LANG, 'errorNoPlug', 'Este plugin não existe ou não tem comandos.')
217 |
218 | -- plugins.lua --
219 |
220 | set_text(LANG, 'pluginsActivated', '*Plugins enabled:*\n')
221 | set_text(LANG, 'pluginNoExist', '`>` *Plugin* $name does *not exist*.')
222 | set_text(LANG, 'pluginIsEnabled', '`>` The *plugin* is *already enabled*.')
223 | set_text(LANG, 'pluginNoEnabled', '`>` The *plugin* is *already disabled*.')
224 | set_text(LANG, 'pluginsReload', '`>` *Plugins reloaded!*')
225 |
226 | set_text(LANG, 'pluginEnabled', '`>` The *plugin* has been *enabled*.')
227 | set_text(LANG, 'pluginDisabled', '`>` The *plugin* has been *disabled*.')
228 |
229 | -- private.lua--
230 |
231 | set_text(LANG, 'privateMSG', '`>` Sorry, this command only works *in a private chat with the bot.*')
232 | set_text(LANG, 'privateError', '`>` An error occuried.')
233 | set_text(LANG, 'privateSuper', '`>` Group created, migrated to supergroup and promoted to admin!')
234 |
235 |
236 | ------------
237 | -- Usages --
238 | ------------
239 |
240 |
241 | -- commands.lua --
242 | set_text(LANG, 'commands:0', 2)
243 | set_text(LANG, 'commands:1', '#commands: Show all commands for every plugin.')
244 | set_text(LANG, 'commands:2', '#commands [plugin]: Commands for that plugin.')
245 |
246 | -- export_gban.lua --
247 | -- set_text(LANG, 'export_gban:0', 2)
248 | -- set_text(LANG, 'export_gban:1', '#gbans installer: Return a lua file installer to share gbans and add those in another bot in just one command.')
249 | -- set_text(LANG, 'export_gban:2', '#gbans list: Return an archive with a list of gbans.')
250 |
251 | -- gban_installer.lua --
252 | -- set_text(LANG, 'gban_installer:0', 1)
253 | -- set_text(LANG, 'gban_installer:1', '#install gbans: add a list of gbans into your redis db.')
254 |
255 | -- welcome.lua --
256 | set_text(LANG, 'welcome:0', 3)
257 | set_text(LANG, 'welcome:1', '#setwelcome [text for welcome]. You can make a custom welcome for this chat. Put a "0" to set the default welcome.')
258 | set_text(LANG, 'welcome:2', '#getwelcome - returns the current welcome in this chat')
259 | set_text(LANG, 'welcome:3', '#welcome on/off - enable/disable welcome in this chat')
260 |
261 | -- giverank.lua --
262 | set_text(LANG, 'promote:0', 6)
263 | set_text(LANG, 'promote:1', '#admin (reply): add admin by reply.')
264 | set_text(LANG, 'promote:2', '#admin /: add admin by user ID/Username.')
265 | set_text(LANG, 'promote:3', '#mod (reply): add mod by reply.')
266 | set_text(LANG, 'promote:4', '#mod /: add mod by user ID/Username.')
267 | set_text(LANG, 'promote:5', '#user (reply): remove admin by reply.')
268 | set_text(LANG, 'promote:6', '#user /: remove admin by user ID/Username.')
269 |
270 | -- id.lua --
271 | set_text(LANG, 'id:0', 1)
272 | set_text(LANG, 'id:1', '#id (or reply): Return your ID and the chat id if you are in one.')
273 |
274 | -- moderation.lua --
275 | set_text(LANG, 'moderation:0', 7)
276 | set_text(LANG, 'moderation:1', '#kick //: the user will be kicked in the current chat.')
277 | set_text(LANG, 'moderation:2', '#ban //: the user will be banned in the current chat and it wont be able to return.')
278 | set_text(LANG, 'moderation:3', '#unban //: the user will be unbanned in the current chat.')
279 | set_text(LANG, 'moderation:4', '#gban //: the user will be banned from all chats and it wont be able to enter.')
280 | set_text(LANG, 'moderation:5', '#ungban //: the user will be unbanned from all chats.')
281 | set_text(LANG, 'moderation:6', '#mute //: the user will be silenced in the current chat, erasing all its messages.')
282 | set_text(LANG, 'moderation:7', '#unmute //: the user will be unsilenced in the current chat.')
283 |
284 | -- settings.lua --
285 | set_text(LANG, 'settings:0', 20)
286 | set_text(LANG, 'settings:1', '#tgservices on/off: when disabled, all telegram service messages will be cleared.')
287 | set_text(LANG, 'settings:2', '#invite on/off: when disabled, all new invited participants will be cleared.')
288 | set_text(LANG, 'settings:3', '#lang : changes the language of the bot.')
289 | set_text(LANG, 'settings:4', '#photos on/off: when disabled, all photos will be cleared.')
290 | set_text(LANG, 'settings:5', '#videos on/off: when disabled, all videos will be cleared.')
291 | set_text(LANG, 'settings:6', '#stickers on/off: when disabled, all stickers will be cleared.')
292 | set_text(LANG, 'settings:7', '#gifs on/off: when disabled, all gifs will be cleared.')
293 | set_text(LANG, 'settings:8', '#voice on/off: when disabled, all voicess will be cleared.')
294 | set_text(LANG, 'settings:9', '#audios on/off: when disabled, all audios will be cleared.')
295 | set_text(LANG, 'settings:10', '#documents on/off: when disabled, all documents will be cleared.')
296 | set_text(LANG, 'settings:11', '#location on/off: when disabled, all locations will be cleared.')
297 | set_text(LANG, 'settings:12', '#games on/off: when disabled, all games will be cleared.')
298 | set_text(LANG, 'settings:13', '#spam on/off: when disabled, all spam messages will be cleared.')
299 | set_text(LANG, 'settings:14', '#forward on/off: when disabled, all forwarded messages will be cleared.')
300 | set_text(LANG, 'settings:15', '#floodtime : set the time that bot uses to check flood. Set 0 to desactivate.')
301 | set_text(LANG, 'settings:16', '#maxflood : set the maximum messages in a floodtime to be considered as flood. Set 0 to desactivate.')
302 | set_text(LANG, 'settings:17', '#links on/off: when disabled, all links will be cleared.')
303 | set_text(LANG, 'settings:18', '#arabic on/off: when disabled, all messages with arabic/persian will be cleared.')
304 | set_text(LANG, 'settings:19', '#english on/off: when disabled, all messages with english letters will be cleared.')
305 | set_text(LANG, 'settings:20', '#emoji on/off: when disabled, all messages with emoji will be cleared.')
306 | -- set_text(LANG, 'settings:5', '#bots on/off: when disabled, if someone adds a bot, it will be kicked.')
307 |
308 | if matches[1] == 'install' then
309 | return '`>` *Português* foi instalado com êxito no seu bot.'
310 | elseif matches[1] == 'update' then
311 | return '`>` *Português* foi atualizado com sucesso em seu bot.'
312 | end
313 | else
314 | return "`>` Este plugin *requer* o uso de privilégios *sudo*."
315 | end
316 | end
317 |
318 | return {
319 | patterns = {
320 | '[!/#](install) (portuguese_lang)$',
321 | '[!/#](update) (portuguese_lang)$'
322 | },
323 | run = run
324 | }
325 |
--------------------------------------------------------------------------------
/lang/spanish_lang.lua:
--------------------------------------------------------------------------------
1 | --------------------------------------------------
2 | -- ____ ____ _____ --
3 | -- | \| _ )_ _|___ ____ __ __ --
4 | -- | |_ ) _ \ | |/ ·__| _ \_| \/ | --
5 | -- |____/|____/ |_|\____/\_____|_/\/\_|v2 --
6 | -- --
7 | -- _____________________________________ --
8 | -- | | --
9 | -- |Traducido por la @comunidadtelebots | --
10 | -- |_____________________________________| --
11 | -- --
12 | --------------------------------------------------
13 |
14 | local LANG = 'es'
15 |
16 | local function run(msg, matches)
17 | if permissions(msg.from.id, msg.to.id, "lang_install") then
18 |
19 | -------------------------
20 | -- Translation version --
21 | -------------------------
22 | set_text(LANG, 'version', '1.0')
23 | set_text(LANG, 'versionExtended', 'Versión de la traducción 1.0')
24 |
25 | -------------
26 | -- Plugins --
27 | -------------
28 |
29 | -- global plugins --
30 | set_text(LANG, 'require_sudo', 'Este plugin requiere privilegios sudo.')
31 | set_text(LANG, 'require_admin', 'Este plugin requiere privilegios admin o superior.')
32 | set_text(LANG, 'require_mod', 'Este plugin requiere privilegios mod o superior.')
33 |
34 | -- welcome.lua
35 | set_text(LANG, 'weloff', 'Bienvenida activada.')
36 | set_text(LANG, 'welon', 'Bienvenida desactivada.')
37 | set_text(LANG, 'weldefault', 'La bienvenida actual es la default.')
38 | set_text(LANG, 'welnew', 'La nueva bienvenida asignada es')
39 | set_text(LANG, 'defaultWelcome', 'Bienvenido/s $users al chat!')
40 |
41 |
42 | -- stats.lua
43 | set_text(LANG, 'stats', '*Estadísticas del chat*')
44 |
45 |
46 | -- settings.lua --
47 | set_text(LANG, 'user', 'El usuario')
48 | set_text(LANG, 'isFlooding', '*está haciendo flood.*')
49 | set_text(LANG, 'isSpamming', '*está haciendo spam.*')
50 |
51 | set_text(LANG, 'welcomeT', '> *Mensajes de bienvenida activados* en este chat.')
52 | set_text(LANG, 'noWelcomeT', '> *Mensajes de bienvenida desactivados* en este chat.')
53 |
54 | set_text(LANG, 'noStickersT', '`>` *Stickers* no permitidos en este chat.')
55 | set_text(LANG, 'stickersT', '`>` *Stickers* permitidos en este chat.')
56 |
57 | set_text(LANG, 'noTgservicesT', '`>` *Servicios de Telegram silenciados* en este chat.')
58 | set_text(LANG, 'tgservicesT', '`>` *Servicios de Telegram visibles* en este chat.')
59 |
60 | set_text(LANG, 'gifsT', '`>` *Gifs permitidos* en este chat.')
61 | set_text(LANG, 'noGifsT', '`>` *Gifs no permitidos* en este chat.')
62 |
63 | set_text(LANG, 'photosT', '`>` *Fotos permitidas* en este chat.')
64 | set_text(LANG, 'noPhotosT', '`>` *Fotos no permitidas* en este chat.')
65 |
66 | set_text(LANG, 'botsT', '`>` *Bots permitidos* en este chat.')
67 | set_text(LANG, 'noBotsT', '`>` *Bots no permitidos* en este chat.')
68 |
69 | set_text(LANG, 'arabicT', '`>` El *árabe* está *permitido* en este chat.')
70 | set_text(LANG, 'noArabicT', '`>` El *árabe* *no está permitido* en este chat.')
71 |
72 | set_text(LANG, 'audiosT', '`>` *Audios permitidos* en este chat')
73 | set_text(LANG, 'noAudiosT', '`>` *Audios no permitidos* en este chat.')
74 |
75 | set_text(LANG, 'documentsT', '`>` *Documentos permitidos* en este chat.')
76 | set_text(LANG, 'noDocumentsT', '`>` *Documentos no permitidos* en este chat.')
77 |
78 | set_text(LANG, 'videosT', '`>` *Videos permitidos* en este chat.')
79 | set_text(LANG, 'noVideosT', '`>` *Videos no permitidos* en este chat.')
80 |
81 | set_text(LANG, 'locationT', '`>` *Ubicaciones permitidas* en este chat.')
82 | set_text(LANG, 'noLocationT', '`>` *Ubicaciones no permitidas* en este chat.')
83 |
84 | set_text(LANG, 'emojisT', '`>` *Emojis permitidos* en este chat.')
85 | set_text(LANG, 'noEmojisT', '`>` *Emojis no permitidos* en este chat.')
86 |
87 | set_text(LANG, 'englishT', '`>` *Inglés permitido* en este chat.')
88 | set_text(LANG, 'noEnglishT', '`>` *Inglés no permitido* en este chat.')
89 |
90 | set_text(LANG, 'inviteT', '`>` *Invitaciones permitidas* en este chat.')
91 | set_text(LANG, 'noInviteT', '`>` *Invitaciones no permitidas* en este chat.')
92 |
93 | set_text(LANG, 'voiceT', '`>` *Audios de voz permitidos* en este chat.')
94 | set_text(LANG, 'noVoiceT', '`>` *Audios de voz no permitidos* en este chat.')
95 |
96 | set_text(LANG, 'infoT', '`>` *La foto/título* se puede cambiar en este chat.')
97 | set_text(LANG, 'noInfoT', '`>` *La foto/título* no se puede cambiar en este chat.')
98 |
99 | set_text(LANG, 'gamesT', '`>` *Juegos permitidos* en este chat.')
100 | set_text(LANG, 'noGamesT', '`>` *Juegos no permitidos* en este chat.')
101 |
102 | set_text(LANG, 'spamT', '`>` *Spam permitido* en este chat.')
103 | set_text(LANG, 'noSpamT', '`>` *Spam no permitido* en este chat.')
104 | set_text(LANG, 'setSpam', '`>` Se cambió la lista negra a ')
105 |
106 | set_text(LANG, 'forwardT', '`>` *Reenviar mensajes está permitido* en este chat.')
107 | set_text(LANG, 'noForwardT', '`>` *Reenviar mensajes no está permitido* en este chat.')
108 |
109 | set_text(LANG, 'floodT', '`>` *Flood permitido* en este chat.')
110 | set_text(LANG, 'noFloodT', '`>` *Flood no permitido* en este chat.')
111 |
112 | set_text(LANG, 'floodTime', '`>` *Tiempo máximo de flood* establecido a ')
113 | set_text(LANG, 'floodMax', '`>` *Número máximo de mensajes* para flood establecido a ')
114 |
115 | set_text(LANG, 'gSettings', 'Ajustes del grupo')
116 |
117 | set_text(LANG, 'allowed', 'permitido')
118 | set_text(LANG, 'noAllowed', 'no permitido')
119 | set_text(LANG, 'noSet', 'no establecido')
120 |
121 | set_text(LANG, 'stickers', 'Stickers')
122 | set_text(LANG, 'tgservices', 'Servicios de Telegram')
123 | set_text(LANG, 'links', 'Enlaces')
124 | set_text(LANG, 'arabic', 'Árabe')
125 | set_text(LANG, 'bots', 'Bots')
126 | set_text(LANG, 'gifs', 'Gifs')
127 | set_text(LANG, 'photos', 'Fotos')
128 | set_text(LANG, 'audios', 'Audios')
129 | set_text(LANG, 'spam', 'Spam')
130 | set_text(LANG, 'gName', 'Nombre del grupo')
131 | set_text(LANG, 'flood', 'Flood')
132 | set_text(LANG, 'language', 'Idioma')
133 | set_text(LANG, 'mFlood', 'Límite de flood')
134 | set_text(LANG, 'tFlood', 'Tiempo de flood')
135 | set_text(LANG, 'setphoto', 'Establecer foto')
136 |
137 | set_text(LANG, 'forward', 'Reenviar')
138 | set_text(LANG, 'videos', 'Videos')
139 | set_text(LANG, 'invite', 'Invitación')
140 | set_text(LANG, 'games', 'Juegos')
141 | set_text(LANG, 'documents', 'Documentos')
142 | set_text(LANG, 'location', 'Ubicación')
143 | set_text(LANG, 'voice', 'Voz')
144 | set_text(LANG, 'icontitle', 'Cambiar icono/título')
145 | set_text(LANG, 'english', 'Inglés')
146 | set_text(LANG, 'emojis', 'Emojis')
147 | --Made with @TgTextBot by @iicc1
148 | set_text(LANG, 'groupSettings', 'Configuración del grupo')
149 | set_text(LANG, 'allowedMedia', 'Multimedia Permitidos')
150 | set_text(LANG, 'settingsText', 'T̲e̲x̲t̲o')
151 |
152 | set_text(LANG, 'langUpdated', 'Su idioma ha sido actualizado a: ')
153 |
154 | set_text(LANG, 'linkSet', '`>` Un *nuevo link* ha sido *establecido*')
155 | set_text(LANG, 'linkError', '`>` Se necesita *permisos de creador* para exportar el link de invitación del chat.')
156 |
157 | set_text(LANG, 'newRules', '`>` *Nuevas normas creadas.*')
158 | set_text(LANG, 'rulesDefault', '`>` Tus anteriores *normas han sido eliminadas.*')
159 | set_text(LANG, 'noRules', '`>` *No hay normas visibles* en este grupo.')
160 | set_text(LANG, 'defaultRules', '*Normas del chat:*\n`>` No hacer Flood.\n`>` No hacer Spam.\n`>` Intenta permanecer en el tema.\n`>` Prohibido cualquier contenido racista, sexual, gore......\n\n_El incumplimiento reiterado de estas normas puede comportar el ban._')
161 |
162 | set_text(LANG, 'delAll', '`>` Todos los mensajes han sido *eliminados*.')
163 |
164 | -- export_gban.lua --
165 | set_text(LANG, 'accountsGban', 'cuentas globalmente baneadas.')
166 |
167 | -- promote.lua --
168 | set_text(LANG, 'alreadyAdmin', 'Este usuario ya es *admin.*')
169 | set_text(LANG, 'alreadyMod', 'Este usuario ya es *mod.*')
170 |
171 | set_text(LANG, 'newAdmin', '>
Nuevo admin')
172 | set_text(LANG, 'newMod', '>
Nuevo mod')
173 | set_text(LANG, 'nowUser', ' es ahora un usuario.')
174 |
175 | set_text(LANG, 'modList', '`>` *Lista de Mods*')
176 | set_text(LANG, 'adminList', '`>` *Lista de Admins')
177 | set_text(LANG, 'modEmpty', '*La lista de mods está vacia* en este chat.')
178 | set_text(LANG, 'adminEmpty', '*La lista de admins está vacia*.')
179 | set_text(LANG, 'error1', 'Error: tiene que ser un supergrupo.')
180 | set_text(LANG, 'error2', 'Error: tiene que ser un supergrupo y admin del chat.')
181 | set_text(LANG, 'banall', 'Intentando banear a todos los usuarios...')
182 | set_text(LANG, 'setAbout', 'Bio del bot cambiada a: ')
183 | set_text(LANG, 'leave', 'Adiós!')
184 |
185 |
186 | -- gban.lua --
187 | set_text(LANG, 'gbans', 'Usuarios baneados globalmente (')
188 | set_text(LANG, 'gbanLua', ' usuarios baneados globalmente del archivo LUA!')
189 | set_text(LANG, 'gbanJson', ' usuarios baneados globalmente del archivo JSON!')
190 | set_text(LANG, 'gbanDel', 'Base de datos de los Gbans eliminado.')
191 |
192 | -- id.lua --
193 | set_text(LANG, 'user', 'Usuario')
194 | set_text(LANG, 'chatName', 'Nombre del Chat')
195 | set_text(LANG, 'chat', 'Chat')
196 | set_text(LANG, 'userID', '*ID del usuario:*')
197 | set_text(LANG, 'chatID', '*ID del chat:*')
198 |
199 | -- moderation.lua --
200 | set_text(LANG, 'kickUser', '`>` El usuario `$id` ha sido *expulsado.*')
201 | set_text(LANG, 'banUser', '`>` El usuario `$id` ha sido *baneado.*')
202 | set_text(LANG, 'unbanUser', '`>` El usuario `$id` ha sido *borrado* de la lista *baneados.*')
203 | set_text(LANG, 'gbanUser', '`>` EL usuario `$id` ha sido *baneado globalmente*.')
204 | set_text(LANG, 'ungbanUser', '`>` El usuario `$id` ha sido *borrado* de la *lista de baneados globales. *')
205 | set_text(LANG, 'muteUser', '`>` El usuario `$id` ha sido *silenciado.*')
206 | set_text(LANG, 'muteChat', '`>` El chat ha sido *silenciado.*')
207 | set_text(LANG, 'muteChatSec', '`>` EL chat ha sido *silenciado* durante ')
208 | set_text(LANG, 'muteUserSec', '`>` El usuario `$id` ha sido *silenciado* durante ')
209 | set_text(LANG, 'unmuteUser', '`>` El usuario `$id` *puede hablar ahora.*')
210 | set_text(LANG, 'unmuteChat', '`>` Los usuarios *pueden hablar ahora.*')
211 |
212 | set_text(LANG, 'delXMsg', '`>` Al usuario $user *se le ha eliminado* `$num mensajes`.')
213 |
214 | -- commands.lua --
215 | set_text(LANG, 'commandsT', 'Comandos')
216 | set_text(LANG, 'errorNoPlug', 'Este plugin no existe o no tiene comandos.')
217 |
218 | -- plugins.lua --
219 |
220 | set_text(LANG, 'pluginsActivated', '*Plugins activados:*\n')
221 | set_text(LANG, 'pluginNoExist', '`>` *El plugin* $name *no existe*.')
222 | set_text(LANG, 'pluginIsEnabled', '`>` *El plugin* está *actualmente activado*.')
223 | set_text(LANG, 'pluginNoEnabled', '`>` *El plugin* está *actualmente desactivado*.')
224 | set_text(LANG, 'pluginsReload', '`>` *Plugin recargados!*')
225 |
226 | set_text(LANG, 'pluginEnabled', '`>` El *plugin* ha sido *activado*.')
227 | set_text(LANG, 'pluginDisabled', '`>` El *plugin* ha sido *desactivado*.')
228 |
229 |
230 | -- private.lua--
231 |
232 | set_text(LANG, 'privateMSG', '`>` Perdona, este comando solo funciona *en un chat privado con el bot.*')
233 | set_text(LANG, 'privateError', '`>` Ha habido un error.')
234 | set_text(LANG, 'privateSuper', '`>` Grupo creado, migrado a supergrupo y promoteado a admin!')
235 |
236 |
237 |
238 | ------------
239 | -- Usages --
240 | ------------
241 |
242 | -- commands.lua --
243 | set_text(LANG, 'commands:0', 2)
244 | set_text(LANG, 'commands:1', '#commands: Muestra los comandos para todos los plugins.')
245 | set_text(LANG, 'commands:2', '#commands [plugin]: Comandos para ese plugin.')
246 |
247 | -- export_gban.lua --
248 | -- set_text(LANG, 'export_gban:0', 2)
249 | -- set_text(LANG, 'export_gban:1', '#gbans installer: Devuelve un archivo lua instalador para compartir gbans y añadirlos en otro bot con un único comando.')
250 | -- set_text(LANG, 'export_gban:2', '#gbans list: Devuelve un archivo con la lista de gbans.')
251 |
252 | -- gban_installer.lua --
253 | -- set_text(LANG, 'gban_installer:0', 1)
254 | -- set_text(LANG, 'gban_installer:1', '#install gbans: añade una lista de gbans en tu base de datos redis.')
255 |
256 | -- welcome.lua --
257 | set_text(LANG, 'welcome:0', 3)
258 | set_text(LANG, 'welcome:1', '#setwelcome [Texto para bienvenida]. Puede realizar una bienvenida personalizada para este chat. Ponga un "0" para establecer la recepción predeterminada.')
259 | set_text(LANG, 'welcome:2', '#getwelcome - Devuelve la bienvenida actual en este chat')
260 | set_text(LANG, 'welcome:3', '#welcome on/off - Activar/desactivar la bienvenida en este chat')
261 |
262 | -- giverank.lua --
263 | set_text(LANG, 'promote:0', 6)
264 | set_text(LANG, 'promote:1', '#admin (reply): Convierte la persona a la que respondes en admin')
265 | set_text(LANG, 'promote:2', '#admin /: Añade un admin mediante su ID/Username.')
266 | set_text(LANG, 'promote:3', '#mod (reply): Convierte la persona a la que respondes en mod.')
267 | set_text(LANG, 'promote:4', '#mod /: Añade un mod mediante su ID/Username.')
268 | set_text(LANG, 'promote:5', '#user (reply): Convierte a la persona a la que respondes en usuario.')
269 | set_text(LANG, 'promote:6', '#user /: Convierte un usuario mediante su ID/Usuario a usuario normal.')
270 |
271 | -- id.lua --
272 | set_text(LANG, 'id:0', 1)
273 | set_text(LANG, 'id:1', '#id (or reply): devuelve tu id y la del chat si estás en alguno.')
274 |
275 | -- moderation.lua --
276 | set_text(LANG, 'moderation:0', 7)
277 | set_text(LANG, 'moderation:1', '#kick //: El usuario será eliminado en el chat actual.')
278 | set_text(LANG, 'moderation:2', '#ban //: El usuario será bloqueado en el chat actual y no será capaz de volver.')
279 | set_text(LANG, 'moderation:3', '#unban //: El usuario quedará desbloqueado en el chat actual.')
280 | set_text(LANG, 'moderation:4', '#gban //: El usuario será bloqueado de todos los chats y no será capaz de entrar.')
281 | set_text(LANG, 'moderation:5', '#ungban //: El usuario será desbloqueado de todos los chats.')
282 | set_text(LANG, 'moderation:6', '#mute //: El usuario se silenciará en el chat actual, borrando todos sus mensajes.')
283 | set_text(LANG, 'moderation:7', '#unmute //: el usuario puede hablar en el chat actual.')
284 |
285 | -- settings.lua --
286 | set_text(LANG, 'settings:0', 20)
287 | set_text(LANG, 'settings:1', '#tgservices on/off: Cuando está inhabilitado, se borrarán todos los mensajes de los servicios de telegram.')
288 | set_text(LANG, 'settings:2', '#invite on/off: Cuando está inhabilitado, todos los nuevos participantes invitados serán eliminados.')
289 | set_text(LANG, 'settings:3', '#lang : Cambia el idioma del bot.')
290 | set_text(LANG, 'settings:4', '#photos on/off: Cuando se inhabilita, se borrarán todas las fotos.')
291 | set_text(LANG, 'settings:5', '#videos on/off: Cuando está inhabilitado, todos los videos se borrarán.')
292 | set_text(LANG, 'settings:6', '#stickers on/off: Cuando está inhabilitado, todos las stickers serán borradas.')
293 | set_text(LANG, 'settings:7', '#gifs on/off: Cuando está deshabilitado, todos los gifs se borrarán.')
294 | set_text(LANG, 'settings:8', '#voice on/off: Cuando está deshabilitado, todos los mensajes de voz serán borrados.')
295 | set_text(LANG, 'settings:9', '#audios on/off: Cuando está inhabilitado, todos los audios serán borrados.')
296 | set_text(LANG, 'settings:10', '#documents on/off: Cuando está inhabilitado, todos los documentos serán borrados.')
297 | set_text(LANG, 'settings:11', '#location on/off: Cuando está inhabilitado, todas las ubicaciones serán borradas.')
298 | set_text(LANG, 'settings:12', '#games on/off: Cuando está inhabilitado, todos los juegos serán borrados.')
299 | set_text(LANG, 'settings:13', '#spam on/off: Cuando está deshabilitado, todos los mensajes de spam se borrarán.')
300 | set_text(LANG, 'settings:14', '#forward on/off: Cuando está deshabilitado, se borrarán todos los mensajes reenviados.')
301 | set_text(LANG, 'settings:15', '#floodtime : Establecer el tiempo que bot utiliza para comprobar el flood. Ajuste 0 para desactivar.')
302 | set_text(LANG, 'settings:16', '#maxflood : Establecer el máximo de mensajes en un tiempo de flood para ser considerado como flood. Ajuste 0 para desactivarlo.')
303 | set_text(LANG, 'settings:17', '#links on/off: Cuando está deshabilitado, todos los enlaces se borrarán.')
304 | set_text(LANG, 'settings:18', '#arabic on/off: Cuando está inhabilitado, todos los mensajes con árabe/persa serán borrados.')
305 | set_text(LANG, 'settings:19', '#english on/off: Cuando está deshabilitado, se borrarán todos los mensajes con letras en inglés.')
306 | set_text(LANG, 'settings:20', '#emoji on/off: Cuando está inhabilitado, todos los mensajes con emoji serán borrados.')
307 | -- set_text(LANG, 'settings:5', '#bots on/off: Cuando está inhabilitado, si alguien añade un bot, se pateará.')
308 |
309 | if matches[1] == 'install' then
310 | return '`>` El lenguaje *español* ha sido instalado en su base de datos.'
311 | elseif matches[1] == 'update' then
312 | return '`>` El lenguaje *español* ha sido actualizado en su base de datos.'
313 | end
314 | else
315 | return "`>` Este plugin *requiere permisos de sudo*."
316 | end
317 | end
318 |
319 | return {
320 | patterns = {
321 | '[!/#](install) (spanish_lang)$',
322 | '[!/#](update) (spanish_lang)$'
323 | },
324 | run = run
325 | }
326 |
--------------------------------------------------------------------------------
/launch.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Launch created by @Jarriz, @Josepdal and @iicc1
3 |
4 | tgcli_version="170904-nightly"
5 | luarocks_version=2.4.2
6 |
7 | lualibs=(
8 | 'redis-lua'
9 | 'serpent'
10 | )
11 |
12 | today=`date +%F`
13 |
14 | get_sub() {
15 | local flag=false c count cr=$'\r' nl=$'\n'
16 | while IFS='' read -d '' -rn 1 c; do
17 | if $flag; then
18 | printf '%c' "$c"
19 | else
20 | if [[ $c != $cr && $c != $nl ]]; then
21 | count=0
22 | else
23 | ((count++))
24 | if ((count > 1)); then
25 | flag=true
26 | fi
27 | fi
28 | fi
29 | done
30 | }
31 |
32 | make_progress() {
33 | exe=`lua <<-EOF
34 | print(tonumber($1)/tonumber($2)*100)
35 | EOF
36 | `
37 | echo ${exe:0:4}
38 | }
39 |
40 | function get_tgcli_version() {
41 | echo "$tgcli_version"
42 | }
43 |
44 | function download_libs_lua() {
45 | if [[ ! -d "logs" ]]; then mkdir logs; fi
46 | if [[ -f "logs/logluarocks_${today}.txt" ]]; then rm logs/logluarocks_${today}.txt; fi
47 | local i
48 | for ((i=0;i<${#lualibs[@]};i++)); do
49 | printf "\r\33[2K"
50 | printf "\rDBTeam: wait... [`make_progress $(($i+1)) ${#lualibs[@]}`%%] [$(($i+1))/${#lualibs[@]}] ${lualibs[$i]}"
51 | ./.luarocks/bin/luarocks install ${lualibs[$i]} &>> logs/logluarocks_${today}.txt
52 | done
53 | sleep 0.2
54 | printf "\nLogfile created: $PWD/logs/logluarocks_${today}.txt\nDone\n"
55 | rm -rf luarocks-2.2.2*
56 | }
57 |
58 | function configure() {
59 | dir=$PWD
60 | wget http://luarocks.org/releases/luarocks-${luarocks_version}.tar.gz &>/dev/null
61 | tar zxpf luarocks-${luarocks_version}.tar.gz &>/dev/null
62 | cd luarocks-${luarocks_version}
63 | if [[ ${1} == "--no-null" ]]; then
64 | ./configure --prefix=$dir/.luarocks --sysconfdir=$dir/.luarocks/luarocks --force-config
65 | make bootstrap
66 | else
67 | ./configure --prefix=$dir/.luarocks --sysconfdir=$dir/.luarocks/luarocks --force-config &>/dev/null
68 | make bootstrap &>/dev/null
69 | fi
70 | cd ..; rm -rf luarocks*
71 | if [[ ${1} != "--no-download" ]]; then
72 | download_libs_lua
73 | wget --progress=bar:force https://valtman.name/files/telegram-bot-${tgcli_version}-linux 2>&1 | get_sub
74 | mv telegram-bot-${tgcli_version}-linux telegram-bot; chmod +x telegram-bot
75 | fi
76 | for ((i=0;i<101;i++)); do
77 | printf "\rConfiguring... [%i%%]" $i
78 | sleep 0.007
79 | done
80 | mkdir $HOME/.telegram-bot; cat < $HOME/.telegram-bot/config
81 | default_profile = "main";
82 | main = {
83 | lua_script = "$HOME/DBTeamV3/bot/bot.lua";
84 | };
85 | EOF
86 | printf "\nDone\n"
87 | }
88 |
89 | function start_bot() {
90 | ./telegram-bot | grep -v "{"
91 | }
92 |
93 | function login_bot() {
94 | ./telegram-bot -p main --login --phone=${1}
95 | }
96 |
97 | function update_bot() {
98 | git checkout launch.sh plugins/ lang/ bot/ libs/
99 | git pull
100 | echo chmod +x launch.sh | /bin/bash
101 | version=$(echo "./launch.sh tgcli_version" | /bin/bash)
102 | update_bot_to $version
103 | }
104 |
105 | function update_bot_to() {
106 | wget --progress=bar:force https://valtman.name/files/telegram-bot-${1}-linux 2>&1 | get_sub
107 | mv telegram-bot-${1}-linux telegram-bot; chmod +x telegram-bot
108 | }
109 |
110 | function show_logo_slowly() {
111 | seconds=0.009
112 | logo=(
113 | " ____ ____ _____"
114 | "| \| _ )_ _|___ ____ __ __"
115 | "| |_ ) _ \ | |/ .__| _ \_| \/ |"
116 | "|____/|____/ |_|\____/\_____|_/\/\_| v3"
117 | "by @Josepdal @iicc1 and @Jarriz"
118 | )
119 | printf "\033[38;5;208m\t"
120 | local i x
121 | for i in ${!logo[@]}; do
122 | for ((x=0;x<${#logo[$i]};x++)); do
123 | printf "${logo[$i]:$x:1}"
124 | sleep $seconds
125 | done
126 | printf "\n\t"
127 | done
128 | printf "\n"
129 | }
130 |
131 | function show_logo() {
132 | #Adding some color. By @iicc1 :D
133 | echo -e "\033[38;5;208m"
134 | echo -e "\t ____ ____ _____"
135 | echo -e "\t| \| _ )_ _|___ ____ __ __"
136 | echo -e "\t| |_ ) _ \ | |/ .__| _ \_| \/ |"
137 | echo -e "\t|____/|____/ |_|\____/\_____|_/\/\_| v3"
138 | echo -e "\n\e[36m"
139 | }
140 |
141 | case $1 in
142 | install)
143 | show_logo_slowly
144 | configure ${2}
145 | exit ;;
146 | login)
147 | echo "Please enter your phone number: "
148 | read phone_number
149 | login_bot ${phone_number}
150 | exit ;;
151 | update)
152 | update_bot
153 | exit ;;
154 | update-to)
155 | echo "Please enter bot version: "
156 | read bot_version
157 | update_bot_to ${bot_version}
158 | exit ;;
159 | tgcli_version)
160 | get_tgcli_version
161 | exit ;;
162 | help)
163 | echo "Commands available:"
164 | echo " install - First command to install all repos and download binary."
165 | echo " login - Access into your telegram account."
166 | echo " update - Update to the last DBTeamV3 support binary."
167 | echo " update-to - Write a version to update binary (from vysheng website)."
168 | echo " help - Shows this message."
169 | exit ;;
170 | esac
171 |
172 |
173 | show_logo
174 | start_bot $@
175 | exit 0
176 |
--------------------------------------------------------------------------------
/plugins/commands.lua:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------
2 | -- ___ ___ _____ __ _____ --
3 | -- | \| _ )_ _|__ __ _ _ _\ \ / /_ ) --
4 | -- | |) | _ \ | |/ -_) _` | ' \ V / / / --
5 | -- |___/|___/ |_|\___\__,_|_|_|_\_/ /___| --
6 | -- --
7 | ----------------------------------------------------
8 |
9 | do
10 | local function run(msg, matches)
11 | print(1)
12 | text = '#⃣ '..lang_text(msg.to.id, 'commandsT')..':\n'
13 | local space = '\n'
14 | if matches[1] == 'commands' and not matches[2] then
15 | if permissions(msg.from.id, msg.to.id, "mod_commands") then
16 | local langHash = 'langset:'..msg.to.id
17 | local lang = redis:get(langHash)
18 | for v,plugin in pairs(_config.enabled_plugins) do
19 | local textHash = 'lang:'..lang..':'..plugin..':0'
20 | if redis:get(textHash) then
21 | for i=1, tonumber(lang_text(msg.to.id, plugin..':0')), 1 do
22 | text = text..lang_text(msg.to.id, plugin..':'..i)..'\n'
23 | end
24 | text = text..space
25 | end
26 | end
27 | else
28 | text = text..lang_text(msg.to.id, 'moderation:5')..'\n'
29 | text = text..lang_text(msg.to.id, 'version:1')..'\n'
30 | text = text..lang_text(msg.to.id, 'rules:1')..'\n'
31 | end
32 | elseif matches[1] == 'commands' and matches[2] then
33 | if permissions(msg.from.id, msg.to.id, "mod_commands") then
34 | local langHash = 'langset:'..msg.to.id
35 | local lang = redis:get(langHash)
36 | for v,plugin in pairs(_config.enabled_plugins) do
37 | if plugin == matches[2] then
38 | local textHash = 'lang:'..lang..':'..plugin..':0'
39 | if redis:get(textHash) then
40 | for i=1, tonumber(lang_text(msg.to.id, plugin..':0')), 1 do
41 | text = text..lang_text(msg.to.id, plugin..':'..i)..'\n'
42 | end
43 | end
44 | return text
45 | end
46 | end
47 | return 'ℹ️ '..lang_text(msg.to.id, 'errorNoPlug')
48 | else
49 | return '🚫 '..lang_text(msg.to.id, 'require_mod')
50 | end
51 | end
52 |
53 | return '`' .. text .. '`'
54 | end
55 |
56 | return {
57 | patterns = {
58 | "^[!/#](commands)$",
59 | "^[!/#](commands) (.+)"
60 | },
61 | run = run
62 | }
63 | end
--------------------------------------------------------------------------------
/plugins/extra.lua:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------
2 | -- ___ ___ _____ __ _____ --
3 | -- | \| _ )_ _|__ __ _ _ _\ \ / /_ ) --
4 | -- | |) | _ \ | |/ -_) _` | ' \ V / / / --
5 | -- |___/|___/ |_|\___\__,_|_|_|_\_/ /___| --
6 | -- --
7 | ----------------------------------------------------
8 | --extra.lua
9 | --by @iicc1
10 | -- missing translations
11 |
12 | local function run(msg, matches)
13 | if matches[1] == "extra" and not msg.reply_id then
14 | if matches[2] then
15 | if permissions(msg.from.id, msg.to.id, "mod_commands") then
16 | local extra = {}
17 | extra = { string.match(matches[2], "^[!/#](%S+) (.*)$") }
18 | addCommand(msg.to.id, extra)
19 | end
20 | else
21 | local list = "Extra list in this chat:\n"
22 | for command, text in pairs (redis:hgetall("extra".. msg.to.id)) do
23 | list = list .. "[#/!]" .. command .. "\n"
24 | end
25 | send_msg(msg.to.id, list, 'html')
26 | end
27 | elseif matches[1] == "extra" and msg.reply_id then
28 | if permissions(msg.from.id, msg.to.id, "mod_commands") then
29 | get_msg_info(msg.to.id, msg.reply_id, infofile, matches[2])
30 | end
31 | elseif matches[1] == "extradel" and matches[2] then
32 | if permissions(msg.from.id, msg.to.id, "mod_commands") then
33 | local extra = ''
34 | extra = string.match(matches[2], "^[!/#](%S+)$")
35 | if extra then
36 | redis:hdel("extra" .. msg.to.id, extra)
37 | send_msg(msg.to.id, "The command: [!/#]" .. extra .." has been removed.", 'html')
38 | else
39 | send_msg(msg.to.id, "Error: the extra command does not exist in this chat.", 'html')
40 | end
41 | end
42 | elseif matches[1] then
43 | for command, text in pairs (redis:hgetall("extra".. msg.to.id)) do
44 | if matches[1] == command then
45 | local data = redis:hget("extra".. msg.to.id, command)
46 | if string.find(data, "%$") then
47 | local extra = {}
48 | if string.find(data, "nil") then
49 | extra = {string.match(data, "^[%$](%S+) (%S+)")}
50 | else
51 | extra = {string.match(data, "^[%$](%S+) (%S+) (.*)")}
52 | end
53 | if extra[1] == "sticker" then
54 | sendSticker(msg.to.id, extra[2])
55 | elseif extra[1] == "photo" then
56 | sendPhoto(msg.to.id, extra[2], extra[3])
57 | elseif extra[1] == "audio" then
58 | sendAudio(msg.to.id, extra[2], extra[3])
59 | elseif extra[1] == "voice" then
60 | sendVoice(msg.to.id, extra[2], extra[3])
61 | elseif extra[1] == "gif" then
62 | sendAnimation(msg.to.id, extra[2], extra[3])
63 | elseif extra[1] == "video" then
64 | sendVideo(msg.to.id, extra[2], extra[3])
65 | elseif extra[1] == "document" then
66 | sendDocument(msg.to.id, extra[2], extra[3])
67 | end
68 | else
69 | send_msg(msg.to.id, data, 'html')
70 | end
71 | end
72 | end
73 | end
74 | end
75 |
76 | function infofile(matches,msginfo)
77 | local data = {}
78 | data.message_ = msginfo
79 | msg = oldtg(data)
80 | if msg.file_id then
81 | if msg.sticker then
82 | local extra = {}
83 | extra = { string.match(matches, "^[!/#](%S+) (.*)$") }
84 | if not extra[1] then
85 | extra = { string.match(matches, "^[!/#](%S+)$") }
86 | end
87 | local persistent = "$sticker " .. msg.file_id
88 | addCommand(msg.to.id, extra, true, persistent)
89 | elseif msg.photo then
90 | local extra = {}
91 | extra = { string.match(matches, "^[!/#](%S+) (.*)$") }
92 | if not extra[1] then
93 | extra = { string.match(matches, "^[!/#](%S+)$") }
94 | end
95 | local persistent = "$photo " .. msg.file_id
96 | addCommand(msg.to.id, extra, true, persistent)
97 | elseif msg.audio then
98 | local extra = {}
99 | extra = { string.match(matches, "^[!/#](%S+) (.*)$") }
100 | if not extra[1] then
101 | extra = { string.match(matches, "^[!/#](%S+)$") }
102 | end
103 | local persistent = "$audio " .. msg.file_id
104 | addCommand(msg.to.id, extra, true, persistent)
105 | elseif msg.voice then
106 | local extra = {}
107 | extra = { string.match(matches, "^[!/#](%S+) (.*)$") }
108 | if not extra[1] then
109 | extra = { string.match(matches, "^[!/#](%S+)$") }
110 | end
111 | local persistent = "$voice " .. msg.file_id
112 | addCommand(msg.to.id, extra, true, persistent)
113 | elseif msg.gif then
114 | local extra = {}
115 | extra = { string.match(matches, "^[!/#](%S+) (.*)$") }
116 | if not extra[1] then
117 | extra = { string.match(matches, "^[!/#](%S+)$") }
118 | end
119 | local persistent = "$gif " .. msg.file_id
120 | addCommand(msg.to.id, extra, true, persistent)
121 | elseif msg.video then
122 | local extra = {}
123 | extra = { string.match(matches, "^[!/#](%S+) (.*)$") }
124 | if not extra[1] then
125 | extra = { string.match(matches, "^[!/#](%S+)$") }
126 | end
127 | local persistent = "$video " .. msg.file_id
128 | addCommand(msg.to.id, extra, true, persistent)
129 | elseif msg.document then
130 | local extra = {}
131 | extra = { string.match(matches, "^[!/#](%S+) (.*)$") }
132 | if not extra[1] then
133 | extra = { string.match(matches, "^[!/#](%S+)$") }
134 | end
135 | local persistent = "$document " .. msg.file_id
136 | addCommand(msg.to.id, extra, true, persistent)
137 | end
138 | end
139 | end
140 |
141 | function addCommand(chat_id, command, file, persistent)
142 | local pattern = command[1]
143 | local text = ''
144 | if file == true then
145 | if command[2] then
146 | text = persistent .. " " .. command[2]
147 | else
148 | text = persistent .. " nil"
149 | end
150 | else
151 | text = command[2]
152 | end
153 | print(pattern)
154 | if redis:hget("extra".. msg.to.id, pattern) then
155 | redis:hset("extra" .. msg.to.id, pattern, text)
156 | else
157 | redis:hset("extra" .. msg.to.id, pattern, text)
158 | end
159 | send_msg(msg.to.id, "New command: [#/!]" ..pattern.."\nThat sends:\n".. redis:hget("extra" .. msg.to.id, pattern) , 'html')
160 | end
161 |
162 | return {
163 | patterns = {
164 | "^[!/#](%S+) (.*)$",
165 | "^[!/#](.*)$"
166 | },
167 | run = run
168 | }
169 |
--------------------------------------------------------------------------------
/plugins/gbans.lua:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------
2 | -- ___ ___ _____ __ _____ --
3 | -- | \| _ )_ _|__ __ _ _ _\ \ / /_ ) --
4 | -- | |) | _ \ | |/ -_) _` | ' \ V / / / --
5 | -- |___/|___/ |_|\___\__,_|_|_|_\_/ /___| --
6 | -- --
7 | ----------------------------------------------------
8 |
9 |
10 | local function run(msg, matches)
11 | if permissions(msg.from.id, msg.to.id, "gban") and redis:get("moderation_group: " .. msg.to.id) then
12 | if not matches[2] then
13 | local count =(redis:scard("gbans"))
14 | local text = lang_text(msg.to.id, 'gbans')..count..") :\n"
15 | for k, v in pairs (redis:smembers("gbans")) do
16 | text = text .. ">
" .. v .. "\n"
17 | end
18 | send_msg(msg.to.id, text, "html")
19 |
20 | elseif matches[2] == "json" then
21 | local text = "[\n"
22 | for k, v in pairs (redis:smembers("gbans")) do
23 | text = text .. '\t' .. v .. ',\n'
24 | end
25 | text = text:sub(1, -3) .. "\n]\n"
26 |
27 | file = io.open("data/gbans.json", "w")
28 | file:write(text)
29 | file:close()
30 | send_document(msg.to.id, "./data/gbans.json")
31 |
32 | elseif matches[2] == "lua" then
33 | local text = "return {\ngbans = {\n"
34 | for k, v in pairs (redis:smembers("gbans")) do
35 | text = text .. '\t' .. v .. ',\n'
36 | end
37 | text = text:sub(1, -3) .. '\n },\n\n}\n'
38 |
39 | file = io.open("data/gbans.lua", "w")
40 | file:write(text)
41 | file:close()
42 | send_document(msg.to.id, "./data/gbans.lua")
43 |
44 | elseif matches[2] == "install" then
45 | t = scandir("data/")
46 | for k, v in pairs(t) do
47 | if string.match(v, "^gbans%.[Ll]ua$") then
48 | local count = 0
49 | local gbanst = load_gbans("data/"..v)
50 | for k, v in pairs (gbanst) do
51 | count = count + 1
52 | redis:sadd("gbans", v)
53 | end
54 | send_msg(msg.to.id, count .. lang_text(msg.to.id, 'gbanLua'), "html")
55 |
56 | elseif string.match(v, "^gbans%.[Jj][sS][Oo][nN]$") then
57 | local count = 0
58 | local f = io.open("data/"..v, "r")
59 | repeat
60 | local line = f:read ("*l")
61 | if line then
62 | local user = (line:gsub('[%D/n]',''))
63 | if (string.len(user)) ~= 0 then
64 | count = count + 1
65 | redis:sadd("gbans", user)
66 | end
67 | end
68 | until not line
69 |
70 | f:close()
71 | send_msg(msg.to.id, count .. lang_text(msg.to.id, 'gbanJson'), "html")
72 | end
73 | end
74 |
75 | elseif matches[2] == "delete" then
76 | redis:del("gbans")
77 | send_msg(msg.to.id, lang_text(msg.to.id, 'gbanDel'), "html")
78 | end
79 | end
80 | end
81 |
82 | function load_gbans(file)
83 | local f = io.open(file, "r")
84 | local data = loadfile (file)()
85 | local t = {}
86 | for v,user in pairs(data.gbans) do
87 | t[v] = user
88 | end
89 | return t
90 | end
91 |
92 | return {
93 | patterns = {
94 | "^[!/#]([Gg]bans)$",
95 | "^[!/#]([Gg]bans) (.*)$"
96 | },
97 | run = run,
98 | }
99 |
--------------------------------------------------------------------------------
/plugins/id.lua:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------
2 | -- ___ ___ _____ __ _____ --
3 | -- | \| _ )_ _|__ __ _ _ _\ \ / /_ ) --
4 | -- | |) | _ \ | |/ -_) _` | ' \ V / / / --
5 | -- |___/|___/ |_|\___\__,_|_|_|_\_/ /___| --
6 | -- --
7 | ----------------------------------------------------
8 |
9 | function send_ID_by_reply(channel_id, message_id)
10 | get_msg_info(channel_id, message_id, getID_by_reply_cb, false)
11 | end
12 |
13 |
14 |
15 | function getID_by_reply_cb(arg, msg)
16 | send_msg(msg.chat_id, lang_text(msg.chat_id, 'userID') .. " " .. msg.sender_user_id .. "\n" .. lang_text(msg.chat_id, 'chatID') .. " " .. msg.chat_id, "md")
17 | end
18 |
19 | local function run(msg, matches)
20 | if not msg.reply_id then
21 | if not matches[2] then
22 | send_msg(msg.to.id, lang_text(msg.to.id, 'userID') .. " " .. msg.from.id .. "\n" .. lang_text(msg.to.id, 'chatID') .. " " .. msg.to.id, "md")
23 | else
24 | if is_number(matches[2]) then
25 | resolve_id(matches[2], getIdUsername, msg.to.id)
26 | else
27 | resolve_username(matches[2], getUsernameId, msg.to.id)
28 | end
29 | end
30 | else
31 | send_ID_by_reply(msg.to.id, msg.reply_id)
32 | end
33 | end
34 |
35 | function getIdUsername(chat, data)
36 | if data.ID == "Error" then
37 | send_msg(chat, "*Error:* `" .. data.message .. "`", "md")
38 | else
39 | send_msg(chat, "*Alias:* @" .. data.user.username , "md")
40 | end
41 | end
42 |
43 | function getUsernameId(chat, data)
44 | if data.ID == "Error" then
45 | send_msg(chat, "*Error:* `" .. data.message .. "`", "md")
46 | else
47 | send_msg(chat, "*ID:* `" .. data.id .. "`", "md")
48 | end
49 | end
50 |
51 | return {
52 | patterns = {
53 | '^[!/#]([Ii][Dd])$',
54 | '^[!/#]([Ii][Dd]) (.*)$'
55 | },
56 | run = run
57 | }
58 |
--------------------------------------------------------------------------------
/plugins/langs.lua:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------
2 | -- ___ ___ _____ __ _____ --
3 | -- | \| _ )_ _|__ __ _ _ _\ \ / /_ ) --
4 | -- | |) | _ \ | |/ -_) _` | ' \ V / / / --
5 | -- |___/|___/ |_|\___\__,_|_|_|_\_/ /___| --
6 | -- --
7 | ----------------------------------------------------
8 |
9 | local function lang_enabled(name)
10 | for k,v in pairs(_config.enabled_lang) do
11 | if name == v then
12 | return true
13 | end
14 | end
15 | return false
16 | end
17 |
18 | local function lang_exists( name )
19 | for k,v in pairs(langs_names()) do
20 | if name..'.lua' == v then
21 | return true
22 | end
23 | end
24 | return false
25 | end
26 |
27 | local function enable_lang(lang_name)
28 | table.insert(_config.enabled_lang, lang_name)
29 | load_lang()
30 | save_config()
31 | send_msg(msg.to.id, "`>` This lang was correctly installed in your bot, use `#install ` to load the translations and `#lang ` to change the language.", "md")
32 | end
33 |
34 | local function run(msg, matches)
35 | if permissions(msg.from.id, msg.to.id, "plugins") then
36 | if lang_enabled(matches[2]) == true then
37 | send_msg(msg.to.id, "`>` This lang is already installed, use `#install ` to load the translations and `#lang ` to change the language.", "md")
38 | else
39 | if lang_exists(matches[2]) == true then
40 | enable_lang(matches[2])
41 | else
42 | send_msg(msg.to.id, "`>` This lang does not exists in `/lang` folder.", "md")
43 | end
44 | end
45 | end
46 | end
47 |
48 | return {
49 | patterns = {
50 | "^[!/#]([Ee][Nn][aA][Bb][lL]e) (%S+)$",
51 | },
52 | run = run
53 | }
54 |
--------------------------------------------------------------------------------
/plugins/moderation.lua:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------
2 | -- ___ ___ _____ __ _____ --
3 | -- | \| _ )_ _|__ __ _ _ _\ \ / /_ ) --
4 | -- | |) | _ \ | |/ -_) _` | ' \ V / / / --
5 | -- |___/|___/ |_|\___\__,_|_|_|_\_/ /___| --
6 | -- --
7 | ----------------------------------------------------
8 |
9 | local function delete_messages(chat_id, messages_ids)
10 | tdcli_function ({
11 | ID = "DeleteMessages",
12 | chat_id_ = chat_id,
13 | message_ids_ = message_ids
14 | }, dl_cb, nil)
15 | end
16 |
17 | local function history_cb(chat_id, data)
18 | local message_ids = {}
19 | for i = 0, #data.messages_, 1 do
20 | delete_msg(msg.to.id, data.messages_[i].id_)
21 | end
22 | end
23 |
24 | local function pre_process(msg)
25 |
26 | -- Check if user is chat-banned
27 | if redis:get("ban:" .. msg.to.id .. ":" .. msg.from.id) then
28 | if redis:get("moderation_group: " .. msg.to.id) then
29 | kick_user(msg.to.id, msg.from.id)
30 | end
31 | end
32 |
33 | -- Check if user is global-banned
34 | if redis:sismember("gbans", msg.from.id) then
35 | if redis:get("moderation_group: " .. msg.to.id) then
36 | kick_user(msg.to.id, msg.from.id)
37 | end
38 | end
39 |
40 | --Check if user is muted
41 | if redis:get("muted:" .. msg.to.id .. ":" .. msg.from.id) then
42 | if redis:get("moderation_group: " .. msg.to.id) then
43 | delete_msg(msg.to.id, msg.id)
44 | if not redis:get("muted:alert:" .. msg.to.id .. ":" .. msg.from.id) then
45 | redis:setex("muted:alert:" .. msg.to.id .. ":" .. msg.from.id, 300, true)
46 | send_msg(msg.to.id, 'Trying to speak...', 'md')
47 | end
48 | end
49 | end
50 | --Check if chat is muted
51 | if redis:get("muteall:" .. msg.to.id) then
52 | if redis:get("moderation_group: " .. msg.to.id) then
53 | if not permissions(msg.from.id, msg.to.id, "moderation", "silent") then
54 | delete_msg(msg.to.id, msg.id)
55 | end
56 | end
57 | end
58 |
59 | return msg
60 | end
61 |
62 | local function run(msg, matches)
63 | if redis:get("moderation_group: " .. msg.to.id) then
64 | if matches[1] == "del" and not matches[2] then
65 | if permissions(msg.from.id, msg.to.id, "rem_history") and msg.reply_id then
66 | delete_msg(msg.to.id, msg.reply_id)
67 | end
68 | delete_msg(msg.to.id, msg.id)
69 | elseif matches[1] == "ban" then
70 | if not matches[2] and msg.reply_id then
71 | if compare_permissions(msg.to.id, msg.from.id, msg.replied.id) then
72 | send_msg(msg.to.id, lang_text(msg.to.id, 'banUser'):gsub("$id", msg.replied.id), "md")
73 | kick_user(msg.to.id, msg.replied.id)
74 | redis:set("ban:" .. msg.to.id .. ":" .. msg.replied.id, true)
75 | else
76 | permissions(msg.from.id, msg.to.id, "moderation")
77 | end
78 | elseif is_number(matches[2]) and not msg.reply_id then
79 | if compare_permissions(msg.to.id, msg.from.id, matches[2]) then
80 | send_msg(msg.to.id, lang_text(msg.to.id, 'banUser'):gsub("$id", matches[2]), "md")
81 | kick_user(msg.to.id, matches[2])
82 | redis:set("ban:" .. msg.to.id .. ":" .. matches[2], true)
83 | else
84 | permissions(msg.from.id, msg.to.id, "moderation")
85 | end
86 | elseif not is_number(matches[2]) and matches[2] then
87 | resolve_username(matches[2], resolve_cb, {chat_id = msg.to.id, superior = msg.from.id, plugin_tag = "moderation", command = "ban"})
88 | elseif is_number(matches[2]) and msg.reply_id then
89 | send_msg(msg.to.id, "`>` The user `" .. msg.replied.id .. "` has been *banned* for `" .. matches[2] .. "` secs." , "md")
90 | kick_user(msg.to.id, msg.replied.id)
91 | redis:setex("ban:" .. msg.to.id .. ":" .. msg.replied.id, matches[2], true)
92 | removeFromBanList(msg.to.id, msg.replied.id)
93 | end
94 | elseif matches[1] == "unban" then
95 | if not matches[2] and msg.reply_id ~= 0 then
96 | if compare_permissions(msg.to.id, msg.from.id, msg.replied.id) then
97 | send_msg(msg.to.id, lang_text(msg.to.id, 'unbanUser'):gsub("$id", msg.replied.id), "md")
98 | redis:del("ban:" .. msg.to.id .. ":" .. msg.replied.id)
99 | removeFromBanList(msg.to.id, msg.replied.id)
100 | else
101 | permissions(msg.from.id, msg.to.id, "moderation")
102 | end
103 | elseif is_number(matches[2]) then
104 | if compare_permissions(msg.to.id, msg.from.id, matches[2]) then
105 | send_msg(msg.to.id, lang_text(msg.to.id, 'unbanUser'):gsub("$id", matches[2]), "md")
106 | redis:del("ban:" .. msg.to.id .. ":" .. matches[2])
107 | removeFromBanList(msg.to.id, matches[2])
108 | else
109 | permissions(msg.from.id, msg.to.id, "moderation")
110 | end
111 | elseif not is_number(matches[2]) and matches[2] then
112 | resolve_username(matches[2], resolve_cb, {chat_id = msg.to.id, superior = msg.from.id, plugin_tag = "moderation", command = "unban"})
113 | end
114 | elseif matches[1] == "kick" then
115 | if not matches[2] and msg.reply_id ~= 0 then
116 | if compare_permissions(msg.to.id, msg.from.id, msg.replied.id) then
117 | send_msg(msg.to.id, lang_text(msg.to.id, 'kickUser'):gsub("$id", msg.replied.id), "md")
118 | kick_user(msg.to.id, msg.replied.id)
119 | removeFromBanList(msg.to.id, msg.replied.id)
120 | else
121 | permissions(msg.from.id, msg.to.id, "moderation")
122 | end
123 | elseif is_number(matches[2]) then
124 | if compare_permissions(msg.to.id, msg.from.id, matches[2]) then
125 | send_msg(msg.to.id, lang_text(msg.to.id, 'kickUser'):gsub("$id", matches[2]), "md")
126 | kick_user(msg.to.id, matches[2])
127 | removeFromBanList(msg.to.id, matches[2])
128 | else
129 | permissions(msg.from.id, msg.to.id, "moderation")
130 | end
131 | elseif not is_number(matches[2]) and matches[2] then
132 | resolve_username(matches[2], resolve_cb, {chat_id = msg.to.id, superior = msg.from.id, plugin_tag = "moderation", command = "kick"})
133 | end
134 | elseif matches[1] == "gban" then
135 | if not matches[2] and msg.reply_id then
136 | if compare_permissions(msg.to.id, msg.from.id, msg.replied.id) then
137 | send_msg(msg.to.id, lang_text(msg.to.id, 'gbanUser'):gsub("$id", msg.replied.id), "md")
138 | kick_user(msg.to.id, msg.replied.id)
139 | redis:sadd("gbans", msg.replied.id)
140 | else
141 | permissions(msg.from.id, msg.to.id, "gban")
142 | end
143 | elseif is_number(matches[2]) then
144 | if compare_permissions(msg.to.id, msg.from.id, matches[2]) then
145 | send_msg(msg.to.id, lang_text(msg.to.id, 'gbanUser'):gsub("$id", matches[2]), "md")
146 | kick_user(msg.to.id, matches[2])
147 | redis:sadd("gbans", msg.replied.id)
148 | else
149 | permissions(msg.from.id, msg.to.id, "gban")
150 | end
151 | elseif not is_number(matches[2]) and matches[2] then
152 | resolve_username(matches[2], resolve_cb, {chat_id = msg.to.id, superior = msg.from.id, plugin_tag = "moderation", command = "gban"})
153 | end
154 | elseif matches[1] == "ungban" then
155 | if not matches[2] and msg.reply_id ~= 0 then
156 | if compare_permissions(msg.to.id, msg.from.id, msg.replied.id) then
157 | send_msg(msg.to.id, lang_text(msg.to.id, 'ungbanUser'):gsub("$id", msg.replied.id), "md")
158 | redis:srem("gbans", msg.replied.id)
159 | else
160 | permissions(msg.from.id, msg.to.id, "gban")
161 | end
162 | elseif is_number(matches[2]) then
163 | if compare_permissions(msg.to.id, msg.from.id, matches[2]) then
164 | send_msg(msg.to.id, lang_text(msg.to.id, 'ungbanUser'):gsub("$id", matches[2]), "md")
165 | redis:srem("gbans", matches[2])
166 | else
167 | permissions(msg.from.id, msg.to.id, "gban")
168 | end
169 | elseif not is_number(matches[2]) and matches[2] then
170 | resolve_username(matches[2], resolve_cb, {chat_id = msg.to.id, superior = msg.from.id, plugin_tag = "moderation", command = "ungban"})
171 | end
172 | elseif matches[1] == "mute" then
173 | if not matches[2] and msg.reply_id then
174 | if compare_permissions(msg.to.id, msg.from.id, msg.replied.id) then
175 | send_msg(msg.to.id, lang_text(msg.to.id, 'muteUser'):gsub("$id", msg.replied.id), "md")
176 | redis:set("muted:" .. msg.to.id .. ":" .. msg.replied.id, true)
177 | else
178 | permissions(msg.from.id, msg.to.id, "moderation")
179 | end
180 | elseif is_number(matches[2]) and msg.reply_id then
181 | if compare_permissions(msg.to.id, msg.from.id, msg.replied.id) then
182 | send_msg(msg.to.id, lang_text(msg.to.id, 'muteUserSec'):gsub("$id", msg.replied.id) .. matches[2] .. " *secs.*", "md")
183 | redis:setex("muted:" .. msg.to.id .. ":" .. msg.replied.id, matches[2], true)
184 | else
185 | permissions(msg.from.id, msg.to.id, "moderation")
186 | end
187 | elseif is_number(matches[2]) then
188 | if compare_permissions(msg.to.id, msg.from.id, matches[2]) then
189 | send_msg(msg.to.id, lang_text(msg.to.id, 'muteUser'):gsub("$id", matches[2]), "md")
190 | redis:set("muted:" .. msg.to.id .. ":" .. matches[2], true)
191 | else
192 | permissions(msg.from.id, msg.to.id, "moderation")
193 | end
194 | elseif not is_number(matches[2]) and matches[2] then
195 | resolve_username(matches[2], resolve_cb, {chat_id = msg.to.id, superior = msg.from.id, plugin_tag = "moderation", command = "mute"})
196 | end
197 | elseif matches[1] == "unmute" then
198 | if not matches[2] and msg.reply_id then
199 | if compare_permissions(msg.to.id, msg.from.id, msg.replied.id) then
200 | send_msg(msg.to.id, lang_text(msg.to.id, 'unmuteUser'):gsub("$id", msg.replied.id), "md")
201 | redis:del("muted:" .. msg.to.id .. ":" .. msg.replied.id)
202 | else
203 | permissions(msg.from.id, msg.to.id, "moderation")
204 | end
205 | elseif is_number(matches[2]) then
206 | if compare_permissions(msg.to.id, msg.from.id, matches[2]) then
207 | send_msg(msg.to.id, lang_text(msg.to.id, 'unmuteUser'):gsub("$id", matches[2]), "md")
208 | redis:del("muted:" .. msg.to.id .. ":" .. matches[2])
209 | else
210 | permissions(msg.from.id, msg.to.id, "moderation")
211 | end
212 | elseif not is_number(matches[2]) and matches[2] then
213 | resolve_username(matches[2], resolve_cb, {chat_id = msg.to.id, superior = msg.from.id, plugin_tag = "moderation", command = "unmute"})
214 | end
215 | elseif matches[1] == "muteall" then
216 | if is_number(matches[2]) then
217 | if permissions(msg.from.id, msg.to.id, "moderation") then
218 | send_msg(msg.to.id, lang_text(msg.to.id, 'muteChatSec') .. matches[2] .. " *secs.*", "md")
219 | redis:setex("muteall:" .. msg.to.id, matches[2], true)
220 | end
221 | else
222 | if permissions(msg.from.id, msg.to.id, "moderation") then
223 | send_msg(msg.to.id, lang_text(msg.to.id, 'muteChat'), "md")
224 | redis:set("muteall:" .. msg.to.id, true)
225 | end
226 | end
227 | elseif matches[1] == "unmuteall" then
228 | if permissions(msg.from.id, msg.to.id, "moderation") then
229 | send_msg(msg.to.id, lang_text(msg.to.id, 'unmuteChat'), "md")
230 | redis:del("muteall:" .. msg.to.id)
231 | end
232 | elseif matches[1] == "delall" and not msg.reply_id then
233 | if permissions(msg.from.id, msg.to.id, "rem_history") then
234 | for k,v in pairs(redis:smembers('chat:' .. msg.to.id .. ':members')) do
235 | delete_msg_user(msg.to.id, v)
236 | end
237 | send_msg(msg.to.id, lang_text(msg.to.id, 'delAll'), 'md')
238 | end
239 | elseif matches[1] == "delall" and msg.reply_id then
240 | if permissions(msg.from.id, msg.to.id, "rem_history") then
241 | if compare_permissions(msg.to.id, msg.from.id, msg.replied.id) then
242 | delete_msg_user(msg.to.id, msg.replied.id)
243 | delete_msg(msg.to.id, msg.id)
244 | send_msg(msg.to.id, lang_text(msg.to.id, 'delAll'), 'md')
245 | end
246 | end
247 | elseif matches[1] == "del" and matches[2] and msg.reply_id then
248 | if permissions(msg.from.id, msg.to.id, "rem_history") then
249 | if compare_permissions(msg.to.id, msg.from.id, msg.replied.id) then
250 | chat_history(msg.to.id, msg.reply_id, 0, tonumber(matches[2]), history_cb, msg.to.id)
251 | delete_msg(msg.to.id, msg.reply_id)
252 | delete_msg(msg.to.id, msg.id)
253 | send_msg(msg.to.id, lang_text(msg.to.id, 'delXMsg'):gsub("$user", (msg.replied.username or msg.replied.first_name)):gsub("$num", matches[2]), 'md')
254 | end
255 | end
256 | end
257 | else
258 | print("\27[32m> Not moderating this group.\27[39m")
259 | end
260 | end
261 |
262 | return {
263 | patterns = {
264 | "^[!/#](del)$",
265 | "^[!/#](del) (.*)$",
266 | "^[!/#](delall)$",
267 | "^[!/#](ban) (.*)$",
268 | "^[!/#](ban)$",
269 | "^[!/#](gban) (.*)$",
270 | "^[!/#](gban)$",
271 | "^[!/#](ungban) (.*)$",
272 | "^[!/#](ungban)$",
273 | "^[!/#](unban) (.*)$",
274 | "^[!/#](unban)$",
275 | "^[!/#](kick) (.*)$",
276 | "^[!/#](kick)$",
277 | "^[!/#](mute)$",
278 | "^[!/#](mute) (.*)$",
279 | "^[!/#](unmute)$",
280 | "^[!/#](unmute) (.*)$",
281 | "^[!/#](muteall)$",
282 | "^[!/#](unmuteall)$",
283 | "^[!/#](muteall) (.*)$"
284 | },
285 | run = run,
286 | pre_process = pre_process
287 | }
288 |
--------------------------------------------------------------------------------
/plugins/plugins.lua:
--------------------------------------------------------------------------------
1 | do
2 |
3 | local to_id = ""
4 |
5 | -- Returns the key (index) in the config.enabled_plugins table
6 | local function plugin_enabled( name )
7 | for k,v in pairs(_config.enabled_plugins) do
8 | if name == v then
9 | return k
10 | end
11 | end
12 | -- If not found
13 | return false
14 | end
15 |
16 | -- Returns true if file exists in plugins folder
17 | local function plugin_exists( name )
18 | for k,v in pairs(plugins_names()) do
19 | if name..'.lua' == v then
20 | return true
21 | end
22 | end
23 | return false
24 | end
25 |
26 | local function list_plugins(only_enabled)
27 | local text = '*'..lang_text(to_id, 'pluginsActivated')..':*\n'
28 | local psum = 0
29 | for k, v in pairs( plugins_names( )) do
30 | -- ✅ enabled, ❎ disabled
31 | local status = '`✗`'
32 | psum = psum+1
33 | pact = 0
34 | -- Check if is enabled
35 | for k2, v2 in pairs(_config.enabled_plugins) do
36 | if v == v2..'.lua' then
37 | status = '`✓`'
38 | end
39 | pact = pact+1
40 | end
41 | if not only_enabled and status == '`✗`'then
42 | -- get the name
43 | v = string.match (v, "(.*)%.lua")
44 | text = text..status..' _'..v..'_\n'
45 | elseif not only_enabled and status == '`✓`' then
46 | -- get the name
47 | v = string.match (v, "(.*)%.lua")
48 | text = text..status..' '..v..'\n'
49 | end
50 | end
51 | return text
52 | end
53 |
54 | local function reload_plugins(de)
55 | plugins = {}
56 | load_plugins()
57 | if de == 'en' then
58 | return lang_text(to_id, 'pluginEnabled')
59 | elseif de == 'di' then
60 | return lang_text(to_id, 'pluginDisabled')
61 | end
62 | end
63 |
64 |
65 | local function enable_plugin(plugin_name)
66 | -- Check if plugin is enabled
67 | if plugin_enabled(plugin_name) then
68 | return lang_text(to_id, 'pluginIsEnabled')
69 | end
70 | -- Checks if plugin exists
71 | if plugin_exists(plugin_name) then
72 | -- Add to the config table
73 | table.insert(_config.enabled_plugins, plugin_name)
74 | save_config()
75 | -- Reload the plugins
76 | return reload_plugins('en')
77 | else
78 | return lang_text(to_id, 'pluginNoExist'):gsub("$name", plugin_name)
79 | end
80 | end
81 |
82 | local function disable_plugin(plugin_name)
83 | -- Check if plugins exists
84 | if not plugin_exists(plugin_name) then
85 | return lang_text(to_id, 'pluginNoExist'):gsub("$name", plugin_name)
86 | end
87 | local k = plugin_enabled(plugin_name)
88 | -- Check if plugin is enabled
89 | if not k then
90 | return lang_text(to_id, 'pluginNoEnabled')
91 | end
92 | -- Disable and reload
93 | table.remove(_config.enabled_plugins, k)
94 | save_config( )
95 | return reload_plugins('di')
96 | end
97 |
98 |
99 | local function run(msg, matches)
100 | to_id = msg.to.id
101 | if permissions(msg.from.id, msg.to.id, "plugins") then
102 | -- Enable a plugin
103 | if matches[1] == 'enable' then
104 | local plugin_name = matches[2]
105 | print("enable: "..matches[2])
106 | return enable_plugin(plugin_name)
107 | end
108 | -- Disable a plugin
109 | if matches[1] == 'disable' then
110 | print("disable: "..matches[2])
111 | return disable_plugin(matches[2])
112 | end
113 | -- Reload all the plugins!
114 | if matches[1] == 'reload' then
115 | send_msg(msg.to.id, lang_text(msg.to.id, 'pluginsReload'), "md")
116 | return reload_plugins(true)
117 | end
118 |
119 | if matches[1] == 'plugins' then
120 | return list_plugins()
121 | end
122 | else
123 | return lang_text(msg.to.id, 'require_sudo')
124 | end
125 | end
126 |
127 | return {
128 | patterns = {
129 | "^[!/#](plugins)$",
130 | "^[!/#]plugins? (enable) ([%w_%.%-]+)$",
131 | "^[!/#]plugins? (disable) ([%w_%.%-]+)$",
132 | "^[!/#]plugins? (reload)$" },
133 | run = run
134 | }
135 | end
--------------------------------------------------------------------------------
/plugins/private.lua:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------
2 | -- ___ ___ _____ __ _____ --
3 | -- | \| _ )_ _|__ __ _ _ _\ \ / /_ ) --
4 | -- | |) | _ \ | |/ -_) _` | ' \ V / / / --
5 | -- |___/|___/ |_|\___\__,_|_|_|_\_/ /___| --
6 | -- --
7 | ----------------------------------------------------
8 |
9 | local function run(msg, matches)
10 | if matches[1] == "start" or matches[1] == "help" then
11 | if msg.from.id == msg.to.id then
12 | send_msg(msg.to.id, "*Welcome!*\n\nThis is a *DBTeamV3 TDCli* _userbot_.\n\nLook here how to use the bot: http://telegra.ph/DBTeamV2-Tutorial-English-02-26\n\n*Official channels:* @DBTeamEN @DBTeamES @DBTeam\n\nSource code (Github): https://git.io/DBTeamV3", "md")
13 | else
14 | send_msg(msg.to.id, lang_text(msg.to.id, 'privateMSG'), "md")
15 |
16 |
17 | end
18 | elseif matches[1] == "creategroup" and matches[2] and permissions(msg.from.id, msg.to.id, "creategroup") then
19 | createNewGroupChat({[0] = msg.from.id}, matches[2], groupcb)
20 | end
21 | end
22 |
23 | function groupcb(extra,data)
24 | local group_id = "-" .. data.type_.group_.id_
25 | if not group_id then
26 | send_msg(msg.from.id, lang_text(msg.to.id, 'privateError'), "md")
27 | else
28 | migrateGroupChatToChannelChat(group_id, migratecb)
29 | end
30 | end
31 |
32 | function migratecb(extra, result)
33 | local channel_id = result.id_
34 | if channel_id then
35 | send_msg(channel_id, lang_text(msg.to.id, 'privateSuper'), "md")
36 | getChannelMembers(channel_id, 0, 'Recent', 2, promote_members_cb, channel_id)
37 | else
38 | send_msg(msg.to.id, lang_text(msg.to.id, 'privateError'), "md")
39 | end
40 | end
41 |
42 | function promote_members_cb(extra, result)
43 | changeChatMemberStatus(extra, result.members_[1].user_id_, "Editor", ok_cb)
44 | end
45 |
46 | return {
47 | patterns = {
48 | "^[!/#]([sS][tT][Aa][rR][tT])",
49 | "^[!/#]([Hh][eE][Ll][pP])",
50 | "^[!/#]([Cc]reategroup) (.*)"
51 | },
52 | run = run,
53 | }
54 |
--------------------------------------------------------------------------------
/plugins/promote.lua:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------
2 | -- ___ ___ _____ __ _____ --
3 | -- | \| _ )_ _|__ __ _ _ _\ \ / /_ ) --
4 | -- | |) | _ \ | |/ -_) _` | ' \ V / / / --
5 | -- |___/|___/ |_|\___\__,_|_|_|_\_/ /___| --
6 | -- --
7 | ----------------------------------------------------
8 |
9 | local function run(msg, matches)
10 | if matches[1] == "add" then
11 | if permissions(msg.from.id, msg.to.id, "add_moderation") then
12 | redis:set("moderation_group: " .. msg.to.id, true)
13 | send_msg(msg.to.id, "Group added to moderation list.", "html")
14 | end
15 | end
16 | if matches[1] == "rem" then
17 | if permissions(msg.from.id, msg.to.id, "add_moderation") then
18 | redis:del("moderation_group: " .. msg.to.id)
19 | send_msg(msg.to.id, "Group removed from moderation list.", "html")
20 | end
21 | end
22 | if redis:get("moderation_group: " .. msg.to.id) then
23 | if matches[1] == "admin" then
24 | if permissions(msg.from.id, msg.to.id, "promote_admin") then
25 | if msg.reply_id then
26 | redis:sadd('admins', msg.replied.id)
27 | redis:srem('mods:'..msg.to.id, msg.replied.id)
28 | send_msg(msg.to.id, lang_text(msg.to.id, 'newAdmin') .. ": @" .. (msg.replied.username or msg.replied.first_name), "html")
29 | elseif not is_number(matches[2]) then
30 | resolve_username(matches[2], resolve_cb, {chat_id = msg.to.id, superior = msg.from.id, plugin_tag = "promote_admin", command = "admin"})
31 | elseif is_number(matches[2]) then
32 | redis:sadd('admins', matches[2])
33 | redis:srem('mods:'..msg.to.id, matches[2])
34 | send_msg(msg.to.id, lang_text(msg.to.id, 'newAdmin') .. ": " .. matches[2], "html")
35 | end
36 | end
37 | elseif matches[1] == "mod" then
38 | if permissions(msg.from.id, msg.to.id, "promote_mod") then
39 | if msg.reply_id and not matches[2] then
40 | redis:sadd('mods:'..msg.to.id, msg.replied.id)
41 | if new_is_sudo(msg.from.id) then
42 | redis:srem('admins', msg.replied.id)
43 | end
44 | send_msg(msg.to.id, lang_text(msg.to.id, 'newMod') .. ": @" .. (msg.replied.username or msg.replied.first_name), "html")
45 | elseif not is_number(matches[2]) then
46 | resolve_username(matches[2], resolve_cb, {chat_id = msg.to.id, superior = msg.from.id, plugin_tag = "promote_mod", command = "mod"})
47 | elseif is_number(matches[2]) then
48 | redis:sadd('mods:'..msg.to.id, matches[2])
49 | if new_is_sudo(msg.from.id) then
50 | redis:srem('admins', matches[2])
51 | end
52 | send_msg(msg.to.id, lang_text(msg.to.id, 'newMod') .. ": " .. matches[2], "html")
53 | end
54 | end
55 | elseif matches[1] == "user" then
56 | if permissions(msg.from.id, msg.to.id, "promote_user") then
57 | if msg.reply_id and not matches[2] then
58 | if new_is_sudo(msg.from.id) then
59 | redis:srem('mods:'..msg.to.id, msg.replied.id)
60 | redis:srem('admins', msg.replied.id)
61 | elseif is_admin(msg.from.id) then
62 | redis:srem('mods:'..msg.to.id, msg.replied.id)
63 | end
64 | send_msg(msg.to.id, ">
@" .. (msg.replied.username or msg.replied.first_name) .. "" .. lang_text(msg.to.id, 'nowUser'), "html")
65 | elseif not is_number(matches[2]) then
66 | resolve_username(matches[2], resolve_cb, {chat_id = msg.to.id, superior = msg.from.id, plugin_tag = "promote_user", command = "user"})
67 | elseif is_number(matches[2]) then
68 | if new_is_sudo(msg.from.id) then
69 | redis:srem('mods:'..msg.to.id, matches[2])
70 | redis:srem('admins', matches[2])
71 | elseif is_admin(msg.from.id) then
72 | redis:srem('mods:'..msg.to.id, matches[2])
73 | end
74 | send_msg(msg.to.id, ">
" .. matches[2] .. lang_text(msg.to.id, 'nowUser'), "html")
75 | end
76 | end
77 | elseif matches[1] == "admins" then
78 | if permissions(msg.from.id, msg.to.id, "promote_user") then
79 | local text = "Admins:\n"
80 | for k, v in pairs(redis:smembers("admins")) do
81 | text = text .. ">
" .. (redis:hget('bot:ids', v) or "user_not_known" ) .. " (" .. v .. ")
\n"
82 | end
83 | send_msg(msg.to.id, text, 'html')
84 | end
85 | elseif matches[1] == "mods" then
86 | if permissions(msg.from.id, msg.to.id, "moderation") then
87 | local text = "Mods:\n"
88 | for k, v in pairs(redis:smembers("mods:" .. msg.to.id)) do
89 | text = text .. ">
" .. (redis:hget('bot:ids', v) or "user_not_known" ) .. " (" .. v .. ")
\n"
90 | end
91 | send_msg(msg.to.id, text, 'html')
92 | end
93 | elseif matches[1] == "kicked" then
94 | if permissions(msg.from.id, msg.to.id, "tagall") then
95 | getChannelMembers(msg.to.id, 0, 'Kicked', 200, kicked_cb, msg.to.id)
96 | end
97 | elseif matches[1] == "banall" then
98 | if permissions(msg.from.id, msg.to.id, "banall") then
99 | getChannelMembers(msg.to.id, 0, 'Recent', 200, banall_cb, msg.to.id)
100 | end
101 | end
102 | else
103 | print("\27[32m> Not moderating this group.\27[39m")
104 | end
105 | if matches[1] == "users" or matches[1] == "members" or matches[1] == "tagall" then
106 | if permissions(msg.from.id, msg.to.id, "tagall") then
107 | if matches[2] then
108 | getChannelMembers(msg.to.id, 0, 'Recent', 200, members_cb, {chat = msg.to.id, text = matches[2]})
109 | else
110 | getChannelMembers(msg.to.id, 0, 'Recent', 200, members_cb, {chat = msg.to.id, text = nil})
111 | end
112 | end
113 | elseif matches[1] == "bots" then
114 | if permissions(msg.from.id, msg.to.id, "tagall") then
115 | getChannelMembers(msg.to.id, 0, 'Bots', 200, bots_cb, msg.to.id)
116 | end
117 |
118 | elseif matches[1] == "leave" then
119 | if permissions(msg.from.id, msg.to.id, "leave") then
120 | send_msg(msg.to.id, lang_text(msg.to.id, 'leave'), 'html')
121 | removeFromBanList(msg.to.id, _config.our_id[1])
122 | end
123 | elseif matches[1] == "setabout" and matches[2] then
124 | if permissions(msg.from.id, msg.to.id, "setabout") then
125 | changeAbout(matches[2], ok_cb)
126 | send_msg(msg.to.id, lang_text(msg.to.id, 'setAbout') .. matches[2], 'html')
127 | end
128 | end
129 | end
130 |
131 | function members_cb(extra, data)
132 | openChat(msg.to.id, opencb)
133 | local count = data.total_count_
134 | if not count then
135 | send_msg(extra.chat, lang_text(msg.to.id, 'error1'), 'html')
136 | end
137 | local count2 = count
138 | text = "Users ("..count.."): \n"
139 | for k,v in pairs(data.members_) do
140 | if v.user_id_ then
141 | count2 = count2 - 1
142 | resolve_id(v.user_id_, resolveid_cb, {userid = v.user_id_ , send = count2, chat = extra.chat, text = extra.text})
143 | end
144 | end
145 | end
146 |
147 | function banall_cb(extra, data)
148 | send_msg(extra, lang_text(msg.to.id, 'banall'), 'html')
149 | for k,user in pairs(data.members_) do
150 | if user.user_id_ ~= _config.our_id[1] and not new_is_sudo(user.user_id_) and not is_admin(user.user_id_) and not is_mod(extra, user.user_id_) then
151 | kick_user(extra, user.user_id_)
152 | end
153 | end
154 | end
155 |
156 | function bots_cb(extra, data)
157 | local count = data.total_count_
158 | local count2 = count
159 | text = "Bots: ("..count.."): \n"
160 | for k,v in pairs(data.members_) do
161 | if v.user_id_ then
162 | count2 = count2 - 1
163 | resolve_id(v.user_id_, resolveid_cb, {userid = v.user_id_ , send = count2, chat = extra, text = nil})
164 | end
165 | end
166 | end
167 |
168 | function kicked_cb(extra, data)
169 | local count = data.total_count_
170 | if not count then
171 | send_msg(extra, lang_text(msg.to.id, 'error2'), 'html')
172 | end
173 | local count2 = count
174 | text = "Bans ("..count.."): \n"
175 | for k,v in pairs(data.members_) do
176 | if v.user_id_ then
177 | count2 = count2 - 1
178 | resolve_id(v.inviter_user_id_, resolveid_kicked_cb, {userid = v.inviter_user_id_ , send = count2, chat = extra, status = "kicker", idkicked = v.user_id_})
179 | end
180 | end
181 | end
182 |
183 | function resolveid_kicked_cb(extra,info)
184 | if extra.status == "kicker" then
185 | if info.user_.username_ then
186 | info_from_kicker = '>
@'..info.user_.username_..' '
187 | else
188 | info_from_kicker = '>
'..info.user_.first_name_..' '
189 | end
190 | resolve_id(extra.idkicked, resolveid_kicked_cb, {userid = extra.idkicked , send = extra.send, chat = extra.chat, status = "kicked", infokicker = info_from_kicker })
191 | else
192 | if info then
193 | if info.user_ then
194 | if info.user_.username_ then
195 | text = text..extra.infokicker..'banned @'..info.user_.username_..'\n'
196 | else
197 | text = text..extra.infokicker..'banned '..info.user_.first_name_..'\n'
198 | end
199 | else
200 | text = text .. 'no info \n'
201 | end
202 | else
203 | text = text .. 'no info \n'
204 | end
205 | if extra.send == 0 then
206 | send_msg(extra.chat, text, 'html')
207 | end
208 | end
209 | end
210 |
211 | function resolveid_cb(extra,info)
212 | if info.user_.username_ then
213 | text = text..'>
@'..info.user_.username_.."("..extra.userid..')
\n'
214 | else
215 | text = text..'>
'..info.user_.first_name_.."("..extra.userid..')
\n'
216 | end
217 |
218 | if extra.send == 0 then
219 | if extra.text then
220 | text = text..'\n'..extra.text..''
221 | send_msg(extra.chat, text, 'html')
222 | else
223 | text = text
224 | send_msg(extra.chat, text, 'html')
225 | end
226 | end
227 | end
228 |
229 |
230 |
231 | return {
232 | patterns = {
233 | "^[!/#]([Aa]dd)$",
234 | "^[!/#]([Rr]em)$",
235 | "^[!/#]([Aa]dmin)$",
236 | "^[!/#]([Aa]dmin) (.*)$",
237 | "^[!/#]([Mm]od)$",
238 | "^[!/#]([Mm]od) (.*)$",
239 | "^[!/#]([Uu]ser)$",
240 | "^[!/#]([Uu]ser) (.*)$",
241 | "^[!/#]([Aa]dmins)$",
242 | "^[!/#]([Mm]ods)$",
243 | "^[!/#]([Uu]sers)$",
244 | "^[!/#]([Mm]embers)$",
245 | "^[!/#](tagall)$",
246 | "^[!/#]([Uu]sers) (.*)$",
247 | "^[!/#]([Mm]embers) (.*)$",
248 | "^[!/#](tagall) (.*)$",
249 | "^[!/#](bots)$",
250 | "^[!/#](kicked)$",
251 | "^[!/#](banall)$",
252 | "^[!/#](leave)$",
253 | "^[!/#](setabout) (.*)$",
254 | },
255 | run = run
256 | }
--------------------------------------------------------------------------------
/plugins/settings.lua:
--------------------------------------------------------------------------------
1 | ----------------------------------------------------
2 | -- ___ ___ _____ __ _____ --
3 | -- | \| _ )_ _|__ __ _ _ _\ \ / /_ ) --
4 | -- | |) | _ \ | |/ -_) _` | ' \ V / / / --
5 | -- |___/|___/ |_|\___\__,_|_|_|_\_/ /___| --
6 | -- --
7 | ----------------------------------------------------
8 |
9 | local function get_added_users(msg)
10 | local users = ""
11 | for i = 1, #msg.added, 1 do
12 | if msg.added[i].username then
13 | users = users .. "@" .. msg.added[i].username
14 | elseif msg.added[i].first_name then
15 | users = users .. msg.added[i].first_name
16 | end
17 | if i == (#msg.added - 1) then
18 | users = users .. " & "
19 | elseif i ~= #msg.added then
20 | users = users .. ", "
21 | end
22 | end
23 | return users
24 | end
25 |
26 | function adduser_cb(chat, data)
27 | redis:del("ban:" .. chat .. ":" .. data.id)
28 | addChatMember(chat, data.id)
29 | end
30 |
31 | function send_report(msg,reason)
32 | local user_ = "no username"
33 | if msg.from.username then
34 | user_ = "@" .. msg.from.username
35 | end
36 | local text = 'Spam report:\nUser: '.. user_ ..'(
'..msg.from.id..')-'..msg.from.first_name..'
\nMessage: '..msg.text..'
\nPattern: '..reason..'
'
37 | for v,user in pairs(_config.sudo_users) do
38 | send_msg(user, text, 'html')
39 | end
40 | end
41 |
42 | local function get_exported_link(arg, data)
43 | if data.message then
44 | send_msg(arg, lang_text(arg, 'linkError'), 'md')
45 | else
46 | redis:set("settings:link:" .. arg, data.invite_link)
47 | send_msg(arg, lang_text(arg, 'linkSet'), 'md')
48 | end
49 | end
50 |
51 | local function getlink(arg,data)
52 | local link = data.invite_link
53 | send_msg(msg.to.id, link, 'html')
54 | end
55 |
56 | local function pre_process(msg)
57 | if msg.added then
58 | if redis:get("moderation_group: " .. msg.to.id) then
59 | for k, user in pairs (msg.added) do
60 | if is_gban(user.id) then -- checks if user is gbanned
61 | kick_user(msg.to.id, user.id)
62 | end
63 | if is_mod(msg.to.id, user.id) then -- checks if user is mod
64 | promoteToAdmin(msg.to.id, user.id)
65 | end
66 | if is_admin(user.id) then -- checks if user is admin
67 | promoteToAdmin(msg.to.id, user.id)
68 | end
69 | if new_is_sudo(user.id) then -- checks if user is sudo
70 | promoteToAdmin(msg.to.id, user.id)
71 | end
72 | if user.username then
73 | if string.find(user.username, "([Bb][oO][Tt])$") then -- checks if it is a bot
74 | if redis:get("settings:bots:" .. msg.to.id) then
75 | kick_user(msg.to.id, user.id)
76 | end
77 | end
78 | end
79 | if user.first_name then
80 | if redis:get("settings:arabic:" .. msg.to.id) then -- checks if name with arabic letters, removes the msg and kicks him
81 | if (string.find(user.first_name, "[\216-\219][\128-\191]")) then
82 | delete_msg(msg.to.id, user.id)
83 | kick_user(msg.to.id, user.id)
84 | end
85 | if user.last_name then
86 | if (string.find(user.last_name, "[\216-\219][\128-\191]")) then
87 | delete_msg(msg.to.id, user.id)
88 | kick_user(msg.to.id, user.id)
89 | end
90 | end
91 | end
92 | end
93 | end
94 | end
95 | if redis:get("settings:welcome:"..msg.to.id) then
96 | local users
97 | if #msg.added > 0 then
98 | users = get_added_users(msg)
99 | else
100 | users = msg.added[1]
101 | end
102 | local welcomeText
103 | if redis:get("settings:welcome:msg:" .. msg.to.id) then
104 | welcomeText = redis:get("settings:welcome:msg:" .. msg.to.id):gsub("$users", users):gsub("$id", msg.from.id):gsub("$chatid", msg.to.id)
105 | else
106 | welcomeText = lang_text(msg.to.id, 'defaultWelcome'):gsub("$users", users):gsub("$id", msg.from.id):gsub("$chatid", msg.to.id)
107 | end
108 | send_msg(msg.to.id, welcomeText, 'html')
109 | end
110 | end
111 | if permissions(msg.from.id, msg.to.id, "settings", "silent") then
112 | return msg
113 | end
114 | if msg.text then
115 | if redis:get("settings:spam:" .. msg.to.id) and redis:get("moderation_group: " .. msg.to.id) then
116 | local list = require("data/spam_data")
117 | local customlist = redis:get("settings:setspam:" .. msg.to.id) or "default"
118 | for number, pattern in pairs(list.blacklist[customlist]) do
119 | local matches = match_pattern(pattern, msg.text)
120 | local spam = true
121 | if matches then
122 | if list.whitelist[customlist] then
123 | for number, pattern1 in pairs(list.whitelist[customlist]) do
124 | local matches1 = match_pattern(pattern1, msg.text)
125 | if matches1 then
126 | spam = false
127 | end
128 | end
129 | end
130 | if spam then
131 | if msg.from.username then
132 | user_ = msg.from.username
133 | else
134 | user_ = msg.from.first_name
135 | end
136 | reply_msg(msg.to.id, lang_text(msg.to.id, 'user') .. " *" .. user_ .. "* (" .. msg.from.id .. ") " .. lang_text(msg.to.id, 'isSpamming'), msg.id, 'md')
137 | delete_msg(msg.to.id, msg.id)
138 | if redis:get("settings:reports:" .. msg.to.id) then
139 | send_report(msg,pattern)
140 | end
141 | -- One matches is enough
142 | return msg
143 | end
144 | end
145 | end
146 | end
147 | if redis:get("settings:arabic:" .. msg.to.id) then
148 | if string.find(msg.text, "[\216-\219][\128-\191]") then
149 | delete_msg(msg.to.id, msg.id)
150 | kick_user(msg.to.id, msg.from.id)
151 | send_msg(msg.to.id, "`>` *Arabic is not allowed* in this chat, user kicked.", 'md')
152 | end
153 | end
154 | elseif msg.photo and redis:get("moderation_group: " .. msg.to.id) then
155 | if redis:get("settings:photos:" .. msg.to.id) then
156 | delete_msg(msg.to.id, msg.id)
157 | end
158 | elseif msg.sticker and redis:get("moderation_group: " .. msg.to.id) then
159 | if redis:get("settings:stickers:" .. msg.to.id) then
160 | delete_msg(msg.to.id, msg.id)
161 | end
162 | elseif msg.audio and redis:get("moderation_group: " .. msg.to.id)then
163 | if redis:get("settings:audios:" .. msg.to.id) then
164 | delete_msg(msg.to.id, msg.id)
165 | end
166 | elseif msg.voice and redis:get("moderation_group: " .. msg.to.id)then
167 | if redis:get("settings:voice:" .. msg.to.id) then
168 | delete_msg(msg.to.id, msg.id)
169 | end
170 | elseif msg.gif and redis:get("moderation_group: " .. msg.to.id) then
171 | if redis:get("settings:gifs:" .. msg.to.id) then
172 | delete_msg(msg.to.id, msg.id)
173 | end
174 | elseif msg.service and redis:get("moderation_group: " .. msg.to.id) then -- Only group creator can delete this messages
175 | if redis:get("settings:tgservices:" .. msg.to.id) then
176 | delete_msg(msg.to.id, msg.id)
177 | end
178 | elseif msg.video and redis:get("moderation_group: " .. msg.to.id) then
179 | if redis:get("settings:videos:" .. msg.to.id) then
180 | delete_msg(msg.to.id, msg.id)
181 | end
182 | elseif msg.document and redis:get("moderation_group: " .. msg.to.id) then
183 | if redis:get("settings:documents:" .. msg.to.id) then
184 | delete_msg(msg.to.id, msg.id)
185 | end
186 | elseif msg.forward and redis:get("moderation_group: " .. msg.to.id) then
187 | if redis:get("settings:forward:" .. msg.to.id) then
188 | delete_msg(msg.to.id, msg.forward.msg_id)
189 | end
190 | end
191 | if redis:get("settings:flood:" .. msg.to.id) and redis:get("moderation_group: " .. msg.to.id) then
192 | local maxFlood = tonumber(redis:get("settings:maxFlood:" .. msg.to.id)) or 5
193 | local floodTime = tonumber(redis:get("settings:floodTime:" .. msg.to.id)) or 3
194 | local hash = 'flood:'..msg.from.id..':'..msg.to.id..':msg-num'
195 | local msgs = tonumber(redis:get(hash) or 0)
196 | if msgs > maxFlood then
197 | local user = msg.from.id
198 | local chat = msg.to.id
199 | local username = msg.from.username or "username"
200 | if not redis:get("settings:flood:user:" .. msg.from.id) then
201 | send_msg(msg.to.id, lang_text(chat, 'user')..' @'.. username ..' ('..msg.from.id..') ' .. lang_text(chat, 'isFlooding'), 'md')
202 | end
203 | redis:setex("settings:flood:user:" .. msg.from.id, 60, true)
204 | kick_user(msg.to.id, msg.from.id)
205 | msg.text = ""
206 | return msg
207 | end
208 | redis:setex(hash, floodTime, msgs+1)
209 | end
210 | return msg
211 | end
212 |
213 | local function run(msg, matches)
214 | if matches[1] == 'lang' then
215 | if permissions(msg.from.id, msg.to.id, 'set_lang') then
216 | hash = 'langset:'..msg.to.id
217 | redis:set(hash, matches[2])
218 | return lang_text(msg.to.id, 'langUpdated')..string.upper(matches[2])
219 | else
220 | return '🚫 '..lang_text(msg.to.id, 'require_sudo')
221 | end
222 | elseif matches[1]:lower() == "settings" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
223 | local settings = "*" .. lang_text(msg.to.id, 'groupSettings') .. ":*\n"
224 | -- Check TgServices
225 | if redis:get("settings:tgservices:" .. msg.to.id) then
226 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'tgservices') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
227 | else
228 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'tgservices') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
229 | end
230 | -- Check Invite
231 | if redis:get("settings:invite:" .. msg.to.id) then
232 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'invite') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
233 | else
234 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'invite') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
235 | end
236 | -- Check Bots
237 | if redis:get("settings:bots:" .. msg.to.id) then
238 | settings = settings .. "`>` *Bots:* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
239 | else
240 | settings = settings .. "`>` *Bots:* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
241 | end
242 | -- Check Language
243 | if redis:get("langset:" .. msg.to.id) then
244 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'language') .. ":* `" .. redis:get("langset:" .. msg.to.id) .. "`\n"
245 | else
246 | redis:set("langset:" .. msg.to.id, 'en')
247 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'language') .. ":* `" .. redis:get("langset:" .. msg.to.id) .. "`\n"
248 | end
249 | settings = settings.. "\n*" .. lang_text(msg.to.id, 'allowedMedia') .. " :*\n"
250 | -- Check Photos
251 | if redis:get("settings:photos:" .. msg.to.id) then
252 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'photos') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
253 | else
254 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'photos') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
255 | end
256 | -- Check Videos
257 | if redis:get("settings:videos:" .. msg.to.id) then
258 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'videos') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
259 | else
260 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'videos') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
261 | end
262 | -- Check Stickers
263 | if redis:get("settings:stickers:" .. msg.to.id) then
264 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'stickers') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
265 | else
266 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'stickers') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
267 | end
268 | -- Check Gifs
269 | if redis:get("settings:gifs:" .. msg.to.id) then
270 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'gifs') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
271 | else
272 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'gifs') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
273 | end
274 | -- Check Voice
275 | if redis:get("settings:voice:" .. msg.to.id) then
276 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'voice') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
277 | else
278 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'voice') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
279 | end
280 | -- Check Audios
281 | if redis:get("settings:audios:" .. msg.to.id) then
282 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'audios') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
283 | else
284 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'audios') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
285 | end
286 | -- Check Documents
287 | if redis:get("settings:documents:" .. msg.to.id) then
288 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'documents') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
289 | else
290 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'documents') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
291 | end
292 | -- Check Location
293 | if redis:get("settings:location:" .. msg.to.id) then
294 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'location') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
295 | else
296 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'location') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
297 | end
298 | -- Check Games
299 | if redis:get("settings:games:" .. msg.to.id) then
300 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'games') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
301 | else
302 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'games') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
303 | end
304 |
305 | settings = settings.. "\n*" .. lang_text(msg.to.id, 'settingsText') .. ":*\n"
306 |
307 | -- Check Forward
308 | if redis:get("settings:forward:" .. msg.to.id) then
309 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'forward') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
310 | else
311 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'forward') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
312 | end
313 | -- Check Spam
314 | if redis:get("settings:spam:" .. msg.to.id) then
315 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'spam') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
316 | else
317 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'spam') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
318 | end
319 | -- Get Spam
320 | if redis:get("settings:spam:type" .. msg.to.id) then
321 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'spam') .. ":* `" .. redis:get("settings:spam:type" .. msg.to.id) .. "`\n"
322 | else
323 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'spam') .. ":* `default `\n"
324 | end
325 | -- Send report
326 | if redis:get("settings:reports:" .. msg.to.id) then
327 | settings = settings .. "`>` *Reports:* `activated`\n" --translations
328 | else
329 | settings = settings .. "`>` *Reports:* `disabled`\n" --translations
330 | end
331 | -- Check Flood
332 | if redis:get("settings:flood:" .. msg.to.id) then
333 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'flood') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
334 | else
335 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'flood') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
336 | end
337 | -- Check maxFlood
338 | if redis:get("settings:maxFlood:" .. msg.to.id) then
339 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'mFlood') .. ":* `" .. redis:get("settings:maxFlood:" .. msg.to.id) .. "`\n"
340 | else
341 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'mFlood') .. ":* `5`\n"
342 | end
343 | -- Check timeFlood
344 | if redis:get("settings:floodTime:" .. msg.to.id) then
345 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'tFlood') .. ":* `" .. redis:get("settings:floodTime:" .. msg.to.id) .. "`\n"
346 | else
347 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'tFlood') .. ":* `3`\n"
348 | end
349 | -- Check Arabic
350 | if redis:get("settings:arabic:" .. msg.to.id) then
351 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'arabic') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
352 | else
353 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'arabic') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
354 | end
355 | -- Check English
356 | if redis:get("settings:english:" .. msg.to.id) then
357 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'english') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
358 | else
359 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'english') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
360 | end
361 | -- Check Emojis
362 | if redis:get("settings:emojis:" .. msg.to.id) then
363 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'emojis') .. ":* `" .. lang_text(msg.to.id, 'noAllowed') .. "`\n"
364 | else
365 | settings = settings .. "`>` *" .. lang_text(msg.to.id, 'emojis') .. ":* `" .. lang_text(msg.to.id, 'allowed') .. "`\n"
366 | end
367 |
368 | send_msg(msg.to.id, settings, 'md')
369 | elseif matches[1] == "tgservices" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
370 | if matches[2] == 'off' then
371 | redis:set("settings:tgservices:" .. msg.to.id, true)
372 | send_msg(msg.to.id, lang_text(msg.to.id, 'noTgservicesT'), 'md')
373 | elseif matches[2] == 'on' then
374 | redis:del("settings:tgservices:" .. msg.to.id)
375 | send_msg(msg.to.id, lang_text(msg.to.id, 'tgservicesT'), 'md')
376 | end
377 | elseif matches[1] == "invite" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
378 | if matches[2] == 'off' then
379 | redis:set("settings:invite:" .. msg.to.id, true)
380 | send_msg(msg.to.id, lang_text(msg.to.id, 'noInviteT'), 'md')
381 | elseif matches[2] == 'on' then
382 | redis:del("settings:invite:" .. msg.to.id)
383 | send_msg(msg.to.id, lang_text(msg.to.id, 'inviteT'), 'md')
384 | end
385 | elseif matches[1] == "bots" then
386 | if matches[2] == 'off' then
387 | redis:set("settings:bots:" .. msg.to.id, true)
388 | send_msg(msg.to.id, "`>` *Bots* are now *not allowed* in this chat.", 'md')
389 | elseif matches[2] == 'on' then
390 | redis:del("settings:bots:" .. msg.to.id)
391 | send_msg(msg.to.id, "`>` *Bots* are now *allowed* in this chat.", 'md')
392 | end
393 | elseif matches[1] == "photos" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
394 | if matches[2] == 'off' then
395 | redis:set("settings:photos:" .. msg.to.id, true)
396 | send_msg(msg.to.id, lang_text(msg.to.id, 'noPhotosT'), 'md')
397 | elseif matches[2] == 'on' then
398 | redis:del("settings:photos:" .. msg.to.id)
399 | send_msg(msg.to.id, lang_text(msg.to.id, 'photosT'), 'md')
400 | end
401 | elseif matches[1] == "videos" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
402 | if matches[2] == 'off' then
403 | redis:set("settings:videos:" .. msg.to.id, true)
404 | send_msg(msg.to.id, lang_text(msg.to.id, 'noVideosT'), 'md')
405 | elseif matches[2] == 'on' then
406 | redis:del("settings:videos:" .. msg.to.id)
407 | send_msg(msg.to.id, lang_text(msg.to.id, 'videosT'), 'md')
408 | end
409 | elseif matches[1] == "stickers" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
410 | if matches[2] == 'off' then
411 | redis:set("settings:stickers:" .. msg.to.id, true)
412 | send_msg(msg.to.id, lang_text(msg.to.id, 'noStickersT'), 'md')
413 | elseif matches[2] == 'on' then
414 | redis:del("settings:stickers:" .. msg.to.id)
415 | send_msg(msg.to.id, lang_text(msg.to.id, 'stickersT'), 'md')
416 | end
417 | elseif matches[1] == "gifs" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
418 | if matches[2] == 'off' then
419 | redis:set("settings:gifs:" .. msg.to.id, true)
420 | send_msg(msg.to.id, lang_text(msg.to.id, 'noGifsT'), 'md')
421 | elseif matches[2] == 'on' then
422 | redis:del("settings:gifs:" .. msg.to.id)
423 | send_msg(msg.to.id, lang_text(msg.to.id, 'gifsT'), 'md')
424 | end
425 | elseif matches[1] == "voice" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
426 | if matches[2] == 'off' then
427 | redis:set("settings:voice:" .. msg.to.id, true)
428 | send_msg(msg.to.id, lang_text(msg.to.id, 'noVoiceT'), 'md')
429 | elseif matches[2] == 'on' then
430 | redis:del("settings:voice:" .. msg.to.id)
431 | send_msg(msg.to.id, lang_text(msg.to.id, 'voiceT'), 'md')
432 | end
433 | elseif matches[1] == "audios" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
434 | if matches[2] == 'off' then
435 | redis:set("settings:audios:" .. msg.to.id, true)
436 | send_msg(msg.to.id, lang_text(msg.to.id, 'noAudiosT'), 'md')
437 | elseif matches[2] == 'on' then
438 | redis:del("settings:audios:" .. msg.to.id)
439 | send_msg(msg.to.id, lang_text(msg.to.id, 'audiosT'), 'md')
440 | end
441 | elseif matches[1] == "documents" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
442 | if matches[2] == 'off' then
443 | redis:set("settings:documents:" .. msg.to.id, true)
444 | send_msg(msg.to.id, lang_text(msg.to.id, 'noDocumentsT'), 'md')
445 | elseif matches[2] == 'on' then
446 | redis:del("settings:documents:" .. msg.to.id)
447 | send_msg(msg.to.id, lang_text(msg.to.id, 'documentsT'), 'md')
448 | end
449 | elseif matches[1] == "location" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
450 | if matches[2] == 'off' then
451 | redis:set("settings:location:" .. msg.to.id, true)
452 | send_msg(msg.to.id, lang_text(msg.to.id, 'noLocationT'), 'md')
453 | elseif matches[2] == 'on' then
454 | redis:del("settings:location:" .. msg.to.id)
455 | send_msg(msg.to.id, lang_text(msg.to.id, 'locationT'), 'md')
456 | end
457 | elseif matches[1] == "games" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
458 | if matches[2] == 'off' then
459 | redis:set("settings:games:" .. msg.to.id, true)
460 | send_msg(msg.to.id, lang_text(msg.to.id, 'noGamesT'), 'md')
461 | elseif matches[2] == 'on' then
462 | redis:del("settings:games:" .. msg.to.id)
463 | send_msg(msg.to.id, lang_text(msg.to.id, 'gamesT'), 'md')
464 | end
465 | elseif matches[1] == "forward" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
466 | if matches[2] == 'off' then
467 | redis:set("settings:forward:" .. msg.to.id, true)
468 | send_msg(msg.to.id, lang_text(msg.to.id, 'noForwardT'), 'md')
469 | elseif matches[2] == 'on' then
470 | redis:del("settings:forward:" .. msg.to.id)
471 | send_msg(msg.to.id, lang_text(msg.to.id, 'forwardT'), 'md')
472 | end
473 | elseif matches[1] == "spam" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
474 | if matches[2] == 'off' then
475 | redis:set("settings:spam:" .. msg.to.id, true)
476 | send_msg(msg.to.id, lang_text(msg.to.id, 'noSpamT'), 'md')
477 | elseif matches[2] == 'on' then
478 | redis:del("settings:spam:" .. msg.to.id)
479 | send_msg(msg.to.id, lang_text(msg.to.id, 'spamT'), 'md')
480 | end
481 | elseif matches[1] == "setspam" and permissions(msg.from.id, msg.to.id, "settings") and matches[2] and redis:get("moderation_group: " .. msg.to.id) then
482 | redis:set("settings:setspam:" .. msg.to.id, matches[2])
483 | send_msg(msg.to.id, lang_text(msg.to.id, 'setSpam') .. "*" .. matches[2] .. "*.", 'md')
484 | elseif matches[1] == "reports" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
485 | if matches[2] == 'on' then
486 | redis:set("settings:reports:" .. msg.to.id, true)
487 | send_msg(msg.to.id, "`>` *Spam reports* are now *activated* in this chat.", 'md') -- translations
488 | elseif matches[2] == 'off' then
489 | redis:del("settings:reports:" .. msg.to.id)
490 | send_msg(msg.to.id, "`>` *Spam reports* are *disabled* in this chat.", 'md') -- translations
491 | end
492 | elseif matches[1] == "arabic" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
493 | if matches[2] == 'off' then
494 | redis:set("settings:arabic:" .. msg.to.id, true)
495 | send_msg(msg.to.id, lang_text(msg.to.id, 'noArabicT'), 'md')
496 | elseif matches[2] == 'on' then
497 | redis:del("settings:arabic:" .. msg.to.id)
498 | send_msg(msg.to.id, lang_text(msg.to.id, 'arabicT'), 'md')
499 | end
500 | elseif matches[1] == "english" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
501 | if matches[2] == 'off' then
502 | redis:set("settings:english:" .. msg.to.id, true)
503 | send_msg(msg.to.id, lang_text(msg.to.id, 'noEnglishT'), 'md')
504 | elseif matches[2] == 'on' then
505 | redis:del("settings:english:" .. msg.to.id)
506 | send_msg(msg.to.id, lang_text(msg.to.id, 'englishT'), 'md')
507 | end
508 | elseif matches[1] == "emojis" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
509 | if matches[2] == 'off' then
510 | redis:set("settings:emojis:" .. msg.to.id, true)
511 | send_msg(msg.to.id, lang_text(msg.to.id, 'noEmojisT'), 'md')
512 | elseif matches[2] == 'on' then
513 | redis:del("settings:emojis:" .. msg.to.id)
514 | send_msg(msg.to.id, lang_text(msg.to.id, 'emojisT'), 'md')
515 | end
516 | elseif matches[1] == "flood" and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
517 | if matches[2] == 'off' then
518 | redis:set("settings:flood:" .. msg.to.id, true)
519 | send_msg(msg.to.id, lang_text(msg.to.id, 'noFloodT'), 'md')
520 | elseif matches[2] == 'on' then
521 | redis:del("settings:flood:" .. msg.to.id)
522 | send_msg(msg.to.id, lang_text(msg.to.id, 'floodT'), 'md')
523 | end
524 | elseif matches[1] == "welcome" and permissions(msg.from.id, msg.to.id, "settings") then
525 | if matches[2] == 'off' then
526 | redis:del("settings:welcome:" .. msg.to.id)
527 | send_msg(msg.to.id, lang_text(msg.to.id, 'noWelcomeT'), 'md')
528 | elseif matches[2] == 'on' then
529 | redis:set("settings:welcome:" .. msg.to.id, true)
530 | send_msg(msg.to.id, lang_text(msg.to.id, 'welcomeT'), 'md')
531 | end
532 | elseif matches[1] == "setwelcome" and permissions(msg.from.id, msg.to.id, "settings") then
533 | if tonumber(matches[2]) == 0 then
534 | redis:del("settings:welcome:msg:" .. msg.to.id)
535 | send_msg(msg.to.id, lang_text(msg.to.id, 'weldefault'), 'md')
536 | else
537 | redis:set("settings:welcome:msg:" .. msg.to.id, matches[2])
538 | send_msg(msg.to.id, lang_text(msg.to.id, 'welnew') .. matches[2], 'md')
539 | end
540 | elseif matches[1] == "max" and is_number(matches[2]) and permissions(msg.from.id, msg.to.id, "settings")and redis:get("moderation_group: " .. msg.to.id) then
541 | if tonumber(matches[2]) == 0 then
542 | redis:del("settings:maxFlood:" .. msg.to.id)
543 | send_msg(msg.to.id, lang_text(msg.to.id, 'floodTime') .. ": `3`", 'md')
544 | else
545 | redis:set("settings:maxFlood:" .. msg.to.id, tonumber(matches[2]))
546 | send_msg(msg.to.id, lang_text(msg.to.id, 'floodTime') .. ": `" .. matches[2] .. "`", 'md')
547 | end
548 | elseif matches[1] == "time" and is_number(matches[2]) and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
549 | if tonumber(matches[2]) == 0 then
550 | redis:del("settings:floodTime:" .. msg.to.id)
551 | send_msg(msg.to.id, lang_text(msg.to.id, 'floodMax') .. ": `5`", 'md')
552 | else
553 | redis:set("settings:floodTime:" .. msg.to.id, tonumber(matches[2]))
554 | send_msg(msg.to.id, lang_text(msg.to.id, 'floodMax') .. ": `" .. matches[2] .. "`", 'md')
555 | end
556 | elseif matches[1]:lower() == "setlink" and matches[2] and permissions(msg.from.id, msg.to.id, "settings") then
557 | redis:set("settings:link:" .. msg.to.id, matches[2])
558 | send_msg(msg.to.id, lang_text(msg.to.id, 'linkSet'), 'md')
559 | elseif matches[1]:lower() == "newlink" and not matches[2] and permissions(msg.from.id, msg.to.id, "settings") then
560 | export_link(msg.to.id, get_exported_link, msg.to.id)
561 | elseif matches[1]:lower() == "link" and not matches[2] then
562 | local link = redis:get("settings:link:" .. msg.to.id)
563 | if link then
564 | send_msg(msg.to.id, link, 'html')
565 | else
566 | getChannelFull(msg.to.id, getlink)
567 | end
568 | elseif matches[1]:lower() == "rules" and not matches[2] and redis:get("moderation_group: " .. msg.to.id) then
569 | if not redis:get("settings:norules:" .. msg.to.id) then
570 | if redis:get("settings:rules:" .. msg.to.id) then
571 | send_msg(msg.to.id, redis:get("settings:rules:" .. msg.to.id), 'md')
572 | else
573 | send_msg(msg.to.id, lang_text(msg.to.id, 'defaultRules'), 'md')
574 | end
575 | end
576 | elseif matches[1]:lower() == "setrules" and matches[2] and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
577 | redis:set("settings:rules:" .. msg.to.id, matches[2])
578 | redis:del("settings:norules:" .. msg.to.id)
579 | send_msg(msg.to.id, lang_text(msg.to.id, 'newRules'), 'md')
580 | elseif matches[1]:lower() == "norules" and not matches[2] and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
581 | redis:del("settings:rules:" .. msg.to.id, matches[2])
582 | redis:set("settings:norules:" .. msg.to.id, true)
583 | send_msg(msg.to.id, lang_text(msg.to.id, 'noRules'), 'md')
584 | elseif matches[1]:lower() == "remrules" and not matches[2] and permissions(msg.from.id, msg.to.id, "settings") and redis:get("moderation_group: " .. msg.to.id) then
585 | redis:del("settings:rules:" .. msg.to.id, matches[2])
586 | send_msg(msg.to.id, lang_text(msg.to.id, 'rulesDefault'), 'md')
587 | elseif matches[1]:lower() == "adduser" and permissions(msg.from.id, msg.to.id, "adduser") then
588 | if matches[2] then
589 | if is_number(matches[2]) then
590 | redis:del("ban:" .. msg.to.id .. ":" .. matches[2])
591 | addChatMember(msg.to.id, matches[2])
592 | else
593 | resolve_username(matches[2], adduser_cb, msg.to.id)
594 | end
595 | elseif msg.reply_id then
596 | redis:del("ban:" .. msg.to.id .. ":" .. msg.replied.id)
597 | addChatMember(msg.to.id, msg.replied.id)
598 | end
599 | end
600 |
601 | end
602 |
603 | return {
604 | patterns = {
605 | '^[!/#]([Aa]dduser)$',
606 | '^[!/#]([Aa]dduser) (.*)$',
607 | '^[!/#]([Ss]ettings)$',
608 | '^[!/#](lang) (.*)$',
609 | '^[!/#](tgservices) (.*)$',
610 | '^[!/#](invite) (.*)$',
611 | '^[!/#](bots) (.*)$',
612 | '^[!/#](photos) (.*)$',
613 | '^[!/#](videos) (.*)$',
614 | '^[!/#](stickers) (.*)$',
615 | '^[!/#](gifs) (.*)$',
616 | '^[!/#](voice) (.*)$',
617 | '^[!/#](audios) (.*)$',
618 | '^[!/#](documents) (.*)$',
619 | '^[!/#](location) (.*)$',
620 | '^[!/#](games) (.*)$',
621 | '^[!/#](forward) (.*)$',
622 | '^[!/#](spam) (.*)$',
623 | '^[!/#](setspam) (.*)$',
624 | '^[!/#](reports) (.*)$',
625 | '^[!/#](arabic) (.*)$',
626 | '^[!/#](english) (.*)$',
627 | '^[!/#](emojis) (.*)$',
628 | '^[!/#](flood) (.*)$',
629 | '^[!/#](welcome) (.*)$',
630 | '^[!/#](setwelcome) (.*)$',
631 | '^[!/#](max) (.*)$',
632 | '^[!/#](time) (.*)$',
633 | '^[!/#]([Ss]et[Ll]ink) (.*)$',
634 | '^[!/#]([Nn]ew[Ll]ink)$',
635 | '^[!/#]([Ll]ink)$',
636 | '^[!/#]([Rr]ules)$',
637 | '^[!/#]([Ss]et[Rr]ules) (.*)$',
638 | '^[!/#]([Rr]em[Rr]ules)$',
639 | '^[!/#]([Nn]o[Rr]ules)$'
640 | },
641 | run = run,
642 | pre_process = pre_process
643 | }
644 |
--------------------------------------------------------------------------------
/plugins/stats.lua:
--------------------------------------------------------------------------------
1 | local function sort_(tbl, sortFunction)
2 | local keys = {}
3 | for key in pairs(tbl) do
4 | table.insert(keys, key)
5 | end
6 | table.sort(keys, function(a, b)
7 | return sortFunction(tbl[a], tbl[b])
8 | end)
9 | return keys
10 | end
11 |
12 | local function get_name(chatid, id)
13 | hash = "statsn:"..chatid
14 | ok = redis:hget(hash, tostring(id))
15 | if ok then
16 | to_space = string.find(ok, " ")
17 | if to_space then
18 | return string.sub(ok, 0, to_space)
19 | end
20 | return ok
21 | end
22 | return false
23 | end
24 |
25 | local function get_msgs(chatid, id)
26 | hash = "stats:"..chatid
27 | ok = redis:hget(hash, tostring(id))
28 | if ok then
29 | return tonumber(ok)
30 | end
31 | return tonumber(0)
32 | end
33 |
34 | local function get_ranking(chatid, first_message)
35 | local user = first_message
36 | hash = "stats:"..chatid
37 | local reg = redis:hkeys(hash)
38 | local lista = {}
39 | for i,x in pairs(reg) do
40 | local total = get_msgs(chatid, x)
41 | lista[x] = tonumber(total)
42 | end
43 | local tabla = sort_(lista, function(a, b) return a > b end)
44 | for i,x in pairs(tabla) do
45 | if i > 20 then break end
46 | if i == 1 then
47 | user = user.."\n "..i.."° 🏆 `"..get_name(chatid, x).." ➝ "..lista[x].."`"
48 | elseif i == 2 then
49 | user = user.."\n "..i.."° ⭐️ `"..get_name(chatid, x).." ➝ "..lista[x].."`"
50 | elseif i == 3 then
51 | user = user.."\n "..i.."° 🔥 `"..get_name(chatid, x).." ➝ "..lista[x].."`"
52 | else
53 | user = user.."\n "..i.."° `"..get_name(chatid, x).." ➝ "..lista[x].."`"
54 | end
55 | end
56 | return user
57 | end
58 |
59 | local function pre_process(msg)
60 | if msg.from.id then
61 | hash = "stats:"..msg.to.id
62 | hash2 = "statsn:"..msg.to.id
63 | redis:hincrby(hash, msg.from.id, 1)
64 | redis:hset(hash2, msg.from.id, msg.from.first_name)
65 | end
66 | return msg
67 | end
68 |
69 |
70 | local function run(msg, matches)
71 | if matches[1] == "stats" then
72 | ranking = get_ranking(msg.to.id, lang_text(msg.to.id, 'stats'))
73 | send_msg(msg.to.id, ranking, "md")
74 | end
75 | end
76 | return {
77 | patterns = {
78 | "^[!/#](stats)$"
79 | },
80 | run = run,
81 | pre_process = pre_process
82 | }
83 |
--------------------------------------------------------------------------------