متد ها
گرفتن اطلاعات بات
متد: getMe
اطلاعات پایهای بات را بازمیگرداند، شامل نام، نام کاربری،
شناسه و... تا بتوان هویت و تنظیمات اولیه بات را بررسی کرد.
ورودی
این متد اطلاعات پایهای بات را برمیگرداند. معمولاً برای تست
اتصال بات و شناسایی آن استفاده میشود و هیچ پارامتری به عنوان
ورودی دریافت نمیکند.
خروجی
ارسال پیام (Text, Keypad, InlineKeypad)
متد: sendMessage
این متد پیام را از بات به یک چت ارسال میکند و نوع محتوا را
میتوان مشخص کرد. مانند ارسال Text، Keypad یا InlineKeypad
برای دریافت پاسخ مستقیم کاربر.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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 );
});
ارسال پیام متنی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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
این متد امکان ارسال نظرسنجی از بات به چت را فراهم میکند، شامل
سوال، گزینهها و تنظیمات تعامل کاربران با نظرسنجی.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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
این متد موقعیت مکانی را از بات به چت ارسال میکند و شامل
مختصات طول و عرض جغرافیایی است.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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
این متد امکان ارسال اطلاعات تماس (شماره تلفن و نام فرد) از بات
به چت را فراهم میکند تا کاربران بتوانند بهطور مستقیم با آن
تماس برقرار کنند.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/sendContact' \
-- 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 , json = 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/{token}/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
این متد اطلاعات کامل یک چت مشخص را بازمیگرداند، شامل شناسه،
نام، نوع، تصویر و تنظیمات آن، تا بات بتواند ویژگیها و وضعیت
چت را مدیریت یا بررسی کند.
ورودی
گرفتن آخرین آپدیتها
متد: getUpdates
این متد تمامی پیامها، ویرایشها و رویدادهای جدید مربوط به
چتها را از سرور دریافت میکند. با استفاده از آن، بات میتواند
فعالیتهای کاربران، پاسخها، و تغییرات پیامها را دنبال کند.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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
این متد پیام موجود در یک چت را به چت دیگری منتقل میکند، بدون
تغییر محتوا و با حفظ اطلاعات اصلی پیام.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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
این متد متن یک پیام ارسالشده توسط بات را ویرایش میکند، بدون
ایجاد پیام جدید در چت.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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
این متد صفحهکلید (InlineKeypad) یک پیام موجود را بهروزرسانی
میکند، بدون تغییر متن پیام.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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
این متد یک پیام مشخص را از چت حذف میکند، شامل پیامهای ارسالی
بات یا پیامهای دیگران (در صورت داشتن مجوز).
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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
این متد فهرست دستورات قابل استفاده بات را تعریف یا بهروزرسانی
میکند تا کاربر بتواند آنها را در رابط بات مشاهده کند.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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
این متد آدرسهای endpoint بات را بهروزرسانی میکند تا سرور
بتواند رویدادها و درخواستها را به آدرسهای جدید ارسال کند.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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
این متد با مشخص کردن پارامتر chat_keypad_type با
مقدار Remove، صفحهکلید مرتبط با چت را حذف میکند
و گزینههای تعاملی موجود در پیامها را از بین میبرد.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/editChatKeypad' \
-- header 'Content-Type: application/json' \
-- data - raw '{
"chat_id" : " {chat_id} " ,
"chat_keypad_type" : "Remove"
} '
import requests
data = {
"chat_id" : chat_id ,
"chat_keypad_type" : "Remove" ,
}
url = f 'https://botapi.rubika.ir/v3/ { token } /editChatKeypad'
response = requests . post ( url , json = 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/{token}/editChatKeypad' ,
'headers' : {
'Content-Type' : 'application/json'
},
body : JSON . stringify ({
"chat_id" : chat_id ,
"chat_keypad_type" : "Remove"
})
};
request ( options , function ( error , response ) {
if ( error ) throw new Error ( error );
console . log ( response . body );
});
ویرایش keypad
متد: editChatKeypad
برای ویرایش صفحهکلید مرتبط با چت، باید پارامتر
chat_keypad_type را برابر New قرار دهید؛ این متد صفحهکلید
مرتبط با چت را بهروزرسانی میکند.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/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 , json = 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/{token}/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 );
});
دریافت فایل
متد: getFile
این متد مسیر دانلود یک فایل آپلود شده را بازمیگرداند، تا بات
بتواند فایل را دریافت کند.
ورودی
ارسال فایل
متد: sendFile
این متد فایل مشخص شده را از بات به چت ارسال میکند، فایل
میتواند شامل محتوا و گزینههای اضافی مانند متن همراه یا
صفحهکلید باشد.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/sendFile' \
-- header 'Content-Type: application/json' \
-- data - raw '{
"chat_id" : " {chat_id} " ,
"file_id" : " {file_id} " ,
} '
import requests
data = {
"chat_id" : chat_id ,
"file_id" : file_id ,
}
url = f 'https://botapi.rubika.ir/v3/ { token } /sendFile'
response = requests . post ( url , json = data )
print ( response . text )
from rubika_bot.requests import sendFile
send_sticker (
token = 'SUPER_SECRET_TOKEN' ,
chat_id = 'CHAT_ID' ,
file_id = 'FILE_ID' ,
)
var request = require ( 'request' );
var options = {
'method' : 'POST' ,
'url' : 'https://botapi.rubika.ir/v3/{token}/sendFile' ,
'headers' : {
'Content-Type' : 'application/json'
},
body : JSON . stringify ({
"chat_id" : chat_id ,
"file_id" : file_id ,
})
};
request ( options , function ( error , response ) {
if ( error ) throw new Error ( error );
console . log ( response . body );
});
آپلود فایل
متد: requestSendFile
این متد به بات امکان میدهد نوع فایل مورد نظر برای آپلود را
مشخص کند و در پاسخ، یک آدرس برای بارگذاری فایل دریافت میکند
تا فایل مورد نظر از طریق آن آدرس به سرور ارسال شود.
ورودی
مثال
cURL Python NodeJs
curl -- location - g -- request POST 'https://botapi.rubika.ir/v3/{token}/requestSendFile' \
-- header 'Content-Type: application/json' \
-- data - raw '{
"type" : " Image " ,
} '
import requests
data = {
"type" : "Image" ,
}
url = f 'https://botapi.rubika.ir/v3/ { token } /requestSendFile'
response = requests . post ( url , json = data )
print ( response . text )
from rubika_bot.requests import requestSendFile
send_sticker (
token = 'SUPER_SECRET_TOKEN' ,
type = "Image" ,
)
var request = require ( 'request' );
var options = {
'method' : 'POST' ,
'url' : 'https://botapi.rubika.ir/v3/{token}/requestSendFile' ,
'headers' : {
'Content-Type' : 'application/json'
},
body : JSON . stringify ({
"type" : "Image" ,
})
};
request ( options , function ( error , response ) {
if ( error ) throw new Error ( error );
console . log ( response . body );
});
آدرس دریافت شده در یک فیلد با نام
upload_url برمیگردد که برای آپلود فایل از طریق
درخواست POST استفاده میشود. فایل باید در بدنه
(Body)
درخواست ارسال گردد.