Advertisement
Guest User

Untitled

a guest
Feb 11th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.97 KB | None | 0 0
  1. -- Editing this file directly is now highly disencouraged. You should instead use environment variables. This new method is a WIP, so if you need to change something which doesn't have a env var, you are encouraged to open an issue or a PR
  2. local json = require 'cjson'
  3. local open = io.open
  4.  
  5. local function read_secret(path)
  6. local file = open('/run/secrets/'..path, "rb")
  7. if not file then return nil end
  8. local content = file:read "*a"
  9. file:close()
  10. return content
  11. end
  12.  
  13. local _M =
  14. {
  15. -- Getting updates
  16. telegram =
  17. {
  18. token = assert(read_secret('telegram/token') or os.getenv('TG_TOKEN'),
  19. 'You must export $TG_TOKEN with your Telegram Bot API token'),
  20. allowed_updates = os.getenv('TG_UPDATES') or {'message', 'edited_message', 'callback_query'},
  21. polling =
  22. {
  23. limit = os.getenv('TG_POLLING_LIMIT'), -- Not implemented
  24. timeout = os.getenv('TG_POLLING_TIMEOUT') -- Not implemented
  25. },
  26. webhook = -- Not implemented
  27. {
  28. url = os.getenv('TG_WEBHOOK_URL'),
  29. certificate = read_secret('telegram/webhook/certificate') or os.getenv('TG_WEBHOOK_CERT'),
  30. max_connections = os.getenv('TG_WEBHOOK_MAX_CON')
  31. }
  32. },
  33.  
  34. -- Data
  35. postgres = -- Not implemented
  36. {
  37. host = os.getenv('POSTGRES_HOST') or 'localhost',
  38. port = os.getenv('POSTGRES_PORT') or 5432,
  39. user = os.getenv('POSTGRES_USER') or 'postgres',
  40. password = read_secret('postgres/password') or os.getenv('POSTGRES_PASSWORD') or 'postgres',
  41. database = os.getenv('POSTGRES_DB') or 'groupbutler',
  42. },
  43. redis =
  44. {
  45. host = os.getenv('REDIS_HOST') or 'localhost',
  46. port = os.getenv('REDIS_PORT') or 6379,
  47. db = os.getenv('REDIS_DB') or 0
  48. },
  49.  
  50. -- Aesthetic
  51. lang = os.getenv('DEFAULT_LANG') or 'en',
  52. human_readable_version = os.getenv('VERSION') or 'unknown',
  53. channel = os.getenv('CHANNEL') or '@groupbutler_beta',
  54. source_code = os.getenv('SOURCE') or 'https://github.com/RememberTheAir/GroupButler/tree/beta',
  55. help_group = os.getenv('HELP_GROUP') or 'telegram.me/GBgroups',
  56.  
  57. -- Core
  58. log =
  59. {
  60. chat = assert(os.getenv('LOG_CHAT'), 'You must export $LOG_CHAT with the numerical ID of the log chat'),
  61. admin = assert(os.getenv('LOG_ADMIN'), 'You must export $LOG_ADMIN with your Telegram ID'),
  62. stats = os.getenv('LOG_STATS')
  63. },
  64. superadmins = assert(json.decode(os.getenv('SUPERADMINS')),
  65. 'You must export $SUPERADMINS with a JSON array containing at least your Telegram ID'),
  66. cmd = '^[/!#]',
  67. bot_settings = {
  68. cache_time = {
  69. adminlist = 18000, --5 hours (18000s) Admin Cache time, in seconds.
  70. alert_help = 72, -- amount of hours for cache help alerts
  71. chat_titles = 18000
  72. },
  73. report = {
  74. duration = 1200,
  75. times_allowed = 2
  76. },
  77. notify_bug = false, -- notify if a bug occurs!
  78. log_api_errors = true, -- log errors, which happening whilst interacting with the bot api.
  79. stream_commands = true,
  80. admin_mode = os.getenv('GB_ADMIN_MODE') == 'true' or false
  81. },
  82. plugins = {
  83. 'onmessage', --THIS MUST BE THE FIRST: IF AN USER IS FLOODING/IS BLOCKED, THE BOT WON'T GO THROUGH PLUGINS
  84. 'antispam', --SAME OF onmessage.lua
  85. 'backup',
  86. 'banhammer',
  87. 'block',
  88. 'configure',
  89. 'defaultpermissions',
  90. 'dashboard',
  91. 'floodmanager',
  92. 'help',
  93. 'links',
  94. 'logchannel',
  95. 'mediasettings',
  96. 'menu',
  97. 'moderators',
  98. 'pin',
  99. 'private',
  100. 'private_settings',
  101. 'report',
  102. 'rules',
  103. 'service',
  104. 'setlang',
  105. 'users',
  106. 'warn',
  107. 'welcome',
  108. 'admin',
  109. 'extra', --must be the last plugin in the list.
  110. },
  111. available_languages = {
  112. ['en'] = 'English 🇬🇧',
  113. ['it'] = 'Italiano 🇮🇹',
  114. ['es'] = 'Español 🇪🇸',
  115. ['pt_BR'] = 'Português 🇧🇷',
  116. ['ru'] = 'Русский 🇷🇺',
  117. ['de'] = 'Deutsch 🇩🇪',
  118. --['sv'] = 'Svensk 🇸🇪',
  119. ['ar'] = 'العربية 🇸🇩',
  120. --['fr'] = 'Français 🇫🇷',
  121. ['zh'] = '中文 🇨🇳',
  122. ['fa'] = 'فارسی 🇮🇷',
  123. ['id'] = 'Bahasa Indonesia 🇮🇩',
  124. ['nl'] = 'Nederlands 🇱🇺',
  125. ['tr'] = 'Turkish 🇹🇷'
  126. -- more languages will come
  127. },
  128. allow_fuzzy_translations = false,
  129. chat_settings = {
  130. ['settings'] = {
  131. ['Welcome'] = 'off',
  132. ['Extra'] = 'on',
  133. --['Flood'] = 'off',
  134. ['Silent'] = 'off',
  135. ['Rules'] = 'off',
  136. ['Reports'] = 'off',
  137. ['Welbut'] = 'off', -- "read the rules" button under the welcome message
  138. ['Weldelchain'] = 'off', -- delete the previously sent welcome message when a new welcome message is sent
  139. ['Antibot'] = 'off'
  140. },
  141. ['antispam'] = {
  142. ['links'] = 'alwd',
  143. ['forwards'] = 'alwd',
  144. ['warns'] = 2,
  145. ['action'] = 'mute'
  146. },
  147. ['flood'] = {
  148. ['MaxFlood'] = 5,
  149. ['ActionFlood'] = 'mute'
  150. },
  151. ['char'] = {
  152. ['Arab'] = 'allowed', --'kick'/'ban'
  153. ['Rtl'] = 'allowed'
  154. },
  155. ['floodexceptions'] = {
  156. ['text'] = 'no',
  157. ['photo'] = 'no', -- image
  158. ['forward'] = 'no',
  159. ['video'] = 'no',
  160. ['sticker'] = 'no',
  161. ['gif'] = 'no',
  162. },
  163. ['warnsettings'] = {
  164. ['type'] = 'mute',
  165. ['mediatype'] = 'mute',
  166. ['max'] = 3,
  167. ['mediamax'] = 2
  168. },
  169. ['welcome'] = {
  170. ['type'] = 'no',
  171. ['content'] = 'no'
  172. },
  173. ['goodbye'] = {
  174. ['type'] = 'custom',
  175. },
  176. ['media'] = {
  177. ['photo'] = 'ok', --'notok' | image
  178. ['audio'] = 'ok',
  179. ['video'] = 'ok',
  180. ['video_note'] = 'ok',
  181. ['sticker'] = 'ok',
  182. ['gif'] = 'ok',
  183. ['voice'] = 'ok',
  184. ['contact'] = 'ok',
  185. ['document'] = 'ok', -- file
  186. ['link'] = 'ok',
  187. ['game'] = 'ok',
  188. ['location'] = 'ok'
  189. },
  190. ['tolog'] = {
  191. ['ban'] = 'no',
  192. ['kick'] = 'no',
  193. ['unban'] = 'no',
  194. ['tempban'] = 'no',
  195. ['report'] = 'no',
  196. ['warn'] = 'no',
  197. ['nowarn'] = 'no',
  198. ['mediawarn'] = 'no',
  199. ['spamwarn'] = 'no',
  200. ['flood'] = 'no',
  201. ['new_chat_member'] = 'no',
  202. ['new_chat_photo'] = 'no',
  203. ['delete_chat_photo'] = 'no',
  204. ['new_chat_title'] = 'no',
  205. ['pinned_message'] = 'no'
  206. },
  207. ['defpermissions'] = {
  208. ['can_send_messages'] = 'true',
  209. ['can_send_media_messages'] = 'true',
  210. ['can_send_other_messages'] = 'true',
  211. ['can_add_web_page_previews'] = 'true'
  212. },
  213. ['defpermduration'] = {
  214. ['timeframe'] = 'd',
  215. ['duration'] = 1
  216. },
  217. },
  218. private_settings = {
  219. rules_on_join = 'off',
  220. reports = 'off'
  221. },
  222. chat_hashes = {'extra', 'info', 'links', 'warns', 'mediawarn', 'spamwarns', 'blocked', 'report', 'defpermissions',
  223. 'defpermduration'},
  224. chat_sets = {'whitelist'},--, 'mods'},
  225. bot_keys = {
  226. d3 = {'bot:general', 'bot:usernames', 'bot:chat:latsmsg'},
  227. d2 = {'bot:groupsid', 'bot:groupsid:removed', 'tempbanned', 'bot:blocked', 'remolden_chats'} --remolden_chats: chat removed with $remold command
  228. }
  229. }
  230.  
  231. local multipurpose_plugins = os.getenv('MULTIPURPOSE_PLUGINS')
  232. if multipurpose_plugins then
  233. _M.multipurpose_plugins = assert(json.decode(multipurpose_plugins),
  234. '$MULTIPURPOSE_PLUGINS must be a JSON array or empty')
  235. end
  236.  
  237. return _M
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement