XDChat Release 1.2.0

属性
项目名XDChat
版本Release 1.2.0
仓库GitHub

简介

一个简单的跨平台聊天软件

依赖

  1. Python3
  2. rich

运行

git clone https://github.com/This-is-XiaoDeng/XDChat.git
cd XDChat
python3 -m pip install rich
python3 ./main.py

免责声明

禁止将 XDChat 用于违法违规用途,否则本人不会承担因此产生的任何责任

PyPiSearch

项目名PyPiSearch
版本v1.0
GitHubThis-is-XiaoDeng/PyPiSearch

简介

这是一个 PyPi 搜索程序,一定程度上解决了 pip 不支持搜包的问题

依赖

  1. Python3
  2. rich
  3. requests

使用方法

git clone https://github.com/This-is-XiaoDeng/PyPiSearch.git
pip install rich requests
python3 main.py

温馨提示

  1. 程序启动后根据提示输入关键词并回车即可搜索
  2. 搜索速度由包数量和网速决定
  3. GitHub 上还提供了 Linux x86_64 的二进制可执行程序

HTTP for TCP

信息

HTTP for TCP 不实名使用frp软件开网站!
源代码 GitHub
版本 v1.0
许可证 MIT

使用方法

客户端

  1. 克隆仓库
  2. 安装依赖(pip install -r requirememts.txt
  3. 设置 config.json
  4. 启动客户端
  5. 使用浏览器访问开启的服务器

服务端

  1. 克隆仓库
  2. 安装依赖(pip install -r requirememts.txt
  3. 设置 config.json
  4. 启动服务端

XChat Server V1.2-beta

简介

版本:V1.2-beta

XChat Server 是软件 XChat 的服务端,可以让您在1分钟内拥有一个自己的 XChat 服务器。

依赖

  1. Python3
  2. rich

使用教程

  1. 安装依赖,打开 XChat Server
  2. 输入端口
  3. 完成

源代码

from rich.console import Console
import socket
import json
import threading
import time

console = Console()
threads = {}
messages = [
    {"from":"Server","msg":"Server Started","time":time.time()}
]
threadList = []
users = {}

def handle(sock, addr):
    global console, messages, threads, threadList, users
    msgid = 0
    username = ""

    while True:
        resp_data = {
            "code":200,
            "msg":"OK",
            "data":{}
        }

        recv_data = sock.recv(1024)
        try:
            recv_data = recv_data.decode("utf-8")
            recv_data = json.loads(recv_data)

            if username != "":
                if recv_data["mode"] == "getMsg":
                    try:
                        resp_data["data"]["messages"] = messages[msgid:]
                        msgid = messages.__len__()
                    except:
                        resp_data["data"]["messages"] = []
                elif recv_data["mode"] == "sendMsg":
                    messages += [
                        {
                            "from":username,
                            "msg":recv_data["data"]["msg"],
                            "time":time.time()
                        }
                    ]
                    console.log(f"[CHAT] <{username}> {recv_data['data']['msg']}")

                elif recv_data["mode"] == "exit":
                    sock.close()
                    return 0

                elif recv_data["mode"] == "getList":
                    userList = []
                    for t in threadList:
                        if threads[t].is_alive():
                            userList += [users[t].getName()]
                    resp_data["data"]["list"] = userList


                else:
                    resp_data["code"] = 404
                    resp_data["msg"] = "Unkown mode"

            elif recv_data["mode"] == "login":
                username = recv_data["data"]["username"]
                # threads[addr[1]].setName(username)
                users[addr[1]] = username

            else:
                resp_data["code"] = 403
                resp_data["msg"] = "Please Login First"


        except Exception as e:
            console.print_exception(show_locals=True)
            resp_data["code"] = 500
            resp_data["msg"] = "Internal Server Error"
            resp_data["data"]["exception"] = str(e)

        # 回复
        resp_data = json.dumps(resp_data)
        sock.send(resp_data.encode("utf-8"))



if __name__ == "__main__":
    port = int(console.input("[blue]Port: "))

    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.bind(
        (
            "",
            port
        )
    )
    sock.listen(128)

    console.log(f"Server started on 0.0.0.0:{port}.")

    while True:
        s, addr = sock.accept()
        console.log(f"{addr[1]} connected to this server.")
        threadList += [addr[1]]
        users[addr[1]] = ""

        threads[addr[1]] = threading.Thread(None, lambda: handle(s, addr))
        threads[addr[1]].setDaemon(True)
        threads[addr[1]].start()

XChat-CLI pre-1

XChat Client CLI

版本:pre-1

依赖

  1. Python3(Tested 3.10.6)
  2. rich

简介

XChat 是一个简单好用的聊天软件,它(指原版,给改了不关我事熬)不会收集任何除必须外的用户信息

测试服务器

  • IP:124.222.63.135
  • Port:19180

源代码

import socket
from rich.console import Console
import threading
import json
import time

console = Console()
sock = None
sockThread = None

def send(data):
    global sock
    sock.send(
        json.dumps(data).encode("utf-8")
    )

    return json.loads(
        sock.recv(1024).decode("utf-8")
    )

def getMsg():
    global sock, console
    while True:
        msg = send(
            {
                "mode":"getMsg",
                "data":{}
            }
        )
        try:
            for m in msg["data"]["messages"]:
                t = time.strftime(
                    "%H:%M:%S",
                    time.localtime(m["time"])
                )

                console.print(
                    f'[{t}]<[yellow]{m["from"]}[/]> {m["msg"]}'
                )
        except:
            pass

if __name__ == "__main__":
    console.print("[green]XChat CLI V1")
    sock = socket.socket(
            socket.AF_INET,
            socket.SOCK_STREAM
    )

    sock.connect(
        (
            console.input("[yellow]IP: "),
            int(console.input("[yellow]Port: "))
        )
    )

    loginRecv = send(
        {
            "mode":"login",
            "data":{
                "username":console.input(
                    "[yellow]User: "
                )
            }
        }
    )

    if loginRecv["code"] == 200:
        console.print(
            "[green]Server connected!"
        )

        sockThread = threading.Thread(
            None,
            getMsg
        )
        sockThread.start()

        while True:
            sendMsg = console.input("")
            send(
                {
                    "mode":"sendMsg",
                    "data":{
                        "msg":sendMsg
                    }
                }
            )