-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7be15d7
commit 3e6b9be
Showing
6 changed files
with
79 additions
and
20 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
package com.my.discordbot; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class DiscordBotApplication { | ||
public class DiscordBotApplication implements CommandLineRunner { | ||
|
||
@Autowired | ||
private BotInitializer botInitializer; | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(DiscordBotApplication.class, args); | ||
} | ||
|
||
@Override | ||
public void run(String... args) throws Exception { | ||
botInitializer.initializeBot(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.my.discordbot; | ||
|
||
import net.dv8tion.jda.api.entities.Message; | ||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; | ||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; | ||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; | ||
import net.dv8tion.jda.api.hooks.ListenerAdapter; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class EventListener extends ListenerAdapter { | ||
|
||
@Autowired | ||
private ProcessConversionToJpg processConversion; | ||
|
||
@Override | ||
public void onMessageReceived(MessageReceivedEvent event) { | ||
Message message = event.getMessage(); | ||
MessageChannel channel = event.getChannel(); | ||
|
||
if (channel instanceof TextChannel) { | ||
if (!message.getAuthor().isBot() && message.getAttachments().size() > 0) { | ||
message.getAttachments().forEach(attachment -> { | ||
if (attachment.getFileName().endsWith(".heic")) { | ||
processConversion.process(attachment, channel); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
|
22 changes: 22 additions & 0 deletions
22
src/main/java/com/my/discordbot/ProcessConversionToJpg.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.my.discordbot; | ||
|
||
import net.dv8tion.jda.api.entities.Message; | ||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ProcessConversionToJpg { | ||
|
||
@Value("") | ||
private String cloudFunctionUrl; | ||
|
||
@Value("") | ||
private String secretToken; | ||
|
||
@Value("") | ||
private String ownerId; | ||
|
||
public void process(Message.Attachment attachment, MessageChannel channel) {} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters