44local ExpUtil = require (" modules/exp_util" )
55local Async = require (" modules/exp_util/async" )
66
7+ local floor = math.floor
8+ local random = math.random
9+ local format_string = string.format
10+ local locale_reply = " exp_chat-auto-reply.chat-reply"
11+
712local send_message_async =
813 Async .register (function (player , message )
9- if player == true then
14+ if player == nil then
1015 game .print (message )
1116 else
1217 player .print (message )
@@ -18,9 +23,7 @@ local afk_time_units = {
1823 seconds = true ,
1924}
2025
21- -- luacheck:ignore 212/player 212/is_command
2226return {
23- allow_command_prefix_for_messages = true , --- @setting allow_command_prefix_for_messages when true any message trigger will print to all player when prefixed
2427 messages = { --- @setting messages will trigger when ever the word is said
2528 [" discord" ] = { " info.discord" },
2629 [" expgaming" ] = { " info.website" },
@@ -32,99 +35,100 @@ return {
3235 [" command" ] = { " info.custom-commands" },
3336 [" commands" ] = { " info.custom-commands" },
3437 [" softmod" ] = { " info.softmod" },
38+ [" plugin" ] = { " info.softmod" },
3539 [" script" ] = { " info.softmod" },
36- [" loop" ] = { " chat-bot.loops" },
40+ [" redmew" ] = { " info.redmew" },
41+ [" comfy" ] = { " info.redmew" },
3742 [" rhd" ] = { " info.lhd" },
3843 [" lhd" ] = { " info.lhd" },
39- [" roundabout" ] = { " chat-bot.loops" },
40- [" roundabouts" ] = { " chat-bot.loops" },
41- [" redmew" ] = { " info.redmew" },
42- [" afk" ] = function (player , _is_command )
44+ [" loop" ] = { " exp_chat-auto-reply.reply-loops" },
45+ [" roundabout" ] = { " exp_chat-auto-reply.reply-loops" },
46+ [" roundabouts" ] = { " exp_chat-auto-reply.reply-loops" },
47+ [" clusterio" ] = { " exp_chat-auto-reply.reply-clusterio" },
48+ [" players" ] = function ()
49+ return { " exp_chat-auto-reply.reply-players" , # game .players }
50+ end ,
51+ [" online" ] = function ()
52+ return { " exp_chat-auto-reply.reply-online" , # game .connected_players }
53+ end ,
54+ [" afk" ] = function (player )
4355 local max = player
4456 for _ , next_player in pairs (game .connected_players ) do
4557 if max .afk_time < next_player .afk_time then
4658 max = next_player
4759 end
4860 end
4961
50- return { " chat-bot.afk" , max .name , ExpUtil .format_time_locale (max .afk_time , " long" , afk_time_units ) }
51- end ,
52- [" players" ] = function (_player , _is_command )
53- return { " chat-bot.players" , # game .players }
54- end ,
55- [" online" ] = function (_player , _is_command )
56- return { " chat-bot.players-online" , # game .connected_players }
57- end ,
58- [" r!verify" ] = function (player , _is_command )
59- return { " chat-bot.verify" , player .name }
62+ return { " exp_chat-auto-reply.reply-afk" , max .name , ExpUtil .format_time_locale (max .afk_time , " long" , afk_time_units ) }
6063 end ,
6164 },
65+ allow_command_prefix_for_messages = true , --- @setting allow_command_prefix_for_messages when true any message trigger will print to all player when prefixed
6266 command_admin_only = false , --- @setting command_admin_only when true will only allow chat commands for admins
63- command_permission = " command/chat-bot " , --- @setting command_permission the permission used to allow command prefixes
67+ command_permission = " command/chat-commands " , --- @setting command_permission the permission used to allow command prefixes
6468 command_prefix = " !" , --- @setting command_prefix prefix used for commands below and to print to all players (if enabled above)
6569 commands = { --- @setting commands will trigger only when command prefix is given
66- [" dev" ] = { " chat-bot.not-real-dev" },
67- [" blame" ] = function (player , _is_command )
70+ [" dev" ] = { " exp_chat-auto-reply.reply-dev" },
71+ [" magic" ] = { " exp_chat-auto-reply.reply-magic" },
72+ [" aids" ] = { " exp_chat-auto-reply.reply-aids" },
73+ [" riot" ] = { " exp_chat-auto-reply.reply-riot" },
74+ [" lenny" ] = { " exp_chat-auto-reply.reply-lenny" },
75+ [" blame" ] = function (player )
6876 local names = { " Cooldude2606" , " arty714" , " badgamernl" , " mark9064" , " aldldl" , " Drahc_pro" , player .name }
6977 for _ , next_player in pairs (game .connected_players ) do
7078 names [# names + 1 ] = next_player .name
7179 end
7280
73- return { " chat-bot. blame" , table .get_random (names ) }
81+ return { " exp_chat-auto-reply.reply- blame" , table .get_random (names ) }
7482 end ,
75- [" magic" ] = { " chat-bot.magic" },
76- [" aids" ] = { " chat-bot.aids" },
77- [" riot" ] = { " chat-bot.riot" },
78- [" lenny" ] = { " chat-bot.lenny" },
79- [" hodor" ] = function (_player , _is_command )
83+ [" hodor" ] = function ()
8084 local options = { " ?" , " ." , " !" , " !!!" }
81- return { " chat-bot. hodor" , table .get_random (options ) }
85+ return { " exp_chat-auto-reply.reply- hodor" , table .get_random (options ) }
8286 end ,
83- [" evolution" ] = function (player , _is_command )
84- return { " chat-bot.current -evolution" , string.format (" %.2f" , game .forces [" enemy" ].get_evolution_factor (player .surface )) }
87+ [" evolution" ] = function (player )
88+ return { " exp_chat-auto-reply.reply -evolution" , format_string (" %.2f" , game .forces [" enemy" ].get_evolution_factor (player .surface )) }
8589 end ,
86- [" makepopcorn" ] = function (player , _is_command )
87- local timeout = math. floor (180 * (math. random () + 0.5 ))
88- send_message_async ( true , { " chat-bot.reply " , { " chat-bot.get -popcorn-1 " } })
89- send_message_async : start_after ( timeout , true , { " chat-bot.reply " , { " chat-bot.get -popcorn-2 " , player . name } })
90+ [" makepopcorn" ] = function (player )
91+ local timeout = floor (180 * (random () + 0.5 ))
92+ send_message_async : start_after ( timeout , nil , { locale_reply , { " exp_chat-auto-reply.reply -popcorn-2 " , player . name } })
93+ return { locale_reply , { " exp_chat-auto-reply.reply -popcorn-1 " } }
9094 end ,
91- [" passsomesnaps" ] = function (player , _is_command )
92- local timeout = math. floor (180 * (math. random () + 0.5 ))
93- send_message_async ( player , { " chat-bot.reply " , { " chat-bot.get -snaps-1 " } })
94- send_message_async :start_after (timeout , true , { " chat-bot.reply " , { " chat-bot.get -snaps-2 " , player .name } })
95- send_message_async : start_after ( timeout * ( math.random () + 0.5 ), true , { " chat-bot .reply" , { " chat-bot.get- snaps-3 " , player . name } })
95+ [" passsomesnaps" ] = function (player )
96+ local timeout = floor (180 * (random () + 0.5 ))
97+ send_message_async : start_after ( timeout , nil , { locale_reply , { " exp_chat-auto-reply.reply -snaps-2 " , player . name } })
98+ send_message_async :start_after (timeout * ( random () + 0.5 ), nil , { locale_reply , { " exp_chat-auto-reply.reply -snaps-3 " , player .name } })
99+ return { locale_reply , { " exp_chat-auto-reply .reply- snaps-1 " } }
96100 end ,
97- [" makecocktail" ] = function (player , _is_command )
98- local timeout = math. floor (180 * (math. random () + 0.5 ))
99- send_message_async ( true , { " chat-bot.reply " , { " chat-bot.get -cocktail-1 " } })
100- send_message_async :start_after (timeout , true , { " chat-bot.reply " , { " chat-bot.get -cocktail-2 " , player .name } })
101- send_message_async : start_after ( timeout * ( math.random () + 0.5 ), true , { " chat-bot .reply" , { " chat-bot.get- cocktail-3 " , player . name } })
101+ [" makecocktail" ] = function (player )
102+ local timeout = floor (180 * (random () + 0.5 ))
103+ send_message_async : start_after ( timeout , nil , { locale_reply , { " exp_chat-auto-reply.reply -cocktail-2 " , player . name } })
104+ send_message_async :start_after (timeout * ( random () + 0.5 ), nil , { locale_reply , { " exp_chat-auto-reply.reply -cocktail-3 " , player .name } })
105+ return { locale_reply , { " exp_chat-auto-reply .reply- cocktail-1 " } }
102106 end ,
103- [" makecoffee" ] = function (player , _is_command )
104- local timeout = math. floor (180 * (math. random () + 0.5 ))
105- send_message_async ( true , { " chat-bot.reply " , { " chat-bot.make -coffee-1 " } })
106- send_message_async : start_after ( timeout , true , { " chat-bot.reply " , { " chat-bot.make -coffee-2 " , player . name } })
107+ [" makecoffee" ] = function (player )
108+ local timeout = floor (180 * (random () + 0.5 ))
109+ send_message_async : start_after ( timeout , nil , { locale_reply , { " exp_chat-auto-reply.reply -coffee-2 " , player . name } })
110+ return { locale_reply , { " exp_chat-auto-reply.reply -coffee-1 " } }
107111 end ,
108- [" orderpizza" ] = function (player , _is_command )
109- local timeout = math. floor (180 * (math. random () + 0.5 ))
110- send_message_async ( true , { " chat-bot.reply " , { " chat-bot.order -pizza-1 " } })
111- send_message_async :start_after (timeout , true , { " chat-bot.reply " , { " chat-bot.order -pizza-2 " , player .name } })
112- send_message_async : start_after ( timeout * ( math.random () + 0.5 ), true , { " chat-bot .reply" , { " chat-bot.order- pizza-3 " , player . name } })
112+ [" orderpizza" ] = function (player )
113+ local timeout = floor (180 * (random () + 0.5 ))
114+ send_message_async : start_after ( timeout , nil , { locale_reply , { " exp_chat-auto-reply.reply -pizza-2 " , player . name } })
115+ send_message_async :start_after (timeout * ( random () + 0.5 ), nil , { locale_reply , { " exp_chat-auto-reply.reply -pizza-3 " , player .name } })
116+ return { locale_reply , { " exp_chat-auto-reply .reply- pizza-1 " } }
113117 end ,
114- [" maketea" ] = function (player , _is_command )
115- local timeout = math. floor (180 * (math. random () + 0.5 ))
116- send_message_async ( true , { " chat-bot.reply " , { " chat-bot.make -tea-1 " } })
117- send_message_async : start_after ( timeout , true , { " chat-bot.reply " , { " chat-bot.make -tea-2 " , player . name } })
118+ [" maketea" ] = function (player )
119+ local timeout = floor (180 * (random () + 0.5 ))
120+ send_message_async : start_after ( timeout , nil , { locale_reply , { " exp_chat-auto-reply.reply -tea-2 " , player . name } })
121+ return { locale_reply , { " exp_chat-auto-reply.reply -tea-1 " } }
118122 end ,
119- [" meadplease" ] = function (player , _is_command )
120- local timeout = math. floor (180 * (math. random () + 0.5 ))
121- send_message_async ( true , { " chat-bot.reply " , { " chat-bot.get -mead-1 " } })
122- send_message_async : start_after ( timeout , true , { " chat-bot.reply " , { " chat-bot.get -mead-2 " , player . name } })
123+ [" meadplease" ] = function (player )
124+ local timeout = floor (180 * (random () + 0.5 ))
125+ send_message_async : start_after ( timeout , nil , { locale_reply , { " exp_chat-auto-reply.reply -mead-2 " , player . name } })
126+ return { locale_reply , { " exp_chat-auto-reply.reply -mead-1 " } }
123127 end ,
124- [" passabeer" ] = function (player , _is_command )
125- local timeout = math. floor (180 * (math. random () + 0.5 ))
126- send_message_async ( true , { " chat-bot.reply " , { " chat-bot.get -beer-1 " } })
127- send_message_async : start_after ( timeout , true , { " chat-bot.reply " , { " chat-bot.get -beer-2 " , player . name } })
128+ [" passabeer" ] = function (player )
129+ local timeout = floor (180 * (random () + 0.5 ))
130+ send_message_async : start_after ( timeout , nil , { locale_reply , { " exp_chat-auto-reply.reply -beer-2 " , player . name } })
131+ return { locale_reply , { " exp_chat-auto-reply.reply -beer-1 " } }
128132 end ,
129133 },
130134}
0 commit comments