블로그 이미지
010-9967-0955 보미아빠

카테고리

보미아빠, 석이 (498)
밥벌이 (16)
싸이클 (1)
일상 (1)
Total
Today
Yesterday

달력

« » 2024.3
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

공지사항

최근에 올라온 글

telegram bot

카테고리 없음 / 2018. 7. 10. 18:54

[bot 만들기]

텔레그램 안에서 BotFather 친구 맺음

/start

/newbot

yourbotname

yourbotname_bot



Use this token to access the HTTP API:

0000000:VVVhJhOKsTl_2Vppzc93OKsOd0PpLVcVZlM

For a description of the Bot API, see this page: https://core.telegram.org/bots/api


/token 

@yourbotname_bot





[그룹만들어 봇 초대하기]

인간 사용자가 그룹을 만들어

봇 사용자가 그룹을 찾아 들어감 Add to Group






[봇이 들어간 group 내 사용자 리스트 구하기]

https://api.telegram.org/bot00000000:fdsafdsafda_dsafdsafdas/getUpdates


id 양수는 개인

id 음수는 그룹




-- 이제 코딩 

https://github.com/TelegramBots/Telegram.Bot.Examples/blob/master/Telegram.Bot.Examples.Echo/Program.cs







using System;

using System.Collections.Generic;

using System.Diagnostics;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using Telegram.Bot;

using Telegram.Bot.Args;

using Telegram.Bot.Types.Enums;

using Telegram.Bot.Types.InlineQueryResults;

using Telegram.Bot.Types.ReplyMarkups;



namespace telegramtest2

{

    class Program

    {

        private static readonly TelegramBotClient Bot = new Telegram.Bot.TelegramBotClient("botid");

        //private static readonly TelegramBotClient Bot = new Telegram.Bot.TelegramBotClient("botid");

        static void Main(string[] args)

        {

            Bot.OnMessage += Bot_OnMessage;

            var me = Bot.GetMeAsync().Result;


            Console.Title = me.Username;

            //SendMsg(5646546464565, "메롱2");


            /// Recv Start

            Bot.StartReceiving();

            Console.ReadLine();

            /// Recv Stop

            Bot.StopReceiving();


            

            Console.ReadKey();

        }




        private static async void SendMsg(long chatId, string message)

        {

            await Bot.SendTextMessageAsync(chatId, message);

        }


        private static async void Bot_OnMessage(object sender, Telegram.Bot.Args.MessageEventArgs messageEventArgs)

        {

            var message = messageEventArgs.Message;


            if (message.Text.StartsWith("/cmd"))

            {

                Console.WriteLine(message.Chat.Id);

                Debug.WriteLine(message.Chat.Id);

                await Bot.SendTextMessageAsync(message.Chat.Id, "나한테 일시키기 마라");

            }

        }

    }


    

}

Posted by 보미아빠
, |

최근에 달린 댓글

최근에 받은 트랙백

글 보관함