Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/twin/pythonxatbot
DEPRECATED A Xat bot in Python (2.7) that does not require the (bot) power.
https://github.com/twin/pythonxatbot
bot deprecated python xat
Last synced: about 2 months ago
JSON representation
DEPRECATED A Xat bot in Python (2.7) that does not require the (bot) power.
- Host: GitHub
- URL: https://github.com/twin/pythonxatbot
- Owner: TwiN
- Created: 2016-07-16T03:03:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-02-10T04:42:40.000Z (almost 6 years ago)
- Last Synced: 2024-10-11T16:11:23.654Z (3 months ago)
- Topics: bot, deprecated, python, xat
- Language: Python
- Homepage:
- Size: 146 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PythonXatBot
A Xat bot in Python that does not require the (bot) power.
## Requirements
python 2.7## How to use
1. open the file bot.py and edit these variables: botID, botK1, botK2 to your bot settings (you can generate these parameters on [https://xat.com/web_gear/chat/auser3.php](https://xat.com/web_gear/chat/auser3.php)
2. (optional) edit the botDisplayName, botAvatar and botHomepage
3. open the file ```chatNames.txt``` and edit the name of the xats you want your bot to join ( one per line)
## Update (2019-02-09)
This project is no longer actively maintained.
## Update (2018-11-03)
The Xat API on my website is now deprecated and will be removed in the next few days.
## Update (2018-10-07)
I will deprecate the API for getting Xat chat's info _very_ soon. I have long since considered Xat to be dead, but I kept the API up in hope that Xat would eventually make changes. [They didn't](https://trends.google.com/trends/explore?date=today%205-y&q=Xat,Discord) - [Xat still uses Flash](https://trends.google.com/trends/explore?date=all&geo=US&q=Adobe%20Flash)
Here's a quick Java implementation, if somebody wants to make their own API:
```java
@Service
@Deprecated
public class XatApiService {
private static final Logger logger = LoggerFactory.getLogger(XatApiService.class);
private List chatPorts = List.of(10007, 10008, 10019, 10038);
/** You can find those at https://xat.com/web_gear/chat/ip2.htm */
private List chatIps = List.of("fwdelb-166679406.us-east-1.elb.amazonaws.com", "fwdelb2-1789343474.us-east-1.elb.amazonaws.com");
public String generateXatData(String chatName) throws IOException {
return chatName + ":" + getXatChatId(chatName) + ":" + getRandomXatChatIP() + ":" + getRandomXatChatPort();
}
private String getRandomXatChatIP() {
return chatIps.get((int)(Math.ceil(Math.random() * (chatIps.size())))-1);
}
private Integer getRandomXatChatPort() {
return chatPorts.get((int)(Math.ceil(Math.random() * (chatPorts.size())))-1);
}
public String getXatChatId(String chatName) throws IOException {
String chatId = "";
URL siteUrl = new URL("https://xat.com/" + chatName);
URLConnection connection = siteUrl.openConnection();
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String line = "";
while ((line = bufferedReader.readLine()) != null) {
if (line.toLowerCase().contains("name=\"chat\" flashvars=\"id=")) {
chatId = StringUtils.getBetween(line.toLowerCase(), "id=", "&");
break;
}
}
} catch (IOException e) {
logger.error("[getXatChatId] Failed to fetch chat id", e);
}
return chatId;
}
}
```## Update (2018-07-27)
This project is now maintained by [x00x90](https://github.com/x00x90)
## Update (2018-07-22)
This project is no longer actively maintained.
-------------------------
## Changelogs
**2018-07-27**: This bot now supports multiple xats at the same time
**2016-12-18**: Fixed bot not connecting issue. Reason: Xat servers have new ips. No modification was made on the bot script itself because the API on my website was the one that needed to be updated to give the right ips. ( https://twinnation.org/api/xat?chat=ring0 )
## Compatibility and Python version
This bot was made using **Python 2.7.10**, meaning it *most likely* works for 2.7.x. As for those of you who **absolutely** want to use 3.x, then you can learn about how to convert it easily by looking up *lib2to3* online.