SpamProtection-go

SpamProtection-Go is an Official golang wrapper for Intellivoid SpamProtection API, which is fast, secure and requires no additional packages to be installed.

What is SpamProtection?

SpamProtection is a community powered solution with the goal to effectively combat spam on Telegram using machine learning and manual spam reporting.
This API allows you to lookup a user, chat or channel in the SpamProtection database, this method does not require authentication and there are no rate limits.


Supported Go versions

For better experience, we recommend you to use latest version of Go (v1.16), but this library requires at least Go version 1.15.


Features

  • Uses official Intellivoid API, which makes this library:
    • Easy to update
    • Guaranteed to match the docs
    • No third party endpoints
    • Self-documenting (Contains all pre-existing Intellivoid's docs)
  • It's in pure go, no need to install any kind of plugin or include any kind of additional files.
  • No third party library bloat; only uses standard library.
  • Type safe; no weird interface{} logic.
  • Multiple searching for blacklist flags.

Getting started

You can easily download the library with the standard go get command:

go get github.com/Intellivoid/Intellivoid.SpamProtection-go

or

dep ensure -add github.com/Intellivoid/Intellivoid.SpamProtection-go

Full documentation of this library, can be found here.


How to use

The spamProtection package contains all helpers you need!
You can lookup a user, channel, group or a bot and recieve it's status with calling only one function. (using either username or user id)

package main

import "github.com/Intellivoid/Intellivoid.SpamProtection-go/spamProtection"

func main() {
	// get information of a user, channel or a group with a telegram id (int64)
	info, err := spamProtection.GetInfoByID(1234567890)
	if err != nil {
		log.Fatal(err.Error())
	}

	// use this method to see if the target is blacklisted or not
	if info.IsBlacklisted() {
		// use GetType() method to see if the target is a user, 
		// channel, group or bot?
		log.Println("This " + info.GetType() + 
			" is blacklisted, because of " + info.GetBlacklistReason())
		// an example of the output would be:
		// This user is blacklisted, because of RAID Initializer / Participator
	}

	// get information of a user, channel or a group with a telegram username (string)
	// you can use also use '@' at the first of username
	info2, err := spamProtection.GetInfoByUsername("<username>")
	if err != nil {
		log.Fatal(err.Error())
	}

	// Yup! it supports multiple searching
	// pass more than one flag and see if the target has one of them or not!
	if info2.HasFlag(spamProtection.SpamFlag, spamProtection.ChildAbuseFlag) {
		log.Println("this " + info2.GetType() +
			" is either a spammer or a child abuser")
		log.Println("it has " + info2.GetBlacklistFlag() + " flag!")
		// an example of the output would be:
		// this user is either a spammer or a child abuser
		// it has 0xSPAM flag!
	}

	// or see if a user is a potential spammer or not 
	// (based on their last activities)
	if info2.IsPotential() {
		log.Println("Be careful! this " + info2.GetType() +
			" is a potential spammer!")
		// an example for the output would be:
		// "Be careful! this bot is a potential spammer!"
	}

	// also make sure you are joined in our official  group
	if info2.IsVerified() {
		log.Println("This " + info2.GetType() +
			" is verified by Intellivoid Technologies")
		// an example for the output would be:
		// This group is verified by Intellivoid Technologies
	}
}

GitHub

https://github.com/intellivoid/Intellivoid.SpamProtection-go