پرش به محتویات

متد ها

گرفتن اطلاعات بات

  • متد: getMe
  • ورودی
فیلد نوع توضیحات
token str توکن
  • خروجی
فیلد نوع توضیحات
bot Bot بات
  • مثال

    curl -X POST https://botapi.rubika.ir/v3/{token}/getMe
    

    import requests
    
    url = f'https://botapi.rubika.ir/v3/{token}/getMe'
    
    response = requests.post(url)
    
    print(response.text)
    

    from rubika_bot.requests import get_me
    from rubika_bot.models import Bot
    
    bot: Bot = get_me(token='SUPER_SECRET_TOKEN')
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//getMe',
      'headers': {
      }
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

ارسال پیام (Text, Keypad, InlineKeypad)

  • متد: sendMessage
  • ورودی
فیلد نوع توضیحات
token str توکن
chat_id str شناسه چت
text str متن پیام
chat_keypad Keypad keypad
disable_notification bool غیرفعال کردن اعلان؟ (پیشفرض false)
inline_keypad Keypad keypad
reply_to_message_id Optional[str] در جوابِ پیامِ؟
chat_keypad_type ChatKeypadTypeEnum نوع keypad
  • خروجی
فیلد نوع توضیحات
message_id str شناسه پیام
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//sendMessage' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "chat_id": "{chat_id}",
                "text": "Welcome",
                "inline_keypad": {
                    "rows": [
                        {
                            "buttons": [
                                {
                                    "id": "100",
                                    "type": "Simple",
                                    "button_text": "Add Account"
                                }
                            ]
                        },
                        {
                            "buttons": [
                                {
                                    "id": "101",
                                    "type": "Simple",
                                    "button_text": "Edit Account"
                                },
                                {
                                    "id": "102",
                                    "type": "Simple",
                                    "button_text": "Remove Account"
                                }
                            ]
                        }
                    ]
                }
            }'
    

    import requests
    import json
    
    url = f"https://botapi.rubika.ir/v3/{token}/sendMessage"
    
    data = {
        "chat_id": chat_id,
        "text": "Welcome",
        "inline_keypad": {
            "rows": [
                {
                    "buttons": [
                        {
                            "id": "100",
                            "type": "Simple",
                            "button_text": "Add Account"
                        }
                    ]
                },
                {
                    "buttons": [
                        {
                            "id": "101",
                            "type": "Simple",
                            "button_text": "Edit Account"
                        },
                        {
                            "id": "102",
                            "type": "Simple",
                            "button_text": "Remove Account"
                        }
                    ]
                }
            ]
        }
    }
    headers = {
        'Content-Type': 'application/json'
    }
    
    response = requests.post(url, headers=headers, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import send_message
    from rubika_bot.models import Keypad, KeypadRow, Button
    
    b1 = Button(id='100', type='Simple', button_text='Add Account')
    b2 = Button(id='101', type='Simple', button_text='Edit Account')
    b3 = Button(id='102', type='Simple', button_text='Remove Account')
    keypad = Keypad(
        rows=[
            KeypadRow(buttons=[b1]),
            KeypadRow(buttons=[b2, b3])
        ],
    )
    send_message(
        token='SUPER_SECRET_TOKEN',
        chat_id='CHAT_ID',
        text='Welcome',
        inline_keypad=keypad
    )
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//sendMessage',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
          "chat_id": chat_id,
          "text": "hello world"
          "inline_keypad": {
            "rows": [
              {
                "buttons": [
                  {
                    "id": "100",
                    "type": "Simple",
                    "button_text": "Add Account"
                  }
                ]
              },
              {
                "buttons": [
                  {
                    "id": "101",
                    "type": "Simple",
                    "button_text": "Edit Account"
                  },
                  {
                    "id": "102",
                    "type": "Simple",
                    "button_text": "Remove Account"
                  }
                ]
              }
            ]
          }
        })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

ارسال keypad

  • متد: sendMessage
  • ورودی
فیلد نوع توضیحات
token str توکن
chat_id str شناسه چت
text str متن پیام
chat_keypad_type ChatKeypadTypeEnum نوع keypad
chat_keypad Keypad keypad
disable_notification bool غیرفعال کردن اعلان؟ (پیشفرض false)
reply_to_message_id Optional[str] در جوابِ پیامِ؟
  • خروجی
فیلد نوع توضیحات
message_id str شناسه پیام
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//sendMessage' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "chat_id": "{chat_id}",
                "text": "Welcome",
                "chat_keypad_type": "New",
                "chat_keypad": {
                    "rows": [
                        {
                            "buttons": [
                                {
                                    "id": "100",
                                    "type": "Simple",
                                    "button_text": "Add Account"
                                }
                            ]
                        },
                        {
                            "buttons": [
                                {
                                    "id": "101",
                                    "type": "Simple",
                                    "button_text": "Edit Account"
                                },
                                {
                                    "id": "102",
                                    "type": "Simple",
                                    "button_text": "Remove Account"
                                }
                            ]
                        }
                    ],
                    "resize_keyboard": true,
                    "on_time_keyboard": false
                }
            }'
    

    import requests
    import json
    
    url = f"https://botapi.rubika.ir/v3/{token}/sendMessage"
    
    data = {
        "chat_id": chat_id,
        "text": "Welcome",
        "chat_keypad_type": "New",
        "chat_keypad": {
            "rows": [
                {
                    "buttons": [
                        {
                            "id": "100",
                            "type": "Simple",
                            "button_text": "Add Account"
                        }
                    ]
                },
                {
                    "buttons": [
                        {
                            "id": "101",
                            "type": "Simple",
                            "button_text": "Edit Account"
                        },
                        {
                            "id": "102",
                            "type": "Simple",
                            "button_text": "Remove Account"
                        }
                    ]
                }
            ],
            "resize_keyboard": True,
            "on_time_keyboard": False
        }
    }
    headers = {
        'Content-Type': 'application/json'
    }
    
    response = requests.post(url, headers=headers, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import send_message
    from rubika_bot.models import Keypad, KeypadRow, Button
    
    b1 = Button(id='100', type='Simple', button_text='Add Account')
    b2 = Button(id='101', type='Simple', button_text='Edit Account')
    b3 = Button(id='102', type='Simple', button_text='Remove Account')
    keypad = Keypad(
        rows=[
            KeypadRow(buttons=[b1]),
            KeypadRow(buttons=[b2, b3])
        ],
        resize_keyboard=True,
        on_time_keyboard=False
    )
    send_message(
        token='SUPER_SECRET_TOKEN',
        chat_id='CHAT_ID',
        text='Welcome',
        chat_keypad_type='New',
        chat_keypad=keypad
    )
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//sendMessage',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
          "chat_id": chat_id,
          "chat_keypad_type": "New",
          "text": "Welcome",
          "chat_keypad": {
            "rows": [
              {
                "buttons": [
                  {
                    "id": "100",
                    "type": "Simple",
                    "button_text": "Add Account"
                  }
                ]
              },
              {
                "buttons": [
                  {
                    "id": "101",
                    "type": "Simple",
                    "button_text": "Edit Account"
                  },
                  {
                    "id": "102",
                    "type": "Simple",
                    "button_text": "Remove Account"
                  }
                ]
              }
            ],
            "resize_keyboard": true,
            "on_time_keyboard": false
          }
        })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

ارسال پیام متنی

  • متد: sendMessage
  • ورودی
فیلد نوع توضیحات
token str توکن
chat_id str شناسه چت
text str متن پیام
disable_notification bool غیرفعال کردن اعلان؟ (پیشفرض false)
reply_to_message_id Optional[str] در جوابِ پیامِ؟
  • خروجی
فیلد نوع توضیحات
message_id str شناسه پیام
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//sendMessage' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "text": "Hello user, this is my text",
                "chat_id": "{chat_id}"
            }'
    

    import requests
    
    data = {
        "chat_id": chat_id,
        "text": "Hello user, this is my text",
    }
    url = f'https://botapi.rubika.ir/v3/{token}/sendMessage'
    response = requests.post(url, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import send_message
    
    send_message(
        token='SUPER_SECRET_TOKEN',
        chat_id='CHAT_ID',
        text='Hello World',
    )
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//sendMessage',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "chat_id": chat_id,
        "text": "Hello user, this is my text"
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

ارسال نظرسنجی

  • متد: sendPoll
  • ورودی
فیلد نوع توضیحات
token str توکن
chat_id str شناسه چت
question str متن سوال
options list[str] گزینه‌های سوال
  • خروجی
فیلد نوع توضیحات
message_id str شناسه پیام
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//sendPoll' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "chat_id": "{chat_id}",
                "question": "Do you have any question?",
                "options": ["yes", "no"]
            }'
    

    import requests
    
    data = {
        "chat_id": chat_id,
        "question": "Do you have any question?",
        "options": ["yes", "no"],
    }
    url = f'https://botapi.rubika.ir/v3/{token}/sendPoll'
    response = requests.post(url, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import send_poll
    
    send_poll(
        token='SUPER_SECRET_TOKEN',
        chat_id='CHAT_ID',
        question='Do you have any question?',
        options=['yes', 'no']
    )
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//sendPoll',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "chat_id": chat_id,
        "question": "Do you have any question?",
        "options": ["yes", "no"],
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

ارسال موقعیت مکانی

  • متد: sendLocation
  • ورودی
فیلد نوع توضیحات
token str توکن
chat_id str شناسه چت
latitude str عرض جغرافیایی
longitude str طول جغرافیایی
chat_keypad str keypad
disable_notification str غیرفعال کردن اعلان؟ (پیشفرض false)
inline_keypad Optional[Keypad] Keypad
reply_to_message_id str در جوابِ پیامِ؟
chat_keypad_type str نوع keypad
  • خروجی
فیلد نوع توضیحات
message_id str شناسه پیام
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//sendLocation' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "chat_id": "{chat_id}",
                "latitude": "{latitude}",
                "longitude": "{longitude}"
            }'
    

    import requests
    
    data = {
        "chat_id": chat_id,
        "latitude": latitude,
        "longitude": longitude,
    }
    url = f'https://botapi.rubika.ir/v3/{token}/sendLocation'
    response = requests.post(url, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import send_location
    
    send_location(
        token='SUPER_SECRET_TOKEN',
        chat_id='CHAT_ID',
        latitude='35.759662741892626',
        longitude='51.4036344416759'
    )
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//sendLocation',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "chat_id": chat_id,
        "latitude": latitude,
        "longitude": longitude,
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

ارسال مخاطب

  • متد: sendContact
  • ورودی
فیلد نوع توضیحات
token str توکن
chat_id str شناسه چت
first_name str نام مخاطب
last_name str نام‌خانوادگی مخاطب
phone_number str شماره مخاطب
chat_keypad str keypad
disable_notification str غیرفعال کردن اعلان؟ (پیشفرض false)
inline_keypad Optional[Keypad] keypad
reply_to_message_id str در جوابِ پیامِ؟
chat_keypad_type str نوع keypad
  • خروجی
فیلد نوع توضیحات
message_id str شناسه پیام
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//getUpdates' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "chat_id": "{chat_id}",
                "first_name": "{first_name}",
                "last_name": "{last_name}",
                "phone_number": "{phone_number}"
            }'
    

    import requests
    
    data = {
        "chat_id": chat_id,
        "first_name": first_name,
        "last_name": last_name,
        "phone_number": phone_number,
    }
    url = f'https://botapi.rubika.ir/v3/{token}/sendContact'
    response = requests.post(url, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import send_contact
    
    send_contact(
        token='SUPER_SECRET_TOKEN',
        chat_id='CHAT_ID',
        first_name='Ali',
        last_name='Rn',
        phone_number='09038754321'
    )
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//sendContact',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "chat_id": chat_id,
        "first_name": first_name,
        "last_name": last_name,
        "phone_number": phone_number
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

گرفتن اطلاعات چت

  • متد: getChat
  • ورودی
فیلد نوع توضیحات
token str توکن
chat_id str شناسه چت
  • خروجی
فیلد نوع توضیحات
chat Chat چت
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//getChat' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "chat_id": "{chat_id}"
            }'
    

    import requests
    
    data = {
        "chat_id": chat_id,
    }
    url = f'https://botapi.rubika.ir/v3/{token}/getChat'
    response = requests.post(url, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import get_chat
    from rubika_bot.models import Chat
    
    chat: Chat = get_chat(
        token='SUPER_SECRET_TOKEN',
        chat_id='CHAT_ID',
    )
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//getChat',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "chat_id": chat_id
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

گرفتن آخرین آپدیت‌ها

  • متد: getUpdates
  • ورودی
فیلد نوع توضیحات
token str توکن
offset_id str ...
limit int ...
  • خروجی
فیلد نوع توضیحات
updates list[Update] آرایه‌ای از آپدیت ها
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//getUpdates' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "limit": "{limit}"
            }'
    

    import requests
    
    data = {
        "limit": limit,
    }
    url = f'https://botapi.rubika.ir/v3/{token}/getUpdates'
    response = requests.post(url, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import get_updates
    from rubika_bot.models import Update
    
    updates, _ = get_updates(
        token='SUPER_SECRET_TOKEN',
        limit=10,
    )
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//getUpdates',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "limit": limit,
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

فوروارد کردن پیام

  • متد: forwardMessage
  • ورودی
فیلد نوع توضیحات
token str توکن
from_chat_id str از چتِ؟
message_id str شناسه پیام
to_chat_id str به چتِ؟
disable_notification bool غیرفعال کردن اعلان؟ (پیشفرض false)
  • خروجی
فیلد نوع توضیحات
new_message_id str شناسه پیام جدید
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//forwardMessage' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "from_chat_id": "{chat_id}",
                "message_id": "{message_id}",
                "to_chat_id": "{to_chat_id}"
            }'
    

    import requests
    
    data = {
        "from_chat_id": chat_id,
        "message_id": message_id,
        "to_chat_id": to_chat_id
    }
    url = f'https://botapi.rubika.ir/v3/{token}/frowardMessage'
    response = requests.post(url, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import forward_message
    
    forward_message(
        token='SUPER_SECRET_TOKEN',
        from_chat_id='FIRST_CHAT_ID',
        message_id='MESSAGE_ID',
        to_chat_id='SECOND_CHAT_ID'
    )
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//frowardMessage',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "from_chat_id": from_chat_id,
        "message_id": message_id,
        "to_chat_id": to_chat_id
      })
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

ویرایش متن پیام

  • متد: editMessageText
  • ورودی
فیلد نوع توضیحات
token str توکن
chat_id str شناسه چت
message_id str شناسه پیام
text str پیام
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//editMessageText' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "chat_id": "{chat_id}",
                "message_id": "{message_id}",
                "text": "this is my new text"
            }'
    

    import requests
    
    data = {
        "chat_id": chat_id,
        "message_id": message_id,
        "text": "this is my new text"
    }
    url = f'https://botapi.rubika.ir/v3/{token}/editMessageText'
    response = requests.post(url, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import edit_message_text
    
    edit_message_text(
        token='SUPER_SECRET_TOKEN',
        chat_id='CHAT_ID',
        message_id='MESSAGE_ID',
        text='New Message Text'
    )
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//editMessageText',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "chat_id": chat_id,
        "message_id": message_id,
        "text": "this is my new text"
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

ویرایش Inline Keypad

  • متد: editMessageKeypad
  • ورودی
فیلد نوع توضیحات
token str توکن
chat_id str شناسه چت
message_id str شناسه پیام
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//editInlineKeypad' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "chat_id": "{chat_id}",
                "message_id": "{message_id}",
                "inline_keypad": {
                    "rows": [
                        {
                            "buttons": [
                                {
                                    "id": "100",
                                    "type": "Simple",
                                    "button_text": "Add Account"
                                }
                            ]
                        },
                        {
                            "buttons": [
                                {
                                    "id": "101",
                                    "type": "Simple",
                                    "button_text": "Edit Account"
                                },
                                {
                                    "id": "102",
                                    "type": "Simple",
                                    "button_text": "Remove Account"
                                }
                            ]
                        }
                    ]
                }
            }'
    

    import requests
    import json
    
    url = f"https://botapi.rubika.ir/v3/{token}/editMessageText"
    
    data = {
      "chat_id": chat_id,
      "message_id": message_id,
      "inline_keypad": {
        "rows": [
          {
            "buttons": [
              {
                "id": "100",
                "type": "Simple",
                "button_text": "Add Account"
              }
            ]
          },
          {
            "buttons": [
              {
                "id": "101",
                "type": "Simple",
                "button_text": "Edit Account"
              },
              {
                "id": "102",
                "type": "Simple",
                "button_text": "Remove Account"
              }
            ]
          }
        ]
      }
    }
    headers = {
      'Content-Type': 'application/json'
    }
    
    response = requests.post(url, headers=headers, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import edit_message_keypad
    from rubika_bot.models import Button, Keypad, KeypadRow
    
    b1 = Button(id='100', type='Simple', button_text='Add Account')
    b2 = Button(id='101', type='Simple', button_text='Edit Account')
    b3 = Button(id='102', type='Simple', button_text='Remove Account')
    new_keypad = Keypad(
        rows=[
            KeypadRow(buttons=[b1]),
            KeypadRow(buttons=[b2, b3])
        ],
    )
    
    edit_message_keypad(
        token='SUPER_SECRET_TOKEN',
        chat_id='CHAT_ID',
        message_id='MESSAGE_ID',
        inline_keypad=new_keypad
    )
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//editMessageText',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
          "chat_id": chat_id,
          "message_id": message_id,
          "inline_keypad": {
            "rows": [
              {
                "buttons": [
                  {
                    "id": "100",
                    "type": "Simple",
                    "button_text": "Add Account"
                  }
                ]
              },
              {
                "buttons": [
                  {
                    "id": "101",
                    "type": "Simple",
                    "button_text": "Edit Account"
                  },
                  {
                    "id": "102",
                    "type": "Simple",
                    "button_text": "Remove Account"
                  }
                ]
              }
            ]
          }
        })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

حذف پیام

  • متد: deleteMessage
  • ورودی
فیلد نوع توضیحات
token str توکن
chat_id str شناسه چت
message_id str شناسه پیام
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//deleteMessage' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "chat_id": "{chat_id}",
                "message_id": "{message_id}"
            }'
    

    import requests
    
    data = {
        "chat_id": chat_id,
        "message_id": chat_id
    }
    url = f'https://botapi.rubika.ir/v3/{token}/deleteMessage'
    response = requests.post(url, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import delete_message
    
    delete_message(
        token='SUPER_SECRET_TOKEN',
        chat_id='CHAT_ID',
        message_id='MESSAGE_ID',
    )
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//deleteMessage',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "chat_id": chat_id,
        "message_id": message_id
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

تنظیم دستور‌ها (commands)

  • متد: setCommands
  • ورودی
فیلد نوع توضیحات
token str توکن
bot_commands list[BotCommand] آرایه‌ای از دستورات
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//setCommands' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "bot_commands": [
                    {
                        "command": "command1",
                        "description": "description1"
                    },
                    {
                        "command": "command2",
                        "description": "description2"
                    },
                ]
            }'
    

    import requests
    
    data = {
        "bot_commands": [
            {
                "command": "command1",
                "description": "description1"
            },
            {
                "command": "command2",
                "description": "description2"
            },
        ]
    }
    url = f'https://botapi.rubika.ir/v3/{token}/setCommands'
    response = requests.post(url, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import set_commands
    from rubika_bot.models import BotCommand
    
    commands = [
        BotCommand(command='command1', description='description 1'),
        BotCommand(command='command2', description='description 2'),
    ]
    set_commands(token='SUPER_SECRET_TOKEN', bot_commands=commands)
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//setCommands',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
          "bot_commands": [
              {
                  "command": "command1",
                  "description": "description1"
              },
              {
                  "command": "command2",
                  "description": "description2"
              },
          ]
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

آپدیت آدرس بات (URL Endpoint)

  • متد: updateBotEndpoints
  • ورودی
فیلد نوع توضیحات
token str توکن
url str آدرس جدید
type UpdateEndpointTypeEnum نوع آدرس
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//updateBotEndpoints' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "url": "https://example.com",
                "type": "GetSelectionItem"
            }'
    

    import requests
    
    data = {
        'url': 'https://example.com',
        'type': 'GetSelectionItem',
    }
    url = f'https://botapi.rubika.ir/v3/{token}/updateBotEndpoints'
    response = requests.post(url, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import update_bot_endpoint
    
    
    update_bot_endpoint(token='SUPER_SECRET_TOKEN', url='https://example.com', type='GetSelectionItem')
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//updateBotEndpoints',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "url": 'https://example.com',
        "type": "GetSelectionItem"
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

حذف keypad

  • متد: editChatKeypad
  • ورودی
فیلد نوع توضیحات
token str توکن
chat_id str شناسه چت
chat_keypad_type str مقدارِ Removed
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//editChatKeypad' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "chat_id": "{chat_id}",
                "chat_keypad_type": "Removed"
            }'
    

    import requests
    
    data = {
        "chat_id": chat_id,
        "chat_keypad_type": "Removed",
    }
    url = f'https://botapi.rubika.ir/v3/{token}/editChatKeypad'
    response = requests.post(url, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import remove_chat_keypad
    
    remove_chat_keypad(token='SUPER_SECRET_TOKEN', chat_id='CHAT_ID')
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//editChatKeypad',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        "chat_id": chat_id,
        "chat_keypad_type": "Removed"
      })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });
    

ویرایش keypad

  • متد: editChatKeypad
  • ورودی
فیلد نوع توضیحات
token str توکن
chat_id str شناسه چت
chat_keypad Keypad keypad
chat_keypad_type str مقدارِ New
  • مثال

    curl --location -g --request POST 'https://botapi.rubika.ir/v3//editChatKeypad' \
            --header 'Content-Type: application/json' \
            --data-raw '{
                "chat_id": "{chat_id}",
                "chat_keypad_type": "New",
                "chat_keypad": {
                    "rows": [
                        {
                            "buttons": [
                                {
                                    "id": "100",
                                    "type": "Simple",
                                    "button_text": "Add Account"
                                }
                            ]
                        },
                        {
                            "buttons": [
                                {
                                    "id": "101",
                                    "type": "Simple",
                                    "button_text": "Edit Account"
                                },
                                {
                                    "id": "102",
                                    "type": "Simple",
                                    "button_text": "Remove Account"
                                }
                            ]
                        }
                    ],
                    "resize_keyboard": true,
                    "on_time_keyboard": false
                }
            }'
    

    import requests
    
    url = f"https://botapi.rubika.ir/v3/{token}/editChatKeypad"
    
    data = {
        "chat_id": chat_id,
        "chat_keypad_type": "New",
        "chat_keypad": {
            "rows": [
                {
                    "buttons": [
                        {
                            "id": "100",
                            "type": "Simple",
                            "button_text": "Add Account"
                        }
                    ]
                },
                {
                    "buttons": [
                        {
                            "id": "101",
                            "type": "Simple",
                            "button_text": "Edit Account"
                        },
                        {
                            "id": "102",
                            "type": "Simple",
                            "button_text": "Remove Account"
                        }
                    ]
                }
            ],
            "resize_keyboard": True,
            "on_time_keyboard": False
        }
    }
    headers = {
        'Content-Type': 'application/json'
    }
    
    response = requests.post(url, headers=headers, data=data)
    
    print(response.text)
    

    from rubika_bot.requests import edit_chat_keypad
    from rubika_bot.models import Keypad, KeypadRow, Button
    
    b1 = Button(id='100', type='Simple', button_text='Add Account')
    b2 = Button(id='101', type='Simple', button_text='Edit Account')
    b3 = Button(id='102', type='Simple', button_text='Remove Account')
    keypad = Keypad(
        rows=[
            KeypadRow(buttons=[b1]),
            KeypadRow(buttons=[b2, b3])
        ],
        resize_keyboard=True,
        on_time_keyboard=False
    )
    
    edit_chat_keypad(token='SUPER_SECRET_TOKEN', chat_id='CHAT_ID', chat_keypad=keypad)
    

    var request = require('request');
    var options = {
      'method': 'POST',
      'url': 'https://botapi.rubika.ir/v3//editChatKeypad',
      'headers': {
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
          "chat_id": chat_id,
          "chat_keypad_type": "New",
          "chat_keypad": {
            "rows": [
              {
                "buttons": [
                  {
                    "id": "100",
                    "type": "Simple",
                    "button_text": "Add Account"
                  }
                ]
              },
              {
                "buttons": [
                  {
                    "id": "101",
                    "type": "Simple",
                    "button_text": "Edit Account"
                  },
                  {
                    "id": "102",
                    "type": "Simple",
                    "button_text": "Remove Account"
                  }
                ]
              }
            ],
            "resize_keyboard": true,
            "on_time_keyboard": false
          }
        })
    
    };
    request(options, function (error, response) {
      if (error) throw new Error(error);
      console.log(response.body);
    });