Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gems
73 changes: 40 additions & 33 deletions config/locales/server.en.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
en:
site_settings:
discord_bot_enabled: "Enable the Discourse Discord bot plugin"
discord_bot_token: "Enter your bot TOKEN from Discord here"
discord_bot_admin_channel_id: "The id of your admin text channel on Discord"
discord_bot_admin_role_id: "The id of your admin role on Discord for which commands are permitted"
discord_bot_announcement_channel_id: "The id of your Discord announcement channel"
discord_bot_discourse_announcement_topic_id: "The id of your Discourse Announcement Topic (if discord auto channel sync is enabled and matching Category found this is suppressed)"
discord_bot_auto_channel_sync: "Enable chat sync on identically named channels/Categories (takes precedence over Discourse Announcement Topic)"
discord_bot_message_copy_topic_size_limit: "Message history copy: number of Discord messages per Discourse Topic"
discord_bot_post_announcement_categories: "Announce new Posts in here within the announcements channel"
discord_bot_topic_announcement_categories: "Announce new Topics in here within the announcements channel"
discord_bot_rate_limit_delay: "The delay in seconds between sending commands to Discord so we don't annihilate rate limits"
discord_bot:
discord_events:
auto_message_copy:
default_topic_title: "Discord #%{channel_name} messages"
commands:
rate_limit_breached: "Hold on cow(girl/boy/person), rate limit hit!"
no_matching_category: "No matching Category in Discourse!"
disccopy:
description: "Copy across message history to Category of same name"
discourse_topic_title: "#%{channel} messages from Discord"
no_category_specified: "No target Category specified, so attempting to use current channel name to match a Discourse Category."
success:
found_matching_discourse_category: "SUCCESS: Found matching Discourse Category"
found_matching_discourse_topic: "SUCCESS: Found matching Discourse Topic"
final_outcome: "SUCCESS: Copied over %{count} past messages to Discourse!"
error:
unable_to_find_discourse_category: "ERROR: Unable to find matching Discourse Category, aborting command!"
unable_to_find_discourse_topic: "ERROR: Unable to find matching Discourse Topic in target Category, will create new!"
unable_to_determine_topic_id: "ERROR: Unable to determine a suitable Topic Id for Discourse!"
disckick:
en:
site_settings:
discord_bot_enabled: "Enable the Discourse Discord bot plugin"
discord_bot_token: "Enter your bot TOKEN from Discord here"
discord_bot_admin_channel_id: "The id of your admin text channel on Discord"
discord_bot_admin_role_id: "The id of your admin role on Discord for which commands are permitted"
discord_bot_announcement_channel_id: "The id of your Discord announcement channel"
discord_bot_discourse_announcement_topic_id: "The id of your Discourse Announcement Topic (if discord auto channel sync is enabled and matching Category found this is suppressed)"
discord_bot_auto_channel_sync: "Enable chat sync on identically named channels/Categories (takes precedence over Discourse Announcement Topic)"
discord_bot_message_copy_topic_size_limit: "Message history copy: number of Discord messages per Discourse Topic"
discord_bot_message_copy_default_category: "If no Category specified and Channel name doesn't match a Discourse Category use this Category to paste Topics"
discord_bot_post_announcement_categories: "Announce new Posts in here within the announcements channel"
discord_bot_topic_announcement_categories: "Announce new Topics in here within the announcements channel"
discord_bot_rate_limit_delay: "The delay in seconds between sending commands to Discord so we don't annihilate rate limits"
discord_bot_unknown_user_proxy_account: "Username of account to be used for posting if Discord User is unknown to Discourse instance"
discord_bot:
discord_events:
auto_message_copy:
default_topic_title: "Discord #%{channel_name} messages"
commands:
rate_limit_breached: "Hold on cow(girl/boy/person), rate limit hit!"
no_matching_category: "No matching Category in Discourse!"
disccopy:
description: "Copy across message history to Category of same name"
discourse_topic_title: "#%{channel} messages from Discord"
discourse_topic_contents: "%{channel}"
no_category_specified: "No target Category specified, so attempting to use current channel name to match a Discourse Category or will use Default Category."
success:
found_matching_discourse_category: "SUCCESS: Found matching Discourse Category: \"%{name}\""
found_matching_discourse_topic: "SUCCESS: Found matching Discourse Topic"
final_outcome: "SUCCESS: Copied over %{count} past messages to Discourse!"
error:
must_specify_message_number: "ERROR: Outside of a Thread you must specify number of messages to be copied!"
must_specify_message_number_as_integer: "ERROR: Number of messages must be an integer!"
unable_to_find_discourse_category: "ERROR: Unable to find matching Discourse Category, aborting command! Be sure to substitute _ for spaces in name and match case."
unable_to_find_discourse_topic: "ERROR: Unable to find matching Discourse Topic in target Category, will create new!"
unable_to_determine_topic_id: "ERROR: Unable to determine a suitable Topic Id for Discourse!"
disccopythread:
description: "Copy this thread to a new Topic on Discourse"
disckick:
description: "Block users whose trust level is below a certain integer on discourse"
8 changes: 8 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ plugins:
discord_bot_message_copy_topic_size_limit:
default: 100
client: false
discord_bot_message_copy_default_category:
client: false
default: ''
type: category_list
discord_bot_unknown_user_proxy_account:
client: false
type: username
default: system
discord_bot_rate_limit_delay:
default: 2
client: false
3 changes: 2 additions & 1 deletion lib/bot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ class ::DiscordBot::Bot
def self.init
@@DiscordBot = Discordrb::Commands::CommandBot.new token: SiteSetting.discord_bot_token, prefix: '!'

admin_channel_id = SiteSetting.discord_bot_admin_channel_id
@@DiscordBot.ready do |event|
puts "Logged in as #{@@DiscordBot.profile.username} (ID:#{@@DiscordBot.profile.id}) | #{@@DiscordBot.servers.size} servers"
@@DiscordBot.send_message(SiteSetting.discord_bot_admin_channel_id, "The Discourse admin bot has started his shift!")
@@DiscordBot.send_message(admin_channel_id, "The Discourse admin bot has started his shift!")
end

@@DiscordBot
Expand Down
Loading