Compare commits

..

No commits in common. "178399bf94fd7d1378958e1b1f43d09ae31ffae9" and "5dee2150a8dd22f1391cf1746cc2f71a1b09ac65" have entirely different histories.

8 changed files with 19 additions and 121 deletions

4
.gitignore vendored
View File

@ -1,4 +0,0 @@
/.idea
*.class
/target
*.iml

View File

@ -1,43 +1,21 @@
[![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 Bukkit plugin compatible with Paper/Spigot versions 1.7 through 1.18.*, that connects Telegram with Minecraft.
TelegramChat is a Spigot plugin compatible with Spigot versions 1.7 through 1.16.*, 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
View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>xyz.spaceio</groupId>
<artifactId>telegramchat</artifactId>
<version>1.0.18-SNAPSHOT</version>
<version>1.0.17-SNAPSHOT</version>
<name>TelegramChat</name>
<url>https://www.spigotmc.org/resources/telegramchat.16576/</url>
@ -25,24 +25,15 @@
<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.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</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>
@ -51,16 +42,16 @@
</dependency>
</dependencies>
<distributionManagement>
<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>
<repository>
<id>spaceio-releases</id>
<name>releases</name>
<url>https://repo.spaceio.xyz/repository/maven-releases/</url>
</repository>
</distributionManagement>
<build>
<!-- Uses the properties in this file for plugin.yml and config.yml -->
@ -81,8 +72,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>9</source>
<target>9</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- Sets the custom JARfile name (Project name without spaces is good) -->

View File

@ -27,7 +27,7 @@ import net.milkbowl.vault.permission.Permission;
public class CommandHandler extends ConsoleHandler implements TelegramActionListener {
private Permission permissionsAdapter;
private long lastChatId = -1;
private int lastChatId = -1;
private long lastCommandTyped;
private Telegram telegram;

View File

@ -1,44 +0,0 @@
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);
}
}
}

View File

@ -12,8 +12,6 @@ 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;
@ -42,25 +40,17 @@ 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();
@ -200,10 +190,6 @@ 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";
@ -228,10 +214,6 @@ 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";
@ -256,9 +238,4 @@ public class TelegramChat extends JavaPlugin implements Listener {
}
}
public static TelegramChat getInstance()
{
return instance;
}
}

View File

@ -1,16 +1,16 @@
package de.Linus122.TelegramComponents;
public class User {
private long id;
private int id;
private boolean is_bot;
private String first_name;
private String last_name;
public long getId() {
public int getId() {
return id;
}
public void setId(long id) {
public void setId(int id) {
this.id = id;
}

View File

@ -2,7 +2,7 @@ name: TelegramChat
main: de.Linus122.TelegramChat.TelegramChat
version: ${project.version}
authors: [Linus122]
softdepend: [Vault, SuperVanish, PremiumVanish]
softdepend: [Vault]
description: Brings minecraft chat to Telegram!
commands:
telegram: