Skip to content

The official rust implementation of the SpamProtectionBot API

License

Notifications You must be signed in to change notification settings

intellivoid/SpamProtection-Rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpamProtection-rs

Table of contents

About

SpamProtection-Rust is a Rust wrapper for Intellivoid SpamProtection API which uses the Reqwest library to make the request and serde to parse the json output.

This wrapper was made in focus of speed, reliability and memory safety.

Supported Rust version

At the time of development we used rustc version 1.53.0. Anything newer than this should work fine with the library unless if there were any syntax breaking changes included in future rust updates in which we will update our code to the latest standards.

Features

  • Easy to use
  • Looking up userID, PTID or username
  • Check if user is blacklisted due to specific flag
  • Check if user is a operator
  • Check if user is verified
  • Check if user is official
  • Check if user is a agent
  • Spam and ham prediction
  • Language prediction with probability

How to use

To use this library in your project you would need to add the below code to your Cargo.toml

[dependencies]
spamprotection = "0.1.0-2"

You can also use the git version of our library for newer improvements

[dependencies]
spamprotection = { git = "https://github.com/Intellivoid/SpamProtection-Rust" }

Here’s an example of how you can use the spamprotection library in your code

use spamprotection::info;
use std::env;

/* We would need to first to declare the spamprotection library with use declaration.
   We would also need to declare the env trait from std library as args variable will be collecting the arguments passed to the program.
*/

fn main()
{
    /* Here we will need to assign a Vector type to args variable to collect the arguments passed to program.
	 Then we will need to assign String type to arg variable to parse the arguments passed.
	 Alternatively you can use the commented code below too if you don't want an argument-based program.
	 You don't need to add quotes for userID, but you'll need to add quotes if you want to check with username.

	 let info = info::full(123456789);

    */

   /*
   You can also use a private_telegram_id (PTID) to get info
   Example:
   info::full("TEL-9b7ef46a550112edea3ba46220283b1bfd8feddd09b26888524ef7245947e97f-b105a169");
   */


    let args: Vec<String> = env::args().collect();
    let arg: String = args[1].parse().expect("invalid account");

    /* Here's where we will start by declaring the info variable and assign it to the info module in spamprotection library
	 which calls the full() method with given the arg variable as the value.

	 info has several fields and subfields, in the below example we would be using .results and its subtype .results.attributes.
    */
    let info = info::full(arg);

    // You can check if the user is blacklisted or not via this!

    if info.get_bl() {
	  println!("This {} is blacklisted due to {} with the {} flag.\n", info.get_type(), info.get_bl_reason(), info.get_flag());
    } else {
	  println!("This {} is not blacklisted!\n", info.get_type());
    }

    // You can also check if the user is a potential scammer or not!

    if info.get_potential() {
	  println!("Beware! This {} is a potential spammer!!", info.get_type());
    }

Check our examples directory for more info onto how you can use our library.

Credits

This project was inspired by SpamProtection-Go.

Thanks to everyone who helped us with this project.

License

This project is under the GPL-3.0 license.

About

The official rust implementation of the SpamProtectionBot API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages