MCPcopy Index your code
hub / github.com/Sreyas-Sreelal/tgconnector

github.com/Sreyas-Sreelal/tgconnector @1.1.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.1.1 ↗ · + Follow
76 symbols 119 edges 11 files 0 documented · 0% updated 22mo ago1.1.1 · 2024-09-09★ 422 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

TgConnector

Build Status Build status sampctl-supported GitHub issues GitHub pull requests GitHub pull license

A telegram connector plugin that helps to interact with telgram bots through SA-MP.

Installing

If you are a sampctl user

sampctl p install Sreyas-Sreelal/tgconnector

OR

  • Download suitable binary files from releases for your operating system
  • Add it your plugins folder
  • Add tgconnector to server.cfg or tgconnector.so (for linux)
  • Add tgconnector.inc in includes folder

Building

  • Clone the repo

    git clone https://github.com/Sreyas-Sreelal/tgconnector.git

  • Use makefile to compile and test

    • Setup testing environment

      make setup * To build release version

      make release * Run tests

      make run

API

Checkout the Wiki

Example

A basic bot

#include<a_samp>
#include<tgconnector>
#include<zcmd>

#define CHAT_ID (TGChatId:"YOUR_CHAT_ID_HERE")

new TGBot:g_bot;

main() {
    //Store bot token in SAMP_TG_BOT environment variable and connect from it
    g_bot = TG_ConnectFromEnv("SAMP_TG_BOT");
    if(g_bot != INVALID_BOT_ID) {
        printf("bot connected successfully!");
    } else {
        printf("Error: bot couldn't connect");
    }
}

public OnTGMessage(TGBot:bot,TGUser:fromid[],TGMessage:messageid) {

    if(g_bot != bot){
        return 1;
    }

    new
        message[50],
        username[24],
        chatname[56],
        server_msg[128];

    TG_CacheGetMessage(message);
    TG_CacheGetUserName(username);
    TG_CacheGetChatName(chatname);

    format(server_msg,128,"[%s] %s(%s): %s",chatname,username,_:fromid,message);
    SendClientMessageToAll(-1,server_msg);

    return 1;
}


public OnTGUserJoined(TGBot:bot,TGUser:userid[]) {
    new
        TGChatId:chatid[12],
        username[24],
        chatname[56],
        server_msg[128];

    TG_CacheGetUserName(username);
    TG_CacheGetChatId(chatid);
    TG_CacheGetChatName(chatname);

    format(server_msg,128,"User %s(%d) joined %s(%s)",username,_:userid,chatname,_:chatid);
    SendClientMessageToAll(-1,server_msg);
    return 1;
}

public OnTGUserLeft(TGBot:bot,TGUser:userid[]) {
    new
        TGChatId:chatid[12],
        username[24],
        chatname[56],
        server_msg[128];

    TG_CacheGetUserName(username);
    TG_CacheGetChatID(chatid);
    TG_CacheGetChatName(chatname);

    format(server_msg,128,"User %s(%s) left %s(%s)",username,_:userid,chatname,_:chatid);
    SendClientMessageToAll(-1,server_msg);
    return 1;
}

CMD:sendtgmessage(playerid,params[]) {
    TG_SendMessage(g_bot,CHAT_ID,params);
    return 1;
}

Core symbols most depended-on inside this repo

Shape

Method 42
Class 18
Function 14
Enum 2

Languages

Rust100%

Modules by API surface

src/natives.rs25 symbols
src/api.rs13 symbols
src/methods.rs9 symbols
src/types.rs8 symbols
src/plugin.rs6 symbols
src/internals.rs6 symbols
src/callbacks.rs5 symbols
src/http.rs3 symbols
src/encode.rs1 symbols

For agents

$ claude mcp add tgconnector \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page