Compare commits
12 Commits
5dee2150a8
...
178399bf94
Author | SHA1 | Date | |
---|---|---|---|
|
178399bf94 | ||
|
72b48d2666 | ||
|
fda86cc69e | ||
|
62fc23beed | ||
|
d6232f4846 | ||
|
8f24cd35ac | ||
e13185fa29 | |||
18091cd7f8 | |||
de0002fcca | |||
2b6262df9a | |||
f3336c9722 | |||
84a25484c4 |
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/.idea
|
||||
*.class
|
||||
/target
|
||||
*.iml
|
30
README.md
30
README.md
@ -1,21 +1,43 @@
|
||||
[![GitHub last commit](https://img.shields.io/github/last-commit/mastercake10/TelegramChat.svg)](https://github.com/mastercake10/TelegramChat/commits/master)
|
||||
[![build status](https://ci.spaceio.xyz/buildStatus/icon?job=TelegramChat)](https://ci.spaceio.xyz/job/TelegramChat/lastBuild/xyz.spaceio$telegramchat/)
|
||||
[![discord](https://discordapp.com/api/guilds/330725294749122561/widget.png)](https://discord.gg/3xgsPh8)
|
||||
[![view on SpigotMC](https://img.shields.io/badge/view%20on-spigotmc-orange.svg)](https://www.spigotmc.org/resources/telegramchat.16576/)
|
||||
|
||||
![resource icon](https://www.spigotmc.org/data/resource_icons/16/16576.jpg?1476392100)
|
||||
|
||||
## Welcome to the TelegramChat GitHub repository!
|
||||
TelegramChat is a Spigot plugin compatible with Spigot versions 1.7 through 1.16.*, that connects Telegram with Minecraft.
|
||||
TelegramChat is a Bukkit plugin compatible with Paper/Spigot versions 1.7 through 1.18.*, that connects Telegram with Minecraft.
|
||||
|
||||
### Usage
|
||||
## Usage
|
||||
1. Create a new bot by messaging the @BotFather and following the instructions.
|
||||
2. Obtain the token (`/tokentype` in Telegram) and type `/linktelegram <token>` to link the newly created Bot to your Server. This needs to be done once.
|
||||
3. Each user needs to be linked to their Telegram account in order to chat mc <-> telegram.
|
||||
|
||||
## Private chats
|
||||
### Private chats
|
||||
1. Your users need to type `/telegram` in-game to get a temporary code for linking
|
||||
2. The code is then sent to the Telegram bot.
|
||||
|
||||
## Group chats
|
||||
### Group chats
|
||||
1. As an admin, you need to set the privacy setting to disabled using the BotFather. This is done by typing `/setprivacy` and then disabled.
|
||||
2. Users just need to join the group to see the MC chat. They might want to link their account by posting their /linktelegram code in the group chat.
|
||||
|
||||
## Developers
|
||||
* [Jenkins](https://ci.spaceio.xyz/job/TelegramChat/lastBuild/xyz.spaceio$telegramchat/) latest builds, including unstable ones
|
||||
* [Repository](https://repo.spaceio.xyz/#browse/browse:maven-snapshots:xyz%2Fspaceio%2Ftelegramchat)
|
||||
|
||||
### API
|
||||
```xml
|
||||
<repository>
|
||||
<id>spaceio-repo</id>
|
||||
<url>https://repo.spaceio.xyz/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>xyz.spaceio</groupId>
|
||||
<artifactId>telegramchat</artifactId>
|
||||
<version>VERSION_HERE-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
29
pom.xml
29
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>xyz.spaceio</groupId>
|
||||
<artifactId>telegramchat</artifactId>
|
||||
<version>1.0.17-SNAPSHOT</version>
|
||||
<version>1.0.18-SNAPSHOT</version>
|
||||
<name>TelegramChat</name>
|
||||
<url>https://www.spigotmc.org/resources/telegramchat.16576/</url>
|
||||
|
||||
@ -25,15 +25,24 @@
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>nexus-snapshots</id>
|
||||
<url>https://services.mind-overflow.net/nexus/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.LeonMangler</groupId>
|
||||
<artifactId>PremiumVanishAPI</artifactId>
|
||||
<version>2.7.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
@ -42,16 +51,16 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>spaceio-snapshots</id>
|
||||
<name>snapshots</name>
|
||||
<url>https://repo.spaceio.xyz/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>spaceio-releases</id>
|
||||
<name>releases</name>
|
||||
<url>https://repo.spaceio.xyz/repository/maven-releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>spaceio-snapshots</id>
|
||||
<name>snapshots</name>
|
||||
<url>https://repo.spaceio.xyz/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<!-- Uses the properties in this file for plugin.yml and config.yml -->
|
||||
@ -72,8 +81,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<source>9</source>
|
||||
<target>9</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Sets the custom JARfile name (Project name without spaces is good) -->
|
||||
|
@ -27,7 +27,7 @@ import net.milkbowl.vault.permission.Permission;
|
||||
public class CommandHandler extends ConsoleHandler implements TelegramActionListener {
|
||||
|
||||
private Permission permissionsAdapter;
|
||||
private int lastChatId = -1;
|
||||
private long lastChatId = -1;
|
||||
private long lastCommandTyped;
|
||||
|
||||
private Telegram telegram;
|
||||
|
44
src/main/java/de/Linus122/Handlers/VanishHandler.java
Normal file
44
src/main/java/de/Linus122/Handlers/VanishHandler.java
Normal file
@ -0,0 +1,44 @@
|
||||
package de.Linus122.Handlers;
|
||||
|
||||
import de.Linus122.Telegram.Utils;
|
||||
import de.Linus122.TelegramChat.TelegramChat;
|
||||
import de.Linus122.TelegramComponents.ChatMessageToTelegram;
|
||||
import de.myzelyam.api.vanish.PlayerHideEvent;
|
||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class VanishHandler implements Listener
|
||||
{
|
||||
|
||||
@EventHandler
|
||||
public void onVanish(PlayerHideEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if(e.isCancelled()) return;
|
||||
|
||||
if (!TelegramChat.getInstance().getConfig().getBoolean("enable-joinquitmessages"))
|
||||
return;
|
||||
if (TelegramChat.telegramHook.connected) {
|
||||
ChatMessageToTelegram chat = new ChatMessageToTelegram();
|
||||
chat.parse_mode = "Markdown";
|
||||
chat.text = Utils.formatMSG("quit-message", e.getPlayer().getName())[0];
|
||||
TelegramChat.telegramHook.sendAll(chat);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onShow(PlayerShowEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if(e.isCancelled()) return;
|
||||
|
||||
if (!TelegramChat.getInstance().getConfig().getBoolean("enable-joinquitmessages"))
|
||||
return;
|
||||
if (TelegramChat.telegramHook.connected) {
|
||||
ChatMessageToTelegram chat = new ChatMessageToTelegram();
|
||||
chat.parse_mode = "Markdown";
|
||||
chat.text = Utils.formatMSG("join-message", e.getPlayer().getName())[0];
|
||||
TelegramChat.telegramHook.sendAll(chat);
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,8 @@ import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import de.Linus122.Handlers.VanishHandler;
|
||||
import de.myzelyam.api.vanish.VanishAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -40,17 +42,25 @@ public class TelegramChat extends JavaPlugin implements Listener {
|
||||
|
||||
private static Data data = new Data();
|
||||
public static Telegram telegramHook;
|
||||
private static TelegramChat instance;
|
||||
private static boolean isSuperVanish;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.saveDefaultConfig();
|
||||
cfg = this.getConfig();
|
||||
instance = this;
|
||||
Utils.cfg = cfg;
|
||||
|
||||
Bukkit.getPluginCommand("telegram").setExecutor(new TelegramCmd());
|
||||
Bukkit.getPluginCommand("linktelegram").setExecutor(new LinkTelegramCmd());
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("SuperVanish") || Bukkit.getPluginManager().isPluginEnabled("PremiumVanish")) {
|
||||
isSuperVanish = true;
|
||||
Bukkit.getPluginManager().registerEvents(new VanishHandler(), this);
|
||||
}
|
||||
|
||||
File dir = new File("plugins/TelegramChat/");
|
||||
dir.mkdir();
|
||||
data = new Data();
|
||||
@ -190,6 +200,10 @@ public class TelegramChat extends JavaPlugin implements Listener {
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
if (!this.getConfig().getBoolean("enable-joinquitmessages"))
|
||||
return;
|
||||
|
||||
if(isSuperVanish && VanishAPI.isInvisible(e.getPlayer()))
|
||||
return;
|
||||
|
||||
if (telegramHook.connected) {
|
||||
ChatMessageToTelegram chat = new ChatMessageToTelegram();
|
||||
chat.parse_mode = "Markdown";
|
||||
@ -214,6 +228,10 @@ public class TelegramChat extends JavaPlugin implements Listener {
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
if (!this.getConfig().getBoolean("enable-joinquitmessages"))
|
||||
return;
|
||||
|
||||
if(isSuperVanish && VanishAPI.isInvisible(e.getPlayer()))
|
||||
return;
|
||||
|
||||
if (telegramHook.connected) {
|
||||
ChatMessageToTelegram chat = new ChatMessageToTelegram();
|
||||
chat.parse_mode = "Markdown";
|
||||
@ -238,4 +256,9 @@ public class TelegramChat extends JavaPlugin implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public static TelegramChat getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
package de.Linus122.TelegramComponents;
|
||||
|
||||
public class User {
|
||||
private int id;
|
||||
private long id;
|
||||
private boolean is_bot;
|
||||
private String first_name;
|
||||
private String last_name;
|
||||
|
||||
public int getId() {
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ name: TelegramChat
|
||||
main: de.Linus122.TelegramChat.TelegramChat
|
||||
version: ${project.version}
|
||||
authors: [Linus122]
|
||||
softdepend: [Vault]
|
||||
softdepend: [Vault, SuperVanish, PremiumVanish]
|
||||
description: Brings minecraft chat to Telegram!
|
||||
commands:
|
||||
telegram:
|
||||
|
Loading…
Reference in New Issue
Block a user