Coder Social home page Coder Social logo

pythonxatbot's Introduction

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

  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 - Xat still uses Flash

Here's a quick Java implementation, if somebody wants to make their own API:

@Service
@Deprecated
public class XatApiService {
	
	private static final Logger logger = LoggerFactory.getLogger(XatApiService.class);
	
	private List<Integer> chatPorts = List.of(10007, 10008, 10019, 10038);
	/** You can find those at https://xat.com/web_gear/chat/ip2.htm */
	private List<String> 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

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.

pythonxatbot's People

Contributors

twin avatar

Stargazers

 avatar

Watchers

 avatar  avatar

pythonxatbot's Issues

program xat.com

I have a program that needs help and could make you famous on github

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.