use super::*;
impl Client {
pub fn channel_op(&self, user_id: UserId, channel_id: ChannelId, make_op: bool) -> i32 {
if !can_issue_logged_in_command(self.connection_state()) {
return 0;
}
unsafe {
ffi::api().TT_DoChannelOp(self.ptr.0, user_id.0, channel_id.0, i32::from(make_op))
}
}
pub fn kick_user(&self, user_id: UserId, channel_id: ChannelId) -> i32 {
if !can_issue_logged_in_command(self.connection_state()) {
return 0;
}
unsafe { ffi::api().TT_DoKickUser(self.ptr.0, user_id.0, channel_id.0) }
}
pub fn ban_user(&self, user_id: UserId, channel_id: ChannelId) -> i32 {
if !can_issue_logged_in_command(self.connection_state()) {
return 0;
}
unsafe { ffi::api().TT_DoBanUser(self.ptr.0, user_id.0, channel_id.0) }
}
pub fn ban_user_ex(&self, user_id: UserId, ban_types: u32) -> i32 {
if !can_issue_logged_in_command(self.connection_state()) {
return 0;
}
unsafe { ffi::api().TT_DoBanUserEx(self.ptr.0, user_id.0, ban_types) }
}
pub fn unban_user(&self, ip: &str, channel_id: ChannelId) -> i32 {
if !can_issue_logged_in_command(self.connection_state()) {
return 0;
}
unsafe { ffi::api().TT_DoUnBanUser(self.ptr.0, ip.tt().as_ptr(), channel_id.0) }
}
pub fn ban(&self, banned_user: &crate::types::BannedUser) -> i32 {
if !can_issue_logged_in_command(self.connection_state()) {
return 0;
}
unsafe { ffi::api().TT_DoBan(self.ptr.0, &banned_user.to_ffi()) }
}
pub fn unban_ex(&self, banned_user: &crate::types::BannedUser) -> i32 {
if !can_issue_logged_in_command(self.connection_state()) {
return 0;
}
unsafe { ffi::api().TT_DoUnBanUserEx(self.ptr.0, &banned_user.to_ffi()) }
}
pub fn channel_op_ex(
&self,
user_id: UserId,
channel_id: ChannelId,
password: &str,
make_op: bool,
) -> i32 {
if !can_issue_logged_in_command(self.connection_state()) {
return 0;
}
unsafe {
ffi::api().TT_DoChannelOpEx(
self.ptr.0,
user_id.0,
channel_id.0,
password.tt().as_ptr(),
if make_op { 1 } else { 0 },
)
}
}
pub fn set_channel_operator(
&self,
user_id: UserId,
channel_id: ChannelId,
make_op: bool,
) -> i32 {
self.channel_op(user_id, channel_id, make_op)
}
pub fn set_user_operator(&self, user_id: UserId, channel_id: ChannelId, make_op: bool) -> i32 {
self.set_channel_operator(user_id, channel_id, make_op)
}
pub fn set_user_operator_ex(
&self,
user_id: UserId,
channel_id: ChannelId,
password: &str,
make_op: bool,
) -> i32 {
self.channel_op_ex(user_id, channel_id, password, make_op)
}
pub fn op_user(&self, user_id: UserId, channel_id: ChannelId) -> i32 {
self.set_channel_operator(user_id, channel_id, true)
}
pub fn deop_user(&self, user_id: UserId, channel_id: ChannelId) -> i32 {
self.set_channel_operator(user_id, channel_id, false)
}
pub fn op_user_ex(&self, user_id: UserId, channel_id: ChannelId, password: &str) -> i32 {
self.set_user_operator_ex(user_id, channel_id, password, true)
}
pub fn deop_user_ex(&self, user_id: UserId, channel_id: ChannelId, password: &str) -> i32 {
self.set_user_operator_ex(user_id, channel_id, password, false)
}
}