Skip to content

Commit 0f749a4

Browse files
authored
Add files via upload
1 parent 36e0716 commit 0f749a4

6 files changed

Lines changed: 230 additions & 0 deletions

File tree

pom.xml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>id.frostfire</groupId>
8+
<artifactId>BotIoT</artifactId>
9+
<packaging>jar</packaging>
10+
<version>1.0-SNAPSHOT</version>
11+
12+
<properties>
13+
<maven.compiler.source>17</maven.compiler.source>
14+
<maven.compiler.target>17</maven.compiler.target>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
</properties>
17+
18+
<repositories>
19+
<repository>
20+
<id>jitpack.io</id>
21+
<url>https://jitpack.io</url>
22+
</repository>
23+
<repository>
24+
<id>Central</id>
25+
<url>https://repo1.maven.org/maven2/</url>
26+
</repository>
27+
</repositories>
28+
<dependencies>
29+
<dependency>
30+
<groupId>junit</groupId>
31+
<artifactId>junit</artifactId>
32+
<version>3.8.1</version>
33+
<scope>test</scope>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.javacord</groupId>
37+
<artifactId>javacord</artifactId>
38+
<version>3.8.0</version>
39+
<type>pom</type>
40+
</dependency>
41+
42+
<dependency>
43+
<groupId>com.github.auties00</groupId>
44+
<artifactId>whatsappweb4j</artifactId>
45+
<version>3.4.8</version>
46+
</dependency>
47+
48+
<dependency>
49+
<groupId>com.github.pengrad</groupId>
50+
<artifactId>java-telegram-bot-api</artifactId>
51+
<version>6.7.0</version>
52+
</dependency>
53+
<dependency>
54+
<groupId>com.sparkjava</groupId>
55+
<artifactId>spark-core</artifactId>
56+
<version>2.9.4</version>
57+
</dependency>
58+
</dependencies>
59+
<build>
60+
<plugins>
61+
<plugin>
62+
<artifactId>maven-assembly-plugin</artifactId>
63+
<configuration>
64+
<archive>
65+
<manifest>
66+
<mainClass>id.frostfire.BotIoT.Main</mainClass>
67+
</manifest>
68+
</archive>
69+
<descriptorRefs>
70+
<descriptorRef>jar-with-dependencies</descriptorRef>
71+
</descriptorRefs>
72+
</configuration>
73+
<executions>
74+
<execution>
75+
<id>make-assembly</id>
76+
<phase>package</phase>
77+
<goals>
78+
<goal>single</goal>
79+
</goals>
80+
</execution>
81+
</executions>
82+
</plugin>
83+
</plugins>
84+
</build>
85+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package id.frostfire.BotIoT.Discord;
2+
3+
import org.javacord.api.DiscordApi;
4+
import org.javacord.api.DiscordApiBuilder;
5+
import org.javacord.api.entity.channel.TextChannel;
6+
import org.javacord.api.entity.message.MessageBuilder;
7+
8+
public class Discord {
9+
public static DiscordApi api;
10+
public static void Inisialize(String token){
11+
api = new DiscordApiBuilder().setToken(token).login().join();
12+
System.out.println("invite Link Discord Bot : " + api.createBotInvite());
13+
}
14+
public static String pesandc(String pesan, String id){
15+
new MessageBuilder().setContent(pesan).send((TextChannel) api.getChannelById(id).get());
16+
return "Mengirim Pesan Discord dengan pesan " + pesan;
17+
}
18+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package id.frostfire.BotIoT.EndpointAPI;
2+
3+
4+
import id.frostfire.BotIoT.Discord.Discord;
5+
import id.frostfire.BotIoT.Main;
6+
import id.frostfire.BotIoT.Telegram.Telegram;
7+
import id.frostfire.BotIoT.WhatsApp.WhatsApp;
8+
import it.auties.whatsapp.api.Whatsapp;
9+
10+
import static spark.Spark.*;
11+
public class Publish {
12+
public static void event() {
13+
get("/", (req, res) -> "Hello World");
14+
post("/sendwa", (req, res) -> {
15+
16+
return WhatsApp.pesan(Whatsapp.webBuilder().lastConnection().build().connect().join(),
17+
req.params("pesan");
18+
req.params("nomer");
19+
});
20+
post("senddc", (request, response) -> {
21+
response.status(201);
22+
return Discord.pesandc(request.queryParams("pesan"), Main.DcChnId);
23+
});
24+
post("sendtele", (request, response) -> {
25+
response.status(201);
26+
return Telegram.pesan(request.queryParams("pesan"));
27+
});
28+
}
29+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package id.frostfire.BotIoT;
2+
3+
import id.frostfire.BotIoT.Discord.Discord;
4+
import id.frostfire.BotIoT.EndpointAPI.Publish;
5+
import id.frostfire.BotIoT.Telegram.Telegram;
6+
import id.frostfire.BotIoT.WhatsApp.WhatsApp;
7+
import it.auties.whatsapp.api.Whatsapp;
8+
9+
import java.util.Scanner;
10+
11+
import static spark.Spark.port;
12+
13+
public class Main {
14+
public static String DcChnId;
15+
public static long TeleId;
16+
public static Boolean usewhatsapp = false;
17+
public static Boolean usediscord = false;
18+
public static boolean usetelegram = false;
19+
20+
public static String Teletoken;
21+
22+
public static void main(String[] args){
23+
port(80);
24+
Scanner scn = new Scanner(System.in);
25+
System.out.println("Are You using WhatsApp?");
26+
String wa = scn.nextLine();
27+
if(wa.equals("y") || wa.equals("yes") || wa.equals("true")){ WhatsApp.client(); usewhatsapp = true;}
28+
System.out.println("Are You using Discord?");
29+
String dc = scn.nextLine();
30+
if(dc.equals("yes") || dc.equals("y") || dc.equals("true")){
31+
usediscord = true;
32+
System.out.println("Please Insert your Discord Bot Token :");
33+
String token = scn.nextLine();
34+
Discord.Inisialize(token);
35+
System.out.println("Please Insert your ChannelID :");
36+
DcChnId = scn.nextLine();
37+
}
38+
System.out.println("Are you using Telegram?");
39+
String tele = scn.nextLine();
40+
if(tele.equals("y") || tele.equals("yes") || tele.equals("true")){
41+
System.out.println("Please Insert your Telegram Bot Token :");
42+
Teletoken = scn.nextLine();
43+
Telegram.inisialize();
44+
System.out.println("Please Insert your IDcontact :");
45+
TeleId = scn.nextLong();
46+
usetelegram = true;
47+
}
48+
Publish.event();
49+
if(usewhatsapp) System.out.println(WhatsApp.pesan(Whatsapp.webBuilder().lastConnection().build().connect().join(),
50+
"+6285236486026",
51+
"Server Menyala"));
52+
System.out.println("Server Menyala");
53+
}
54+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package id.frostfire.BotIoT.Telegram;
2+
3+
import com.pengrad.telegrambot.TelegramBot;
4+
import com.pengrad.telegrambot.UpdatesListener;
5+
import com.pengrad.telegrambot.request.SendMessage;
6+
import com.pengrad.telegrambot.response.SendResponse;
7+
import id.frostfire.BotIoT.Main;
8+
9+
public class Telegram {
10+
public static TelegramBot bot;
11+
public static void inisialize(){
12+
bot = new TelegramBot(Main.Teletoken);
13+
bot.setUpdatesListener(updates -> {
14+
return UpdatesListener.CONFIRMED_UPDATES_ALL;
15+
}, e -> {
16+
if (e.response() != null) {
17+
e.response().errorCode();
18+
e.response().description();
19+
} else {
20+
e.printStackTrace();
21+
}
22+
});
23+
}
24+
public static String pesan(String Pesan){
25+
SendResponse response = bot.execute(new SendMessage(Main.TeleId, Pesan));
26+
return "Mengirim Pesan Telegram dengan pesan " + Pesan;
27+
}
28+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package id.frostfire.BotIoT.WhatsApp;
2+
3+
import it.auties.whatsapp.api.QrHandler;
4+
import it.auties.whatsapp.api.Whatsapp;
5+
import it.auties.whatsapp.model.contact.ContactJid;
6+
7+
8+
public class WhatsApp {
9+
public static void client(){
10+
Whatsapp.webBuilder().newConnection().qrHandler(QrHandler.toTerminal()).name("FrostFireIoT Bot").build().connect().join();
11+
}
12+
public static String pesan(Whatsapp api, String nomer, String pesan){
13+
api.sendMessage(ContactJid.of(nomer),pesan);
14+
return "Mengirim pesan ke " + nomer + " Dengan pesan " + pesan;
15+
}
16+
}

0 commit comments

Comments
 (0)