This commit is contained in:
n0tr1v 2022-01-19 19:36:14 -08:00
commit 7cf731d509
11 changed files with 6318 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
captcha.gif
samples
target
dist
*.log
*.svg
*.env

3067
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

35
Cargo.toml Normal file
View File

@ -0,0 +1,35 @@
[package]
name = "bhcli"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
base64 = "0.13.0"
chrono = "0.4.19"
clap = "3.0.0-beta.4"
clipboard = "0.5.0"
colors-transform = "0.2.4"
confy = "0.4.0"
crossbeam = "0.8.1"
crossbeam-channel = "0.5.1"
crossterm = { version = "0.21.0" }
http = "0.2.4"
image = "0.23.14"
lazy_static = "1.4.0"
linkify = "0.7.0"
rand = "0.8.4"
regex = "1.5.4"
reqwest = { version = "0.11.4", features = ["blocking", "cookies", "socks", "multipart"] }
rodio = "0.14.0"
rpassword = "5.0.1"
select = "0.6.0-alpha.1"
serde = "1.0.130"
serde_derive = "1.0.88"
serde_json = "1.0"
termage = "1.1.1"
textwrap = "0.14.2"
toml = "0.5.8"
tui = { version = "0.16.0", features = ["crossterm"], default-features = false }
unicode-width = "0.1.8"

3
Dockerfile Normal file
View File

@ -0,0 +1,3 @@
FROM rust:1.54 as bhcli-builder
RUN apt-get update
RUN apt-get install -y pkg-config libasound2-dev libssl-dev cmake libfreetype6-dev libexpat1-dev libxcb-composite0-dev libx11-dev

37
Makefile Normal file
View File

@ -0,0 +1,37 @@
PWD = $(shell pwd)
build-docker-bin:
docker run --rm -it -v $(PWD):/Documents/bhcli -w /Documents/bhcli bhcli sh -c \
'CARGO_TARGET_DIR=./target/linux cargo build --release'
build-darwin:
cargo build --release
cp target/release/bhcli dist/bhcli.darwin.amd64
tar -czvf dist/bhcli.darwin.amd64.tar.gz dist/bhcli.darwin.amd64
openssl dgst -sha256 dist/bhcli.darwin.amd64.tar.gz | cut -d ' ' -f 2 > dist/bhcli.darwin.amd64.tar.gz.checksum
rm dist/bhcli.darwin.amd64
build-linux: build-docker-bin
cp target/linux/release/bhcli dist/bhcli.linux.amd64
tar -czvf dist/bhcli.linux.amd64.tar.gz dist/bhcli.linux.amd64
openssl dgst -sha256 dist/bhcli.linux.amd64.tar.gz | cut -d ' ' -f 2 > dist/bhcli.linux.amd64.tar.gz.checksum
rm dist/bhcli.linux.amd64
cross-compile-windows:
cargo build --release --target x86_64-pc-windows-gnu
cp target/x86_64-pc-windows-gnu/release/bhcli.exe dist/bhcli.windows.amd64.exe
zip dist/bhcli.windows.amd64.zip dist/bhcli.windows.amd64.exe
openssl dgst -sha256 dist/bhcli.windows.amd64.zip | cut -d ' ' -f 2 > dist/bhcli.windows.amd64.zip.checksum
rm dist/bhcli.windows.amd64.exe
process-windows:
zip dist/bhcli.windows.amd64.zip dist/bhcli.exe
openssl dgst -sha256 dist/bhcli.windows.amd64.zip | cut -d ' ' -f 2 > dist/bhcli.windows.amd64.zip.checksum
rm dist/bhcli.exe
rsync:
rsync --recursive --times --compress --progress dist/ torsv:/root/dist/downloads-bhcli
deploy: build-darwin cross-compile-windows build-linux rsync
.PHONY: build-darwin process-windows cross-compile-windows rsync

71
README.md Normal file
View File

@ -0,0 +1,71 @@
# BHCLI
![screenshot](screenshot.png "Screenshot")
## Description
This is a CLI client for any of [le-chat-php](https://github.com/DanWin/le-chat-php)
currently supported chats are [Black Hat Chat](http://blkhatjxlrvc5aevqzz5t6kxldayog6jlx5h7glnu44euzongl4fh5ad.onion) and
[Daniel's chat](http://danschat356lctri3zavzh6fbxg2a7lo6z3etgkctzzpspewu7zdsaqd.onion)
## Pre-built binaries
Pre-buit binaries can be found on the [official website](http://dkforestseeaaq2dqz2uflmlsybvnq2irzn4ygyvu53oazyorednviid.onion/bhcli)
## Features
- Sound notifications when tagged/pmmed
- Private messages `/pm username message`
- Kick someone `/kick username message` | `/k username message`
- Delete last message `/dl`
- Delete last X message `/dl5` will delete the last 5 messages
- Delete all messages `/dall`
- Ignore someone `/ignore username`
- Unignore someone `/unignore username`
- Toggle notifications sound `m`
- Toggle a "guest" view, by filtering out PMs and "Members chat" `shift+G`
- Filter messages `/f terms`
- Copy a selected message to clipboard `ctrl+C` | `y`
- Copy the first link in a message to clipboard `shift+Y`
- Directly tag author of selected message `t` will prefil the input with `@username `
- Directly private message author of selected message `p` will prefil the input with `/pm username `
- Shortcut to kick author of selected message `ctrl+k` will prefil the input with `/kick username `
- captcha is displayed directly in terminal 10 times the real size
- Upload file `/u C:\path\to\file.png @username message` (@username is optional) `@members` for members group
- `<tab>` to autocomplete usernames while typing
### Editing mode
- `ctrl+A` Move cursor to start of line
- `ctrl+E` Move cursor to end of line
- `ctrl+F` Move cursor a word forward
- `ctrl+B` Move cursor a word backward
### Messages navigation
- Page down the messages list `ctrl+D` | `page down`
- Page up the messages list `ctrl+U` | `page up`
- Going down 1 message `j` | `down arrow`
- Going up 1 message `k` | `up arrow`
## Build from source
### Windows
- Install C++ build tools https://visualstudio.microsoft.com/visual-cpp-build-tools/
- Install Rust https://www.rust-lang.org/learn/get-started
- Download & extract code source
- Compile with `cargo build --release`
### OSx
- Install Rust https://www.rust-lang.org/learn/get-started
- Compile with `cargo build --release`
### Linux
- Install Rust
- Install dependencies `apt-get install -y pkg-config libasound2-dev libssl-dev cmake libfreetype6-dev libexpat1-dev libxcb-composite0-dev libx11-dev`
- Compile with `cargo build --release`
## Cross compile
`cargo build --release --target x86_64-pc-windows-gnu`

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

3042
src/main.rs Normal file

File diff suppressed because it is too large Load Diff

BIN
src/sound1.mp3 Normal file

Binary file not shown.

1
src/util/event.rs Normal file
View File

@ -0,0 +1 @@

55
src/util/mod.rs Normal file
View File

@ -0,0 +1,55 @@
pub mod event;
use tui::widgets::ListState;
pub struct StatefulList<T> {
pub state: ListState,
pub items: Vec<T>,
}
impl<T> StatefulList<T> {
pub fn new() -> StatefulList<T> {
StatefulList {
state: ListState::default(),
items: Vec::new(),
}
}
pub fn next(&mut self) {
if self.items.len() == 0 {
return;
}
let i = match self.state.selected() {
Some(i) => {
if i >= self.items.len() - 1 {
0
} else {
i + 1
}
}
None => 0,
};
self.state.select(Some(i));
}
pub fn previous(&mut self) {
if self.items.len() == 0 {
return;
}
let i = match self.state.selected() {
Some(i) => {
if i == 0 {
self.items.len() - 1
} else {
i - 1
}
}
None => 0,
};
self.state.select(Some(i));
}
pub fn unselect(&mut self) {
self.state.select(None);
}
}