⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 command.c

📁 打魔兽战网的都知道他是什么
💻 C
📖 第 1 页 / 共 5 页
字号:
	return -1;    }    if (account_get_auth_admin(conn_get_account(c),NULL)!=1 && account_get_auth_admin(conn_get_account(c),channel)!=1) {	message_send_text(c,message_type_error,c,"You must be at least a Channel Admin to use this command.");	return -1;    }    text = skip_command(text);    if (!(username = &text[0])) {	message_send_text(c, message_type_info, c, "You need to supply a username.");	return -1;    }    if(!(acc = accountlist_find_account(username))) {	sprintf(msgtemp, "There's no account with username %.64s.", username);	message_send_text(c, message_type_info, c, msgtemp);	return -1;    }    dst_c = account_get_conn(acc);    if (account_get_auth_admin(acc,channel) == 1)	sprintf(msgtemp,"%s is already a Channel Admin",username);    else {	account_set_auth_admin(acc,channel,1);	sprintf(msgtemp,"%s has been promoted to a Channel Admin",username);	sprintf(msgtemp2,"%s has promoted you to a Channel Admin for channel \"%s\"",conn_get_loggeduser(c),channel);	changed = 1;    }    if (changed && dst_c) message_send_text(dst_c, message_type_info, c, msgtemp2);    message_send_text(c, message_type_info, c, msgtemp);    command_set_flags(dst_c);    return 0;}static int _handle_vop_command(t_connection * c, char const * text){    char const *	username;    char const *	channel;    t_account *		acc;    t_connection *	dst_c;    int			changed = 0;    if (!(conn_get_channel(c)) || !(channel = channel_get_name(conn_get_channel(c)))) {	message_send_text(c,message_type_error,c,"This command can only be used inside a channel.");	return -1;    }    if (account_get_auth_admin(conn_get_account(c),NULL)!=1 && account_get_auth_admin(conn_get_account(c),channel)!=1) {	message_send_text(c,message_type_error,c,"You must be at least a Channel Admin to use this command.");	return -1;    }    text = skip_command(text);    if (!(username = &text[0])) {	message_send_text(c, message_type_info, c, "You need to supply a username.");	return -1;    }    if(!(acc = accountlist_find_account(username))) {	sprintf(msgtemp, "There's no account with username %.64s.", username);	message_send_text(c, message_type_info, c, msgtemp);	return -1;    }    dst_c = account_get_conn(acc);    if (account_get_auth_voice(acc,channel) == 1)	sprintf(msgtemp,"%s is already on VOP list",username);    else {	account_set_auth_voice(acc,channel,1);	sprintf(msgtemp,"%s has been added to the VOP list",username);	sprintf(msgtemp2,"%s has added you to the VOP list of channel \"%s\"",conn_get_loggeduser(c),channel);	changed = 1;    }    if (changed && dst_c) message_send_text(dst_c, message_type_info, c, msgtemp2);    message_send_text(c, message_type_info, c, msgtemp);    command_set_flags(dst_c);    return 0;}static int _handle_voice_command(t_connection * c, char const * text){    char const *	username;    char const *	channel;    t_account *		acc;    t_connection *	dst_c;    int			changed = 0;    if (!(conn_get_channel(c)) || !(channel = channel_get_name(conn_get_channel(c)))) {	message_send_text(c,message_type_error,c,"This command can only be used inside a channel.");	return -1;    }    if (!(account_is_operator_or_admin(conn_get_account(c),channel_get_name(conn_get_channel(c))))) {	message_send_text(c,message_type_error,c,"You must be at least a Channel Operator to use this command.");	return -1;    }    text = skip_command(text);    if (!(username = &text[0])) {	message_send_text(c, message_type_info, c, "You need to supply a username.");	return -1;    }    if(!(acc = accountlist_find_account(username))) {	sprintf(msgtemp, "There's no account with username %.64s.", username);	message_send_text(c, message_type_info, c, msgtemp);	return -1;    }    dst_c = account_get_conn(acc);    if (account_get_auth_voice(acc,channel)==1)	sprintf(msgtemp,"%s is already on VOP list, no need to Voice him", username);    else    {      if ((!dst_c) || conn_get_channel(c)!=conn_get_channel(dst_c))      {	sprintf(msgtemp,"%s must be on the same channel to voice him",username);      }      else      {        if (channel_conn_has_tmpVOICE(conn_get_channel(c),dst_c))	    sprintf(msgtemp,"%s has already Voice in this channel",username);        else {	  if (account_is_operator_or_admin(acc,channel))	    sprintf(msgtemp,"%s allready is operator or admin, no need to voice him",username);	  else	  {	    conn_set_tmpVOICE_channel(dst_c,channel);	    sprintf(msgtemp,"%s has been granted Voice in this channel",username);	    sprintf(msgtemp2,"%s has granted you Voice in this channel",conn_get_loggeduser(c));	    changed = 1;	  }	}      }    }    if (changed && dst_c) message_send_text(dst_c, message_type_info, c, msgtemp2);    message_send_text(c, message_type_info, c, msgtemp);    command_set_flags(dst_c);    return 0;}static int _handle_devoice_command(t_connection * c, char const * text){    char const *	username;    char const *	channel;    t_account *		acc;    t_connection *	dst_c;    int			done = 0;    int			changed = 0;    if (!(conn_get_channel(c)) || !(channel = channel_get_name(conn_get_channel(c)))) {	message_send_text(c,message_type_error,c,"This command can only be used inside a channel.");	return -1;    }    if (!(account_is_operator_or_admin(conn_get_account(c),channel_get_name(conn_get_channel(c))))) {	message_send_text(c,message_type_error,c,"You must be at least a Channel Operator to use this command.");	return -1;    }    text = skip_command(text);    if (!(username = &text[0])) {	message_send_text(c, message_type_info, c, "You need to supply a username.");	return -1;    }    if(!(acc = accountlist_find_account(username))) {	sprintf(msgtemp, "There's no account with username %.64s.", username);	message_send_text(c, message_type_info, c, msgtemp);	return -1;    }    dst_c = account_get_conn(acc);    if (account_get_auth_voice(acc,channel)==1)    {	if ((account_get_auth_admin(conn_get_account(c),channel)==1) || (account_get_auth_admin(conn_get_account(c),NULL)==1))	{	    account_set_auth_voice(acc,channel,0);	    sprintf(msgtemp,"%s has been removed from VOP list.",username);	    sprintf(msgtemp2,"%s has removed you from VOP list of channel \"%s\"",conn_get_loggeduser(c),channel);	    changed = 1;	}	else	{	    sprintf(msgtemp,"You must be at least Channel Admin to remove %s from the VOP list",username);	}	done = 1;    }    if (changed && dst_c) message_send_text(dst_c, message_type_info, c, msgtemp2);    message_send_text(c, message_type_info, c, msgtemp);    changed = 0;    if ((dst_c) && channel_conn_has_tmpVOICE(conn_get_channel(c),dst_c)==1)    {      conn_set_tmpVOICE_channel(dst_c,NULL);      sprintf(msgtemp,"Voice has been taken from %s in this channel",username);      sprintf(msgtemp2,"%s has taken your Voice in channel \"%s\"",conn_get_loggeduser(c),channel);      changed = 1;      done = 1;    }    if (changed && dst_c) message_send_text(dst_c, message_type_info, c, msgtemp2);    message_send_text(c, message_type_info, c, msgtemp);    if (!done)    {     sprintf(msgtemp,"%s has no Voice in this channel, so it can't be taken away",username);     message_send_text(c, message_type_info, c, msgtemp);    }    command_set_flags(dst_c);    return 0;}static int _handle_op_command(t_connection * c, char const * text){    char const *	username;    char const *	channel;    t_account *		acc;    int			OP_lvl;    t_connection * 	dst_c;    int			changed = 0;    if (!(conn_get_channel(c)) || !(channel = channel_get_name(conn_get_channel(c)))) {	message_send_text(c,message_type_error,c,"This command can only be used inside a channel.");	return -1;    }    acc = conn_get_account(c);    OP_lvl = 0;    if (account_is_operator_or_admin(acc,channel))      OP_lvl = 1;    else if (channel_conn_is_tmpOP(conn_get_channel(c),c))      OP_lvl = 2;    if (OP_lvl==0)    {	message_send_text(c,message_type_error,c,"You must be at least a Channel Operator or tempOP to use this command.");	return -1;    }    text = skip_command(text);    if (!(username = &text[0])) {	message_send_text(c, message_type_info, c, "You need to supply a username.");	return -1;    }    if(!(acc = accountlist_find_account(username))) {	sprintf(msgtemp, "There's no account with username %.64s.", username);	message_send_text(c, message_type_info, c, msgtemp);	return -1;    }    dst_c = account_get_conn(acc);    if (OP_lvl==1) // user is full op so he may fully op others    {      if (account_get_auth_operator(acc,channel) == 1)	  sprintf(msgtemp,"%s is allready a Channel Operator",username);      else {	  account_set_auth_operator(acc,channel,1);	  sprintf(msgtemp,"%s has been promoted to a Channel Operator",username);	  sprintf(msgtemp2,"%s has promoted you to a Channel Operator in channel \"%s\"",conn_get_loggeduser(c),channel);	  changed = 1;      }    }    else { // user is only tempOP so he may only tempOP others         if ((!(dst_c)) || (conn_get_channel(c) != conn_get_channel(dst_c)))          sprintf(msgtemp,"%s must be on the same channel to tempOP him",username);         else         {	   if (account_is_operator_or_admin(acc,channel))	     sprintf(msgtemp,"%s allready is operator or admin, no need to tempOP him",username);	   else	   {             conn_set_tmpOP_channel(dst_c,channel);	     sprintf(msgtemp,"%s has been promoted to a tempOP",username);	     sprintf(msgtemp2,"%s has promoted you to a tempOP in this channel",conn_get_loggeduser(c));	     changed = 1;	   }         }    }    if (changed && dst_c) message_send_text(dst_c, message_type_info, c, msgtemp2);    message_send_text(c, message_type_info, c, msgtemp);    command_set_flags(dst_c);    return 0;}static int _handle_tmpop_command(t_connection * c, char const * text){    char const *	username;    char const *	channel;    t_account *		acc;    t_connection *	dst_c;    int			changed = 0;    if (!(conn_get_channel(c)) || !(channel = channel_get_name(conn_get_channel(c)))) {	message_send_text(c,message_type_error,c,"This command can only be used inside a channel.");	return -1;    }    if (!(account_is_operator_or_admin(conn_get_account(c),channel_get_name(conn_get_channel(c))) || channel_conn_is_tmpOP(conn_get_channel(c),c))) {	message_send_text(c,message_type_error,c,"You must be at least a Channel Operator or tmpOP to use this command.");	return -1;    }    text = skip_command(text);    if (!(username = &text[0])) {	message_send_text(c, message_type_info, c, "You need to supply a username.");	return -1;    }    if(!(acc = accountlist_find_account(username))) {	sprintf(msgtemp, "There's no account with username %.64s.", username);	message_send_text(c, message_type_info, c, msgtemp);	return -1;    }    dst_c = account_get_conn(acc);    if (channel_conn_is_tmpOP(conn_get_channel(c),dst_c))       sprintf(msgtemp,"%s has already tmpOP in this channel",username);    else    {       if ((!(dst_c)) || (conn_get_channel(c) != conn_get_channel(dst_c)))       sprintf(msgtemp,"%s must be on the same channel to tempOP him",username);       else       {	 if (account_is_operator_or_admin(acc,channel))	   sprintf(msgtemp,"%s allready is operator or admin, no need to tempOP him",username);	 else	 {           conn_set_tmpOP_channel(dst_c,channel);           sprintf(msgtemp,"%s has been promoted to tmpOP in this channel",username);	   sprintf(msgtemp2,"%s has promoted you to a tempOP in this channel",conn_get_loggeduser(c));	   changed = 1;	 }       }    }    if (changed && dst_c) message_send_text(dst_c, message_type_info, c, msgtemp2);    message_send_text(c, message_type_info, c, msgtemp);    command_set_flags(dst_c);    return 0;}static int _handle_deop_command(t_connection * c, char const * text){    char const *	username;    char const *	channel;    t_account *		acc;    int			OP_lvl;    t_connection *	dst_c;    int			done = 0;    if (!(conn_get_channel(c)) || !(channel = channel_get_name(conn_get_channel(c)))) {	message_send_text(c,message_type_error,c,"This command can only be used inside a channel.");	return -1;    }    acc = conn_get_account(c);    OP_lvl = 0;    if (account_is_operator_or_admin(acc,channel))      OP_lvl = 1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -