Raised This Month: $32 Target: $400
 8% 

[ANY] Telegram API & RCON


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Plugin ID:
6080
Plugin Version:
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Simple API to send message thru Telegram bots!
    Old 04-10-2018 , 12:26   [ANY] Telegram API & RCON
    Reply With Quote #1

    Hi,

    This is a simple plugin to send message with telegram (using bots)

    Include file
    PHP Code:
     /**
     * Sends a message thru a Telegram bot.
     *
     * @param message        The message to send.
     * @param bot            The bot token. (without 'bot').
     * @param chat            The chat id.
     *
     * @return                True if the request was sent successfully, false otherwise.
     */
    native bool Telegram_SendMessage(const char[] messagechar[] bot, const char[] chat); 
    Example on GitHub
    PHP Code:
    public void OnPluginStart()
    {
        
    RegConsoleCmd("sm_send"Cmd_Send);
    }

    public 
    Action Cmd_Send(int clientint args)
    {
        if (
    args 1)
        {
            
    ReplyToCommand(client"[SM] Invalid args: sm_send <message>");
            return 
    Plugin_Handled;
        }
        
        
    char sMessage[128];
        
    GetCmdArgString(sMessagesizeof(sMessage));
        
        if (!
    Telegram_SendMessage(sMessage"56xxxxxx:AAGgLrtxTgB_cMBr0ZNUxxxxxxxxxxxxxxx""-1001xxxxxxxxx"))
        {
            
    ReplyToCommand(client"[SM] Failed to send the message!");
            return 
    Plugin_Handled;
        }
        
        
    ReplyToCommand(client"[SM] Sent: '%s' successfully"sMessage);
        return 
    Plugin_Handled;

    How to create a telgram bot?
    How do I get a chat id?



    THIS PLUGIN REQUIRES SteamWorks


    DOWNLOAD

    Sourcecode on GitHub


    RCON BOT
    Using this bot you can use the RCON in Telegram!

    Sourcecode on GitHub
    __________________
    My Plugins
    SPCode


    Steam: hexer504
    Telegram: Hexah
    Discord: Hexah#6903

    If you like my work you can donate here!

    Last edited by Papero; 04-16-2018 at 07:55.
    Papero is offline
    Obyboby
    Veteran Member
    Join Date: Sep 2013
    Old 04-10-2018 , 12:28   Re: Telegram API
    Reply With Quote #2

    WOW!
    I'm going to test this asap. Really wanted this feature!!
    Thanks!!
    __________________
    Obyboby is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 04-10-2018 , 12:39   Re: Telegram API
    Reply With Quote #3

    You should probably look into making this a POST message to the api instead of GET. I'm not sure if it's bas practice or what but you may end up with unexpected results.
    Mitchell is offline
    Papero
    Veteran Member
    Join Date: Aug 2016
    Location: Italy
    Old 04-10-2018 , 12:40   Re: Telegram API
    Reply With Quote #4

    Quote:
    Originally Posted by Mitchell View Post
    You should probably look into making this a POST message to the api instead of GET. I'm not sure if it's bas practice or what but you may end up with unexpected results.
    I've seen here that they used GET.
    __________________
    My Plugins
    SPCode


    Steam: hexer504
    Telegram: Hexah
    Discord: Hexah#6903

    If you like my work you can donate here!
    Papero is offline
    Obyboby
    Veteran Member
    Join Date: Sep 2013
    Old 04-10-2018 , 12:52   Re: [ANY] Telegram API
    Reply With Quote #5

    Trying to figure out where the bot and chat IDs need to be placed.
    __________________

    Last edited by Obyboby; 04-10-2018 at 12:52.
    Obyboby is offline
    Papero
    Veteran Member
    Join Date: Aug 2016
    Location: Italy
    Old 04-10-2018 , 12:54   Re: [ANY] Telegram API
    Reply With Quote #6

    Quote:
    Originally Posted by Obyboby View Post
    Trying to figure out where the bot and chat IDs need to be placed.
    PHP Code:
    if (!Telegram_SendMessage(sMessage"BOT TOKEN""CHATID")) 
    __________________
    My Plugins
    SPCode


    Steam: hexer504
    Telegram: Hexah
    Discord: Hexah#6903

    If you like my work you can donate here!
    Papero is offline
    Obyboby
    Veteran Member
    Join Date: Sep 2013
    Old 04-10-2018 , 12:55   Re: [ANY] Telegram API
    Reply With Quote #7

    Quote:
    Originally Posted by Papero View Post
    PHP Code:
    if (!Telegram_SendMessage(sMessage"BOT TOKEN""CHATID")) 
    So there's no CFG file being generated and I need to edit the source code and recompile the plugin? Correct?
    __________________
    Obyboby is offline
    Papero
    Veteran Member
    Join Date: Aug 2016
    Location: Italy
    Old 04-10-2018 , 12:58   Re: [ANY] Telegram API
    Reply With Quote #8

    Quote:
    Originally Posted by Obyboby View Post
    So there's no CFG file being generated and I need to edit the source code and recompile the plugin? Correct?
    The API (telegram.smx) doens't add any command, the example.sp isn't enabled by default, you should compile only example.sp (By default anyone can do sm_send you should either override it or change the source)
    __________________
    My Plugins
    SPCode


    Steam: hexer504
    Telegram: Hexah
    Discord: Hexah#6903

    If you like my work you can donate here!

    Last edited by Papero; 04-10-2018 at 12:58.
    Papero is offline
    Obyboby
    Veteran Member
    Join Date: Sep 2013
    Old 04-10-2018 , 12:58   Re: [ANY] Telegram API
    Reply With Quote #9

    Got it to work lol.
    Really promising and really hope to see the ability to send rcon commands from the telegram chat over to the console

    Example: player A is reported with STEAM ID shown
    Reply from Telegram chat with /kick, /ban, whatever
    Apply action on the server

    Or at least have the ability to send /rcon <argument> commands. First option would be better obviously but I'm no coder so idk how hard to achieve that is
    __________________

    Last edited by Obyboby; 04-10-2018 at 13:13.
    Obyboby is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 04-10-2018 , 13:05   Re: Telegram API
    Reply With Quote #10

    Quote:
    Originally Posted by Papero View Post
    I've seen here that they used GET.
    php though..
    Mitchell is offline
    Reply


    Thread Tools
    Display Modes

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 13:07.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode